public static BlockPos getZeroPositionWithTransform(BlockPos p_191157_0_, Mirror p_191157_1_, Rotation p_191157_2_, int p_191157_3_, int p_191157_4_) { --p_191157_3_; --p_191157_4_; int i = p_191157_1_ == Mirror.FRONT_BACK ? p_191157_3_ : 0; int j = p_191157_1_ == Mirror.LEFT_RIGHT ? p_191157_4_ : 0; BlockPos blockpos = p_191157_0_; switch (p_191157_2_) { case COUNTERCLOCKWISE_90: blockpos = p_191157_0_.add(j, 0, p_191157_3_ - i); break; case CLOCKWISE_90: blockpos = p_191157_0_.add(p_191157_4_ - j, 0, i); break; case CLOCKWISE_180: blockpos = p_191157_0_.add(p_191157_3_ - i, 0, p_191157_4_ - j); break; case NONE: blockpos = p_191157_0_.add(i, 0, j); } return blockpos; }
protected void setBlockState(World worldIn, IBlockState blockstateIn, int x, int y, int z, StructureBoundingBox boundingboxIn) { BlockPos blockpos = new BlockPos(this.getXWithOffset(x, z), this.getYWithOffset(y), this.getZWithOffset(x, z)); if (boundingboxIn.isVecInside(blockpos)) { if (this.mirror != Mirror.NONE) { blockstateIn = blockstateIn.withMirror(this.mirror); } if (this.rotation != Rotation.NONE) { blockstateIn = blockstateIn.withRotation(this.rotation); } worldIn.setBlockState(blockpos, blockstateIn, 2); } }
/** * Transforms the entity's current yaw with the given Mirror and returns it. This does not have a side-effect. */ public float getMirroredYaw(Mirror transformMirror) { float f = MathHelper.wrapDegrees(this.rotationYaw); switch (transformMirror) { case LEFT_RIGHT: return -f; case FRONT_BACK: return 180.0F - f; default: return f; } }
public BlockPos getZeroPositionWithTransform(BlockPos p_189961_1_, Mirror p_189961_2_, Rotation p_189961_3_) { int i = this.getSize().getX() - 1; int j = this.getSize().getZ() - 1; int k = p_189961_2_ == Mirror.FRONT_BACK ? i : 0; int l = p_189961_2_ == Mirror.LEFT_RIGHT ? j : 0; BlockPos blockpos = p_189961_1_; switch (p_189961_3_) { case COUNTERCLOCKWISE_90: blockpos = p_189961_1_.add(l, 0, i - k); break; case CLOCKWISE_90: blockpos = p_189961_1_.add(j - l, 0, k); break; case CLOCKWISE_180: blockpos = p_189961_1_.add(i - k, 0, j - l); break; case NONE: blockpos = p_189961_1_.add(k, 0, l); } return blockpos; }
private void updateMirrorButton() { Mirror mirror = this.tileStructure.getMirror(); switch (mirror) { case NONE: this.mirrorButton.displayString = "|"; break; case LEFT_RIGHT: this.mirrorButton.displayString = "< >"; break; case FRONT_BACK: this.mirrorButton.displayString = "^ v"; } }
private void addEntitiesToWorld(World worldIn, BlockPos pos, Mirror mirrorIn, Rotation rotationIn, @Nullable StructureBoundingBox aabb) { for (Template.EntityInfo template$entityinfo : this.entities) { BlockPos blockpos = transformedBlockPos(template$entityinfo.blockPos, mirrorIn, rotationIn).add(pos); if (aabb == null || aabb.isVecInside(blockpos)) { NBTTagCompound nbttagcompound = template$entityinfo.entityData; Vec3d vec3d = transformedVec3d(template$entityinfo.pos, mirrorIn, rotationIn); Vec3d vec3d1 = vec3d.addVector((double)pos.getX(), (double)pos.getY(), (double)pos.getZ()); NBTTagList nbttaglist = new NBTTagList(); nbttaglist.appendTag(new NBTTagDouble(vec3d1.x)); nbttaglist.appendTag(new NBTTagDouble(vec3d1.y)); nbttaglist.appendTag(new NBTTagDouble(vec3d1.z)); nbttagcompound.setTag("Pos", nbttaglist); nbttagcompound.setUniqueId("UUID", UUID.randomUUID()); Entity entity; try { entity = EntityList.createEntityFromNBT(nbttagcompound, worldIn); } catch (Exception var15) { entity = null; } if (entity != null) { float f = entity.getMirroredYaw(mirrorIn); f = f + (entity.rotationYaw - entity.getRotatedYaw(rotationIn)); entity.setLocationAndAngles(vec3d1.x, vec3d1.y, vec3d1.z, f, entity.rotationPitch); worldIn.spawnEntity(entity); } } } }
private static BlockPos transformedBlockPos(BlockPos pos, Mirror mirrorIn, Rotation rotationIn) { int i = pos.getX(); int j = pos.getY(); int k = pos.getZ(); boolean flag = true; switch (mirrorIn) { case LEFT_RIGHT: k = -k; break; case FRONT_BACK: i = -i; break; default: flag = false; } switch (rotationIn) { case COUNTERCLOCKWISE_90: return new BlockPos(k, j, -i); case CLOCKWISE_90: return new BlockPos(-k, j, i); case CLOCKWISE_180: return new BlockPos(-i, j, -k); default: return flag ? new BlockPos(i, j, k) : pos; } }
private static Vec3d transformedVec3d(Vec3d vec, Mirror mirrorIn, Rotation rotationIn) { double d0 = vec.x; double d1 = vec.y; double d2 = vec.z; boolean flag = true; switch (mirrorIn) { case LEFT_RIGHT: d2 = 1.0D - d2; break; case FRONT_BACK: d0 = 1.0D - d0; break; default: flag = false; } switch (rotationIn) { case COUNTERCLOCKWISE_90: return new Vec3d(d2, d1, 1.0D - d0); case CLOCKWISE_90: return new Vec3d(1.0D - d2, d1, d0); case CLOCKWISE_180: return new Vec3d(1.0D - d0, d1, 1.0D - d2); default: return flag ? new Vec3d(d0, d1, d2) : vec; } }
private void addEntitiesToWorld(World worldIn, BlockPos pos, Mirror mirrorIn, Rotation rotationIn, @Nullable StructureBoundingBox aabb) { for (Template.EntityInfo template$entityinfo : this.entities) { BlockPos blockpos = transformedBlockPos(template$entityinfo.blockPos, mirrorIn, rotationIn).add(pos); if (aabb == null || aabb.isVecInside(blockpos)) { NBTTagCompound nbttagcompound = template$entityinfo.entityData; Vec3d vec3d = transformedVec3d(template$entityinfo.pos, mirrorIn, rotationIn); Vec3d vec3d1 = vec3d.addVector((double)pos.getX(), (double)pos.getY(), (double)pos.getZ()); NBTTagList nbttaglist = new NBTTagList(); nbttaglist.appendTag(new NBTTagDouble(vec3d1.xCoord)); nbttaglist.appendTag(new NBTTagDouble(vec3d1.yCoord)); nbttaglist.appendTag(new NBTTagDouble(vec3d1.zCoord)); nbttagcompound.setTag("Pos", nbttaglist); nbttagcompound.setUniqueId("UUID", UUID.randomUUID()); Entity entity; try { entity = EntityList.createEntityFromNBT(nbttagcompound, worldIn); } catch (Exception var15) { entity = null; } if (entity != null) { float f = entity.getMirroredYaw(mirrorIn); f = f + (entity.rotationYaw - entity.getRotatedYaw(rotationIn)); entity.setLocationAndAngles(vec3d1.xCoord, vec3d1.yCoord, vec3d1.zCoord, f, entity.rotationPitch); worldIn.spawnEntityInWorld(entity); } } } }
@Override public float getMirroredYaw(Mirror transformMirror) { if (m_realPlayer == null) { return super.getMirroredYaw(transformMirror); } else { syncToRealPlayer(); return syncPublicFieldsFromRealAndReturn(m_realPlayer.getMirroredYaw(transformMirror)); } }
@Override public float getMirroredYaw(Mirror transformMirror) { if (m_realPlayer == null) { return super.getMirroredYaw(transformMirror); } else { return m_realPlayer.getMirroredYaw(transformMirror); } }
/** * 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); } }
private static Vec3d transformedVec3d(Vec3d vec, Mirror mirrorIn, Rotation rotationIn) { double d0 = vec.xCoord; double d1 = vec.yCoord; double d2 = vec.zCoord; boolean flag = true; switch (mirrorIn) { case LEFT_RIGHT: d2 = 1.0D - d2; break; case FRONT_BACK: d0 = 1.0D - d0; break; default: flag = false; } switch (rotationIn) { case COUNTERCLOCKWISE_90: return new Vec3d(d2, d1, 1.0D - d0); case CLOCKWISE_90: return new Vec3d(1.0D - d2, d1, d0); case CLOCKWISE_180: return new Vec3d(1.0D - d0, d1, 1.0D - d2); default: return flag ? new Vec3d(d0, d1, d2) : vec; } }
public static BlockPos func_191157_a(BlockPos p_191157_0_, Mirror p_191157_1_, Rotation p_191157_2_, int p_191157_3_, int p_191157_4_) { --p_191157_3_; --p_191157_4_; int i = p_191157_1_ == Mirror.FRONT_BACK ? p_191157_3_ : 0; int j = p_191157_1_ == Mirror.LEFT_RIGHT ? p_191157_4_ : 0; BlockPos blockpos = p_191157_0_; switch (p_191157_2_) { case COUNTERCLOCKWISE_90: blockpos = p_191157_0_.add(j, 0, p_191157_3_ - i); break; case CLOCKWISE_90: blockpos = p_191157_0_.add(p_191157_4_ - j, 0, i); break; case CLOCKWISE_180: blockpos = p_191157_0_.add(p_191157_3_ - i, 0, p_191157_4_ - j); break; case NONE: blockpos = p_191157_0_.add(i, 0, j); } return blockpos; }
public MansionTemplate(TemplateManager p_i47356_1_, String p_i47356_2_, BlockPos p_i47356_3_, Rotation p_i47356_4_, Mirror p_i47356_5_) { super(0); this.field_191082_d = p_i47356_2_; this.templatePosition = p_i47356_3_; this.field_191083_e = p_i47356_4_; this.field_191084_f = p_i47356_5_; this.func_191081_a(p_i47356_1_); }
private void func_191129_a(List<WoodlandMansionPieces.MansionTemplate> p_191129_1_, BlockPos p_191129_2_, Rotation p_191129_3_, EnumFacing p_191129_4_, WoodlandMansionPieces.RoomCollection p_191129_5_) { Rotation rotation = Rotation.NONE; String s = p_191129_5_.func_191104_a(this.field_191135_b); if (p_191129_4_ != EnumFacing.EAST) { if (p_191129_4_ == EnumFacing.NORTH) { rotation = rotation.add(Rotation.COUNTERCLOCKWISE_90); } else if (p_191129_4_ == EnumFacing.WEST) { rotation = rotation.add(Rotation.CLOCKWISE_180); } else if (p_191129_4_ == EnumFacing.SOUTH) { rotation = rotation.add(Rotation.CLOCKWISE_90); } else { s = p_191129_5_.func_191099_b(this.field_191135_b); } } BlockPos blockpos = Template.func_191157_a(new BlockPos(1, 0, 0), Mirror.NONE, rotation, 7, 7); rotation = rotation.add(p_191129_3_); blockpos = blockpos.func_190942_a(p_191129_3_); BlockPos blockpos1 = p_191129_2_.add(blockpos.getX(), 0, blockpos.getZ()); p_191129_1_.add(new WoodlandMansionPieces.MansionTemplate(this.field_191134_a, s, blockpos1, rotation)); }
public boolean generate(World worldIn, Random rand, BlockPos position) { Random random = worldIn.getChunkFromBlockCoords(position).getRandomWithSeed(987234911L); MinecraftServer minecraftserver = worldIn.getMinecraftServer(); Rotation[] arotation = Rotation.values(); Rotation rotation = arotation[random.nextInt(arotation.length)]; int i = random.nextInt(FOSSILS.length); TemplateManager templatemanager = worldIn.getSaveHandler().getStructureTemplateManager(); Template template = templatemanager.getTemplate(minecraftserver, FOSSILS[i]); Template template1 = templatemanager.getTemplate(minecraftserver, FOSSILS_COAL[i]); ChunkPos chunkpos = new ChunkPos(position); StructureBoundingBox structureboundingbox = new StructureBoundingBox(chunkpos.getXStart(), 0, chunkpos.getZStart(), chunkpos.getXEnd(), 256, chunkpos.getZEnd()); PlacementSettings placementsettings = (new PlacementSettings()).setRotation(rotation).setBoundingBox(structureboundingbox).setRandom(random); BlockPos blockpos = template.transformedSize(rotation); int j = random.nextInt(16 - blockpos.getX()); int k = random.nextInt(16 - blockpos.getZ()); int l = 256; for (int i1 = 0; i1 < blockpos.getX(); ++i1) { for (int j1 = 0; j1 < blockpos.getX(); ++j1) { l = Math.min(l, worldIn.getHeight(position.getX() + i1 + j, position.getZ() + j1 + k)); } } int k1 = Math.max(l - 15 - random.nextInt(10), 10); BlockPos blockpos1 = template.getZeroPositionWithTransform(position.add(j, k1, k), Mirror.NONE, rotation); placementsettings.setIntegrity(0.9F); template.addBlocksToWorld(worldIn, blockpos1, placementsettings, 20); placementsettings.setIntegrity(0.1F); template1.addBlocksToWorld(worldIn, blockpos1, placementsettings, 20); return true; }
public boolean generate(World worldIn, Random rand, BlockPos position) { Random random = worldIn.getChunkFromChunkCoords(position.getX(), position.getZ()).getRandomWithSeed(987234911L); MinecraftServer minecraftserver = worldIn.getMinecraftServer(); Rotation[] arotation = Rotation.values(); Rotation rotation = arotation[random.nextInt(arotation.length)]; int i = random.nextInt(FOSSILS.length); TemplateManager templatemanager = worldIn.getSaveHandler().getStructureTemplateManager(); Template template = templatemanager.getTemplate(minecraftserver, FOSSILS[i]); Template template1 = templatemanager.getTemplate(minecraftserver, FOSSILS_COAL[i]); ChunkPos chunkpos = new ChunkPos(position); StructureBoundingBox structureboundingbox = new StructureBoundingBox(chunkpos.getXStart(), 0, chunkpos.getZStart(), chunkpos.getXEnd(), 256, chunkpos.getZEnd()); PlacementSettings placementsettings = (new PlacementSettings()).setRotation(rotation).setBoundingBox(structureboundingbox).setRandom(random); BlockPos blockpos = template.transformedSize(rotation); int j = random.nextInt(16 - blockpos.getX()); int k = random.nextInt(16 - blockpos.getZ()); int l = 256; for (int i1 = 0; i1 < blockpos.getX(); ++i1) { for (int j1 = 0; j1 < blockpos.getX(); ++j1) { l = Math.min(l, worldIn.getHeightmapHeight(position.getX() + i1 + j, position.getZ() + j1 + k)); } } int k1 = Math.max(l - 15 - random.nextInt(10), 10); BlockPos blockpos1 = template.getZeroPositionWithTransform(position.add(j, k1, k), Mirror.NONE, rotation); placementsettings.setIntegrity(0.9F); template.addBlocksToWorld(worldIn, blockpos1, placementsettings, 4); placementsettings.setIntegrity(0.1F); template1.addBlocksToWorld(worldIn, blockpos1, placementsettings, 4); return true; }
public void mirror(Mirror p_189668_1_) { if (this.worldObj != null && this.worldObj.getBlockState(this.getPos()).getValue(BlockSkull.FACING) == EnumFacing.UP) { this.skullRotation = p_189668_1_.mirrorRotation(this.skullRotation, 16); } }
public void setCoordBaseMode(@Nullable EnumFacing facing) { this.coordBaseMode = facing; if (facing == null) { this.rotation = Rotation.NONE; this.mirror = Mirror.NONE; } else { switch (facing) { case SOUTH: this.mirror = Mirror.LEFT_RIGHT; this.rotation = Rotation.NONE; break; case WEST: this.mirror = Mirror.LEFT_RIGHT; this.rotation = Rotation.CLOCKWISE_90; break; case EAST: this.mirror = Mirror.NONE; this.rotation = Rotation.CLOCKWISE_90; break; default: this.mirror = Mirror.NONE; this.rotation = Rotation.NONE; } } }
/** * 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.withProperty(ROTATION, Integer.valueOf(mirrorIn.mirrorRotation(((Integer)state.getValue(ROTATION)).intValue(), 16))); }
/** * 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((EnumFacing)state.getValue(FACING))); }
public void generateTower(WorldServer world, BlockPos pos, Random rand) { MinecraftServer server = world.getMinecraftServer(); Template template = world.getStructureTemplateManager().getTemplate(server, TOWER_STRUCTURE); PlacementSettings settings = new PlacementSettings(); settings.setRotation(Rotation.values()[rand.nextInt(Rotation.values().length)]); BlockPos size = template.getSize(); int airBlocks = 0; for(int x = 0; x < size.getX(); x++) { for (int z = 0; z < size.getZ(); z++) { if (world.isAirBlock(pos.add(template.transformedBlockPos(settings, new BlockPos(x, 0, z))))) { airBlocks++; if (airBlocks > 0.33 * (size.getX() * size.getZ())) { return; } } } } for (int x = 0; x < size.getX(); x++) { for (int z = 0; z < size.getZ(); z++) { if (x == 0 || x == size.getX() - 1 || z == 0 || z == size.getZ() - 1) { for (int y = 0; y < size.getY(); y++) { BlockPos checkPos = pos.add(template.transformedBlockPos(settings, new BlockPos(x, y, z))); IBlockState checkState = world.getBlockState(checkPos); if (!checkState.getBlock().isAir(checkState, world, checkPos)) { if (!(y <= 3 && (checkState.getBlock() == Blocks.NETHERRACK || checkState.getBlock() == Blocks.QUARTZ_ORE || checkState.getBlock() == Blocks.MAGMA))) { return; } } } } } } template.addBlocksToWorld(world, pos, settings); Map<BlockPos, String> dataBlocks = template.getDataBlocks(pos, settings); for (Entry<BlockPos, String> entry : dataBlocks.entrySet()) { String[] tokens = entry.getValue().split(" "); if (tokens.length == 0) return; BlockPos dataPos = entry.getKey(); EntityPigMage pigMage; switch (tokens[0]) { case "pigman_mage": pigMage = new EntityPigMage(world); pigMage.setPosition(dataPos.getX() + 0.5, dataPos.getY(), dataPos.getZ() + 0.5); pigMage.onInitialSpawn(world.getDifficultyForLocation(dataPos), null); world.spawnEntity(pigMage); break; case "fortress_chest": IBlockState chestState = Blocks.CHEST.getDefaultState().withRotation(settings.getRotation()); chestState = chestState.withMirror(Mirror.FRONT_BACK); world.setBlockState(dataPos, chestState); TileEntity tile = world.getTileEntity(dataPos); if (tile != null && tile instanceof TileEntityLockableLoot) ((TileEntityLockableLoot) tile).setLootTable(NETHER_BRIDGE_LOOT_TABLE, rand.nextLong()); break; } } }
@Override public IBlockState withMirror(IBlockState state, Mirror mirrorIn) { return state.withRotation(mirrorIn.toRotation(state.getValue(FACING))); }
@Override public IBlockState withMirror(IBlockState state, Mirror mirrorIn) { return state.withRotation(mirrorIn.toRotation((EnumFacing) state.getValue(FACING))); }
/** * Transforms the entity's current yaw with the given Mirror and returns it. This does not have a side-effect. */ public float getMirroredYaw(Mirror transformMirror) { return this.getRotatedYaw(transformMirror.toRotation(this.facingDirection)); }
@Override public IBlockState withMirror(IBlockState state, Mirror mirror) { return HorizontalFacingController.withMirror(state, mirror); }