Java Code Examples for net.minecraft.util.Mirror#NONE

The following examples show how to use net.minecraft.util.Mirror#NONE . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SchematicPlacingUtils.java    From litematica with GNU Lesser General Public License v3.0 6 votes vote down vote up
public static void rotateEntity(Entity entity, double x, double y, double z, Rotation rotationCombined, Mirror mirrorMain, Mirror mirrorSub)
{
    float rotationYaw = entity.rotationYaw;

    if (mirrorMain != Mirror.NONE)          { rotationYaw = entity.getMirroredYaw(mirrorMain); }
    if (mirrorSub != Mirror.NONE)           { rotationYaw = entity.getMirroredYaw(mirrorSub); }
    if (rotationCombined != Rotation.NONE)  { rotationYaw += entity.rotationYaw - entity.getRotatedYaw(rotationCombined); }

    entity.setLocationAndAngles(x, y, z, rotationYaw, entity.rotationPitch);

    entity.prevRotationYaw = rotationYaw;
    entity.prevRotationPitch = entity.rotationPitch;

    if (entity instanceof EntityLivingBase)
    {
        EntityLivingBase livingBase = (EntityLivingBase) entity;
        livingBase.rotationYawHead = rotationYaw;
        livingBase.prevRotationYawHead = rotationYaw;
        livingBase.renderYawOffset = rotationYaw;
        livingBase.prevRenderYawOffset = rotationYaw;
    }
}
 
Example 2
Source File: SubRegionPlacement.java    From litematica with GNU Lesser General Public License v3.0 5 votes vote down vote up
void resetToOriginalValues()
{
    this.pos = this.defaultPos;
    this.rotation = Rotation.NONE;
    this.mirror = Mirror.NONE;
    this.enabled = true;
    this.ignoreEntities = false;
}
 
Example 3
Source File: SubRegionPlacement.java    From litematica with GNU Lesser General Public License v3.0 5 votes vote down vote up
public boolean isRegionPlacementModified(BlockPos originalPosition)
{
    return this.isEnabled() == false ||
           this.ignoreEntities() ||
           this.getMirror() != Mirror.NONE ||
           this.getRotation() != Rotation.NONE ||
           this.getPos().equals(originalPosition) == false;
}
 
Example 4
Source File: SchematicUtils.java    From litematica with GNU Lesser General Public License v3.0 5 votes vote down vote up
public static IBlockState getUntransformedBlockState(IBlockState state, SchematicPlacement schematicPlacement, String subRegionName)
{
    SubRegionPlacement placement = schematicPlacement.getRelativeSubRegionPlacement(subRegionName);

    if (placement != null)
    {
        final Rotation rotationCombined = PositionUtils.getReverseRotation(schematicPlacement.getRotation().add(placement.getRotation()));
        final Mirror mirrorMain = schematicPlacement.getMirror();
        Mirror mirrorSub = placement.getMirror();

        if (mirrorSub != Mirror.NONE &&
            (schematicPlacement.getRotation() == Rotation.CLOCKWISE_90 ||
             schematicPlacement.getRotation() == Rotation.COUNTERCLOCKWISE_90))
        {
            mirrorSub = mirrorSub == Mirror.FRONT_BACK ? Mirror.LEFT_RIGHT : Mirror.FRONT_BACK;
        }

        if (rotationCombined != Rotation.NONE)
        {
            state = state.withRotation(rotationCombined);
        }

        if (mirrorSub != Mirror.NONE)
        {
            state = state.withMirror(mirrorSub);
        }

        if (mirrorMain != Mirror.NONE)
        {
            state = state.withMirror(mirrorMain);
        }
    }

    return state;
}
 
Example 5
Source File: ItemBuildersWand.java    From enderutilities with GNU Lesser General Public License v3.0 5 votes vote down vote up
private void toggleMirror(ItemStack stack, Mode mode, EntityPlayer player)
{
    Mirror mirror = player.getHorizontalFacing().getAxis() == EnumFacing.Axis.Z ? Mirror.LEFT_RIGHT : Mirror.FRONT_BACK;

    // Same mirror setting as the one stored, toggle mirror off
    if (mirror == this.getMirror(stack) && this.isMirrored(stack))
    {
        mirror = Mirror.NONE;
    }

    this.setMirror(stack, mode, mirror);
}
 
Example 6
Source File: ItemBuildersWand.java    From enderutilities with GNU Lesser General Public License v3.0 5 votes vote down vote up
public Mirror getMirror(ItemStack stack, Mode mode)
{
    int sel = this.getSelectionIndex(stack);
    NBTTagCompound tag = this.getModeTag(stack, mode);

    if (tag.getBoolean("IsMirrored_" + sel) && tag.hasKey("Mirror_" + sel, Constants.NBT.TAG_BYTE))
    {
        return Mirror.values()[tag.getByte("Mirror_" + sel) % Mirror.values().length];
    }

    return Mirror.NONE;
}
 
Example 7
Source File: TofuCastlePiece.java    From TofuCraftReload with MIT License 4 votes vote down vote up
public TofuCastleTemplate(TemplateManager manager, BlockPos pos, Rotation rotation, String templateName) {
    this(manager, pos, rotation, Mirror.NONE, templateName);
}
 
Example 8
Source File: SchematicPlacementUnloaded.java    From litematica with GNU Lesser General Public License v3.0 4 votes vote down vote up
/**
 * Writes the most important/basic settings to JSON.
 * If <b>minimal</b> is true, then only non-default rotation, mirror etc. values are included,
 * and the name is not included. This is meant for sharing the settings string with other people.
 * @param minimal
 * @return
 */
public JsonObject baseSettingsToJson(boolean minimal)
{
    JsonObject obj = new JsonObject();
    boolean all = minimal == false;

    obj.add("origin", JsonUtils.blockPosToJson(this.origin));

    if (all)
    {
        obj.add("name", new JsonPrimitive(this.name));
    }

    if (this.rotation != Rotation.NONE)
    {
        obj.add("rotation", new JsonPrimitive(this.rotation.name()));
    }

    if (this.mirror != Mirror.NONE)
    {
        obj.add("mirror", new JsonPrimitive(this.mirror.name()));
    }

    if (this.ignoreEntities())
    {
        obj.add("ignore_entities", new JsonPrimitive(this.ignoreEntities()));
    }

    if (this.gridSettings.isInitialized() && this.gridSettings.isAtDefaultValues() == false)
    {
        obj.add("grid", this.gridSettings.toJson());
    }

    if ((all || this.isRegionPlacementModified()) && this.relativeSubRegionPlacements.isEmpty() == false)
    {
        JsonArray arr = new JsonArray();

        for (Map.Entry<String, SubRegionPlacement> entry : this.relativeSubRegionPlacements.entrySet())
        {
            JsonObject placementObj = new JsonObject();
            placementObj.add("name", new JsonPrimitive(entry.getKey()));
            placementObj.add("placement", entry.getValue().toJson());
            arr.add(placementObj);
        }

        obj.add("placements", arr);
    }

    return obj;
}