net.minecraft.util.Mirror Java Examples
The following examples show how to use
net.minecraft.util.Mirror.
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: WorldGenAbandonedBase.java From GregTech with GNU Lesser General Public License v3.0 | 6 votes |
@Override public void generate(Random random, int chunkX, int chunkZ, World world, IChunkGenerator chunkGenerator, IChunkProvider chunkProvider) { if (ConfigHolder.abandonedBaseRarity == 0 || world.getWorldType() == WorldType.FLAT || world.provider.getDimensionType() != DimensionType.OVERWORLD || !world.getWorldInfo().isMapFeaturesEnabled()) { return; //do not generate in flat worlds, or in non-surface worlds } BlockPos randomPos = new BlockPos(chunkX * 16 + 8, 0, chunkZ * 16 + 8); if (random.nextInt(ConfigHolder.abandonedBaseRarity) == 0) { int variantNumber = random.nextInt(3); Rotation rotation = Rotation.values()[random.nextInt(Rotation.values().length)]; ResourceLocation templateId = new ResourceLocation(GTValues.MODID, "abandoned_base/abandoned_base_1_" + variantNumber); Template template = TemplateManager.getBuiltinTemplate(world, templateId); BlockPos originPos = template.getZeroPositionWithTransform(randomPos, Mirror.NONE, rotation); originPos = TemplateManager.calculateAverageGroundLevel(world, originPos, template.getSize()); template.addBlocksToWorld(world, originPos, new PlacementSettings().setRotation(rotation)); } }
Example #2
Source File: PositionUtils.java From litematica with GNU Lesser General Public License v3.0 | 6 votes |
public static float getMirroredYaw(float yaw, Mirror mirror) { yaw = MathHelper.wrapDegrees(yaw); switch (mirror) { case LEFT_RIGHT: yaw = 180.0F - yaw; break; case FRONT_BACK: yaw = -yaw; break; default: } return yaw; }
Example #3
Source File: SchematicPlacementManager.java From litematica with GNU Lesser General Public License v3.0 | 6 votes |
public void setSubRegionMirror(SchematicPlacement placement, String regionName, Mirror mirror, IMessageConsumer feedback) { if (placement.isLocked()) { feedback.addMessage(MessageType.ERROR, "litematica.message.placement.cant_modify_is_locked"); return; } SubRegionPlacement subPlacement = placement.getRelativeSubRegionPlacement(regionName); if (subPlacement != null) { this.onPrePlacementChange(placement); placement.setSubRegionMirror(regionName, mirror); this.onPlacementRegionModified(placement); } }
Example #4
Source File: SchematicPlacingUtils.java From litematica with GNU Lesser General Public License v3.0 | 6 votes |
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 #5
Source File: PositionUtils.java From enderutilities with GNU Lesser General Public License v3.0 | 5 votes |
/** * Mirrors and then rotates the given position around the origin */ public static BlockPosEU getTransformedBlockPos(BlockPosEU pos, Mirror mirror, Rotation rotation) { int x = pos.getX(); int y = pos.getY(); int z = pos.getZ(); boolean isMirrored = true; switch (mirror) { // LEFT_RIGHT is essentially NORTH_SOUTH case LEFT_RIGHT: z = -z; break; // FRONT_BACK is essentially EAST_WEST case FRONT_BACK: x = -x; break; default: isMirrored = false; } switch (rotation) { case CLOCKWISE_90: return new BlockPosEU(-z, y, x, pos.getDimension(), pos.getFacing()); case COUNTERCLOCKWISE_90: return new BlockPosEU( z, y, -x, pos.getDimension(), pos.getFacing()); case CLOCKWISE_180: return new BlockPosEU(-x, y, -z, pos.getDimension(), pos.getFacing()); default: return isMirrored ? new BlockPosEU(x, y, z, pos.getDimension(), pos.getFacing()) : pos; } }
Example #6
Source File: TemplateEnderUtilities.java From enderutilities with GNU Lesser General Public License v3.0 | 5 votes |
public void placeBlockAtIndex(World world, int index, BlockPos posStart) { if (index < this.blocks.size()) { TemplateEnderUtilities.TemplateBlockInfo blockInfo = this.blocks.get(index); BlockPos pos = transformedBlockPos(this.placement, blockInfo.pos).add(posStart); IBlockState stateNew = blockInfo.blockState; if (this.replaceMode == ReplaceMode.EVERYTHING || (this.replaceMode == ReplaceMode.WITH_NON_AIR && stateNew.getMaterial() != Material.AIR) || world.isAirBlock(pos)) { Mirror mirror = this.placement.getMirror(); Rotation rotation = this.placement.getRotation(); stateNew = stateNew.withMirror(mirror).withRotation(rotation); boolean success = false; if (this.dropOldBlocks) { world.destroyBlock(pos, true); } /* else { // Replace the block temporarily so that the old TE gets cleared for sure BlockUtils.setBlockToAirWithoutSpillingContents(world, pos, 4); } */ // Place the new block success = world.setBlockState(pos, stateNew, 2); if (success && blockInfo.tileEntityData != null) { TileUtils.createAndAddTileEntity(world, pos, blockInfo.tileEntityData, rotation, mirror); } } } }
Example #7
Source File: TofuCastlePiece.java From TofuCraftReload with MIT License | 5 votes |
@Override protected void readStructureFromNBT(NBTTagCompound compound, TemplateManager manager) { super.readStructureFromNBT(compound, manager); this.isAleadyBossRoomGen = compound.getBoolean("BossRoom"); this.templateName = compound.getString("Template"); this.rotation = Rotation.valueOf(compound.getString("Rot")); this.mirror = Mirror.valueOf(compound.getString("Mi")); this.loadTemplate(manager); }
Example #8
Source File: PositionUtils.java From litematica with GNU Lesser General Public License v3.0 | 5 votes |
/** * Mirrors and then rotates the given position around the origin */ public static BlockPos getTransformedBlockPos(BlockPos pos, Mirror mirror, Rotation rotation) { int x = pos.getX(); int y = pos.getY(); int z = pos.getZ(); boolean isMirrored = true; switch (mirror) { // LEFT_RIGHT is essentially NORTH_SOUTH case LEFT_RIGHT: z = -z; break; // FRONT_BACK is essentially EAST_WEST case FRONT_BACK: x = -x; break; default: isMirrored = false; } switch (rotation) { case CLOCKWISE_90: return new BlockPos(-z, y, x); case COUNTERCLOCKWISE_90: return new BlockPos( z, y, -x); case CLOCKWISE_180: return new BlockPos(-x, y, -z); default: return isMirrored ? new BlockPos(x, y, z) : pos; } }
Example #9
Source File: PositionUtils.java From litematica with GNU Lesser General Public License v3.0 | 5 votes |
public static Vec3d getTransformedPosition(Vec3d originalPos, Mirror mirror, Rotation rotation) { double x = originalPos.x; double y = originalPos.y; double z = originalPos.z; boolean transformed = true; switch (mirror) { case LEFT_RIGHT: z = 1.0D - z; break; case FRONT_BACK: x = 1.0D - x; break; default: transformed = false; } switch (rotation) { case COUNTERCLOCKWISE_90: return new Vec3d(z, y, 1.0D - x); case CLOCKWISE_90: return new Vec3d(1.0D - z, y, x); case CLOCKWISE_180: return new Vec3d(1.0D - x, y, 1.0D - z); default: return transformed ? new Vec3d(x, y, z) : originalPos; } }
Example #10
Source File: PositionUtils.java From litematica with GNU Lesser General Public License v3.0 | 5 votes |
public static String getMirrorName(Mirror mirror) { switch (mirror) { case FRONT_BACK: return "FRONT_BACK"; case LEFT_RIGHT: return "LEFT_RIGHT"; case NONE: default: return "NONE"; } }
Example #11
Source File: SchematicPlacementManager.java From litematica with GNU Lesser General Public License v3.0 | 5 votes |
public void setMirror(SchematicPlacement placement, Mirror mirror, IMessageConsumer feedback) { if (placement.isLocked()) { feedback.addMessage(MessageType.ERROR, "litematica.message.placement.cant_modify_is_locked"); return; } if (placement.getMirror() != mirror) { this.onPrePlacementChange(placement); placement.setMirror(mirror); this.onPlacementModified(placement); } }
Example #12
Source File: SubRegionPlacement.java From litematica with GNU Lesser General Public License v3.0 | 5 votes |
void resetToOriginalValues() { this.pos = this.defaultPos; this.rotation = Rotation.NONE; this.mirror = Mirror.NONE; this.enabled = true; this.ignoreEntities = false; }
Example #13
Source File: SubRegionPlacement.java From litematica with GNU Lesser General Public License v3.0 | 5 votes |
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 #14
Source File: SchematicUtils.java From litematica with GNU Lesser General Public License v3.0 | 5 votes |
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 #15
Source File: TofuCastlePiece.java From TofuCraftReload with MIT License | 5 votes |
private TofuCastleTemplate(TemplateManager manager, BlockPos pos, Rotation rotation, Mirror mirror, String templateName) { super(0); this.templatePosition = pos; this.rotation = rotation; this.mirror = mirror; this.templateName = templateName; this.loadTemplate(manager); }
Example #16
Source File: PositionUtils.java From enderutilities with GNU Lesser General Public License v3.0 | 5 votes |
/** * Mirrors and then rotates the given position around the origin */ public static BlockPos getTransformedBlockPos(BlockPos pos, Mirror mirror, Rotation rotation) { int x = pos.getX(); int y = pos.getY(); int z = pos.getZ(); boolean isMirrored = true; switch (mirror) { // LEFT_RIGHT is essentially NORTH_SOUTH case LEFT_RIGHT: z = -z; break; // FRONT_BACK is essentially EAST_WEST case FRONT_BACK: x = -x; break; default: isMirrored = false; } switch (rotation) { case CLOCKWISE_90: return new BlockPos(-z, y, x); case COUNTERCLOCKWISE_90: return new BlockPos( z, y, -x); case CLOCKWISE_180: return new BlockPos(-x, y, -z); default: return isMirrored ? new BlockPos(x, y, z) : pos; } }
Example #17
Source File: TaskMoveArea.java From enderutilities with GNU Lesser General Public License v3.0 | 5 votes |
public TaskMoveArea(int dimension, BlockPos posSrcStart, BlockPos posSrcEnd, BlockPos posDstStart, Rotation rotationDst, Mirror mirrorDst, UUID wandUUID, int blocksPerTick) { this.posSrcStart = posSrcStart; this.posDstStart = posDstStart; this.rotation = rotationDst; this.mirror = mirrorDst; this.wandUUID = wandUUID; this.dimension = dimension; this.blocksPerTick = blocksPerTick; this.boxRelative = new BlockPosBox(BlockPos.ORIGIN, posSrcEnd.subtract(posSrcStart)); this.boxSource = new BlockPosBox(posSrcStart, posSrcEnd); this.handledPositions = new HashSet<BlockPos>(); }
Example #18
Source File: ItemBuildersWand.java From enderutilities with GNU Lesser General Public License v3.0 | 5 votes |
private void moveAreaImmediate(ItemStack stack, World world, EntityPlayer player, BlockPos posSrc1, BlockPos posSrc2, BlockPos posDst1, Mirror mirror, Rotation rotation) { PlacementSettings placement = new PlacementSettings(); placement.setMirror(mirror); placement.setRotation(rotation); placement.setIgnoreEntities(false); placement.setReplacedBlock(Blocks.BARRIER); // meh ReplaceMode replace = WandOption.REPLACE_EXISTING.isEnabled(stack, Mode.MOVE_DST) ? ReplaceMode.EVERYTHING : ReplaceMode.NOTHING; TemplateEnderUtilities template = new TemplateEnderUtilities(placement, replace); template.takeBlocksFromWorld(world, posSrc1, posSrc2.subtract(posSrc1), true, false); this.deleteArea(stack, world, player, posSrc1, posSrc2, true); template.addBlocksToWorld(world, posDst1); }
Example #19
Source File: ItemBuildersWand.java From enderutilities with GNU Lesser General Public License v3.0 | 5 votes |
private void moveEndPosition(ItemStack stack, EntityPlayer player, boolean reverse) { EnumFacing direction = EntityUtils.getClosestLookingDirection(player); Mode mode = Mode.getMode(stack); BlockPosEU posStart = mode == Mode.CUBE || mode == Mode.WALLS ? this.getPosition(stack, mode, POS_START) : this.getPerTemplateAreaCorner(stack, mode, POS_START); BlockPosEU posEnd = this.getPosition(stack, mode, POS_END); if (posEnd == null) { posEnd = posStart; } if (posStart != null && posEnd != null) { int v = reverse ? 1 : -1; posEnd = posEnd.add(direction.getXOffset() * v, direction.getYOffset() * v, direction.getZOffset() * v); if (mode == Mode.WALLS || mode == Mode.CUBE) { this.setPosition(posEnd, false, stack, player); } else { this.setPerTemplateAreaCorner(posEnd, mode, false, stack, player); this.setAreaFacing(stack, mode, PositionUtils.getFacingFromPositions(posStart, posEnd)); this.setMirror(stack, mode, Mirror.NONE); } } }
Example #20
Source File: ItemBuildersWand.java From enderutilities with GNU Lesser General Public License v3.0 | 5 votes |
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 #21
Source File: ItemBuildersWand.java From enderutilities with GNU Lesser General Public License v3.0 | 5 votes |
private void setMirror(ItemStack stack, Mode mode, Mirror mirror) { int sel = this.getSelectionIndex(stack); NBTTagCompound tag = this.getModeTag(stack, mode); tag.setByte("Mirror_" + sel, (byte)mirror.ordinal()); tag.setBoolean("IsMirrored_" + sel, mirror != Mirror.NONE); }
Example #22
Source File: BlockBeaconPost.java From Cyberware with MIT License | 5 votes |
/** * Returns the blockstate with the given mirror of the passed blockstate. If inapplicable, returns the passed * blockstate. */ public IBlockState withMirror(IBlockState state, Mirror mirrorIn) { switch (mirrorIn) { case LEFT_RIGHT: return state.withProperty(NORTH, state.getValue(SOUTH)).withProperty(SOUTH, state.getValue(NORTH)); case FRONT_BACK: return state.withProperty(EAST, state.getValue(WEST)).withProperty(WEST, state.getValue(EAST)); default: return super.withMirror(state, mirrorIn); } }
Example #23
Source File: PositionUtils.java From enderutilities with GNU Lesser General Public License v3.0 | 5 votes |
public static Vec3d transformedVec3d(Vec3d vec, Mirror mirrorIn, Rotation rotationIn) { double x = vec.x; double y = vec.y; double z = vec.z; boolean isMirrored = true; switch (mirrorIn) { case LEFT_RIGHT: z = 1.0D - z; break; case FRONT_BACK: x = 1.0D - x; break; default: isMirrored = false; } switch (rotationIn) { case COUNTERCLOCKWISE_90: return new Vec3d(z, y, 1.0D - x); case CLOCKWISE_90: return new Vec3d(1.0D - z, y, x); case CLOCKWISE_180: return new Vec3d(1.0D - x, y, 1.0D - z); default: return isMirrored ? new Vec3d(x, y, z) : vec; } }
Example #24
Source File: SchematicPlacement.java From litematica with GNU Lesser General Public License v3.0 | 5 votes |
void setSubRegionMirror(String regionName, Mirror mirror) { SubRegionPlacement subRegion = this.relativeSubRegionPlacements.get(regionName); if (subRegion != null) { subRegion.setMirror(mirror); } }
Example #25
Source File: BlockBarrelDistillation.java From Sakura_mod with MIT License | 4 votes |
/** * Returns the blockstate with the given mirror of the passed blockstate. If inapplicable, returns the passed * blockstate. */ public IBlockState withMirror(IBlockState state, Mirror mirrorIn) { return state.withRotation(mirrorIn.toRotation(state.getValue(FACING))); }
Example #26
Source File: BlockMetalPlate.java From BaseMetals with GNU Lesser General Public License v2.1 | 4 votes |
@Override public IBlockState withMirror(IBlockState state, Mirror mirrorIn) { return state.withRotation(mirrorIn.toRotation((EnumFacing)state.getValue(FACING))); }
Example #27
Source File: BlockBlueprintArchive.java From Cyberware with MIT License | 4 votes |
@Override public IBlockState withMirror(IBlockState state, Mirror mirrorIn) { return state.withRotation(mirrorIn.toRotation((EnumFacing)state.getValue(FACING))); }
Example #28
Source File: BlockBeaconLarge.java From Cyberware with MIT License | 4 votes |
@Override public IBlockState withMirror(IBlockState state, Mirror mirrorIn) { return state.withRotation(mirrorIn.toRotation((EnumFacing)state.getValue(FACING))); }
Example #29
Source File: BlockComponentBox.java From Cyberware with MIT License | 4 votes |
@Override public IBlockState withMirror(IBlockState state, Mirror mirrorIn) { return state.withRotation(mirrorIn.toRotation((EnumFacing)state.getValue(FACING))); }
Example #30
Source File: BlockBeacon.java From Cyberware with MIT License | 4 votes |
@Override public IBlockState withMirror(IBlockState state, Mirror mirrorIn) { return state.withRotation(mirrorIn.toRotation((EnumFacing)state.getValue(FACING))); }