private void renderModelBrightnessColorQuads(float p_178264_1_, float p_178264_2_, float p_178264_3_, float p_178264_4_, List<BakedQuad> p_178264_5_) { Tessellator tessellator = Tessellator.getInstance(); WorldRenderer worldrenderer = tessellator.getWorldRenderer(); for (BakedQuad bakedquad : p_178264_5_) { worldrenderer.begin(7, DefaultVertexFormats.ITEM); worldrenderer.addVertexData(bakedquad.getVertexData()); if (bakedquad.hasTintIndex()) { worldrenderer.putColorRGB_F4(p_178264_2_ * p_178264_1_, p_178264_3_ * p_178264_1_, p_178264_4_ * p_178264_1_); } else { worldrenderer.putColorRGB_F4(p_178264_1_, p_178264_1_, p_178264_1_); } Vec3i vec3i = bakedquad.getFace().getDirectionVec(); worldrenderer.putNormal((float)vec3i.getX(), (float)vec3i.getY(), (float)vec3i.getZ()); tessellator.draw(); } }
private void renderModelBrightnessColorQuads(float p_178264_1_, float p_178264_2_, float p_178264_3_, float p_178264_4_, List p_178264_5_) { Tessellator tessellator = Tessellator.getInstance(); WorldRenderer worldrenderer = tessellator.getWorldRenderer(); for (Object bakedquad0 : p_178264_5_) { BakedQuad bakedquad = (BakedQuad)bakedquad0; worldrenderer.begin(7, DefaultVertexFormats.ITEM); worldrenderer.addVertexData(bakedquad.getVertexData()); if (bakedquad.hasTintIndex()) { worldrenderer.putColorRGB_F4(p_178264_2_ * p_178264_1_, p_178264_3_ * p_178264_1_, p_178264_4_ * p_178264_1_); } else { worldrenderer.putColorRGB_F4(p_178264_1_, p_178264_1_, p_178264_1_); } Vec3i vec3i = bakedquad.getFace().getDirectionVec(); worldrenderer.putNormal((float)vec3i.getX(), (float)vec3i.getY(), (float)vec3i.getZ()); tessellator.draw(); } }
private void renderModelBrightnessColorQuads(float p_178264_1_, float p_178264_2_, float p_178264_3_, float p_178264_4_, List p_178264_5_) { Tessellator tessellator = Tessellator.getInstance(); WorldRenderer worldrenderer = tessellator.getWorldRenderer(); for (Object bakedquad0 : p_178264_5_) { BakedQuad bakedquad = (BakedQuad) bakedquad0; worldrenderer.begin(7, DefaultVertexFormats.ITEM); worldrenderer.addVertexData(bakedquad.getVertexData()); if (bakedquad.hasTintIndex()) { worldrenderer.putColorRGB_F4(p_178264_2_ * p_178264_1_, p_178264_3_ * p_178264_1_, p_178264_4_ * p_178264_1_); } else { worldrenderer.putColorRGB_F4(p_178264_1_, p_178264_1_, p_178264_1_); } Vec3i vec3i = bakedquad.getFace().getDirectionVec(); worldrenderer.putNormal((float)vec3i.getX(), (float)vec3i.getY(), (float)vec3i.getZ()); tessellator.draw(); } }
@Override public void renderTileEntityAt(TileEntity t, double x, double y, double z, float f, int i) { TileEntity_Railing tile = (TileEntity_Railing) t; if (!tile.isInvalid()) { GL11.glPushMatrix(); GL11.glTranslated(x + 0.5, y-1, z + 0.5); bindTexture(texture); Block right = tile.getWorld().getBlockState(tile.getPos().add(new Vec3i(1,-1,0))).getBlock(); Block left = tile.getWorld().getBlockState(tile.getPos().add(new Vec3i(-1,0,0))).getBlock(); Block front = tile.getWorld().getBlockState(tile.getPos().add(new Vec3i(0,0,1))).getBlock(); Block back = tile.getWorld().getBlockState(tile.getPos().add(new Vec3i(0,0,-1))).getBlock(); if(!(left instanceof BlockAir)&&!(left instanceof Block_Railing)){ model.renderPart("left"); }else if(!(right instanceof BlockAir)&&!(right instanceof Block_Railing)){ model.renderPart("right"); }else model.renderPart("middle"); GL11.glPopMatrix(); } }
public void renderModelAt(TileEntity_TV tile, double x, double y, double z, float f) { glPushMatrix(); glDisable(GL_CULL_FACE); glEnable(GL_ALPHA_TEST); Block b = tile.getWorld().getBlockState(tile.getPos().subtract(new Vec3i(0, 1, 0))).getBlock(); glTranslatef((float) x + 0.5f, (float) y, (float) z + 0.5f); if (b instanceof Block_TVTable) { glTranslatef(0, -0.5f, 0); } glRotatef(tile.rotation * 90, 0.0F, 1.0F, 0.0F); if (tile.rotation == 0 || tile.rotation == 2) { glRotatef(180, 0.0F, 1.0F, 0.0F); } this.bindTexture(texture); this.model.renderAll(); glPopMatrix(); }
@SideOnly(Side.CLIENT) @Override public void randomDisplayTick(World worldIn, BlockPos pos, IBlockState state, Random rand) { super.randomDisplayTick(worldIn, pos, state, rand); TileEntity_Lantern tile = (TileEntity_Lantern) worldIn.getTileEntity(pos); if (tile.isActive) { this.isBurning = true; setLightLevel(10.0f); } else { setLightLevel(0); isBurning = false; } worldIn.markBlockForUpdate(pos); worldIn.markBlockRangeForRenderUpdate(pos.subtract(new Vec3i(-5,0,-5)), pos.add(5,0,5)); worldIn.notifyNeighborsOfStateChange(pos, this); }
/** * Actually places the door; use after determining door side for best results */ private void placeDoor(World world, Random rand) { Vec3i center = bBox.getCenter(); int x = center.getX(); int y = bBox.minY + (submerged ? 2 : 1); int z = center.getZ(); switch(face) { case SOUTH: z = bBox.maxZ; break; case NORTH: z = bBox.minZ; break; case EAST: x = bBox.maxX; break; case WEST: x = bBox.minX; break; default: // UP and DOWN not possible } world.setBlockState(new BlockPos(x, y, z), door.getStateFromMeta(doorMeta), 2); doorMeta = (door instanceof BlockDoorLocked ? (doorMeta | 8) : doorMeta); // upper part of door world.setBlockState(new BlockPos(x, y + 1, z), (door instanceof BlockPeg ? Blocks.air.getDefaultState() : door.getStateFromMeta(doorMeta)), 2); }
/** * Actually places the door; use after determining door side for best results */ protected void placeDoor(World world) { Vec3i center = bBox.getCenter(); int x = center.getX(); int y = bBox.minY + (submerged ? 2 : 1); int z = center.getZ(); switch(doorSide) { case SOUTH: z = bBox.maxZ; break; case NORTH: z = bBox.minZ; break; case EAST: x = bBox.maxX; break; case WEST: x = bBox.minX; break; default: ZSSMain.logger.warn("Placing Boss door with invalid door side"); } world.setBlockState(new BlockPos(x, y, z), ZSSBlocks.doorBoss.getStateFromMeta(type.ordinal() & ~0x8), 2); world.setBlockState(new BlockPos(x, y + 1, z), ZSSBlocks.doorBoss.getStateFromMeta(type.ordinal() | 0x8), 2); }
/** * Places and generates the contents of this dungeon's main chest */ protected void placeMainChest(World world, Random rand, boolean inCenter) { Vec3i center = bBox.getCenter(); int x = (inCenter ? center.getX() : (rand.nextFloat() < 0.5F ? bBox.minX + 1 : bBox.maxX - 1)); int y = bBox.minY + (inCenter ? 2 : 1) + (submerged && !inOcean ? 1 : 0); int z = (inCenter ? center.getZ() : (rand.nextFloat() < 0.5F ? bBox.minZ + 1 : bBox.maxZ - 1)); BlockPos pos = new BlockPos(x, y, z); Block chest = (inCenter ? Blocks.chest : ZSSBlocks.chestLocked); placeChest(world, pos, chest); if (inCenter) { world.setBlockState(pos, chest.getStateFromMeta(doorSide.getIndex()), 2); } else if (submerged && !inOcean) { world.setBlockState(pos.down(), BlockSecretStone.EnumType.byMetadata(getMetadata()).getDroppedBlock().getDefaultState(), 2); } TileEntity te = world.getTileEntity(pos); if (te instanceof IInventory) { DungeonLootLists.generateBossChestContents(world, rand, (IInventory) te, this); } }
@Override protected boolean placeInOcean(World world, boolean sink) { if (type == BossType.OCEAN) { Vec3i center = bBox.getCenter(); while (bBox.minY > 60 && world.getBlockState(new BlockPos(center.getX(), bBox.minY, center.getZ())).getBlock().getMaterial() == Material.air) { bBox.offset(0, -1, 0); } while (bBox.minY > 16 && world.getBlockState(new BlockPos(center.getX(), bBox.minY, center.getZ())).getBlock().getMaterial() == Material.water) { bBox.offset(0, -1, 0); } if (world.getBlockState(new BlockPos(center.getX(), bBox.minY, center.getZ())).getBlock().getMaterial() != Material.water && world.getBlockState(new BlockPos(center.getX(), bBox.maxY, center.getZ())).getBlock().getMaterial() == Material.water) { inOcean = true; submerged = true; StructureGenUtils.adjustCornersForMaterial(world, bBox, Material.water, 6, false, false); return true; } } return false; }
@Override protected void onUpdateTick(World world) { int nextUpdate = 10; int x = box.minX + world.rand.nextInt(box.getXSize() - 1) + 1; int y = box.maxY - 1; int z = box.minZ + world.rand.nextInt(box.getZSize() - 1) + 1; Vec3i center = box.getCenter(); if (Math.abs(center.getX() - x) > 1 && Math.abs(center.getZ() - z) > 1) { EntityBomb bomb = new EntityBomb(world).setDestructionFactor(0.7F).addTime((3 - difficulty) * 16); bomb.setPosition(x, y, z); if (world.isAirBlock(new BlockPos(x, box.minY, z))) { bomb.setNoGrief(); } if (world.getCollidingBoundingBoxes(bomb, bomb.getEntityBoundingBox()).isEmpty()) { if (!world.isRemote) { world.playSoundEffect(x, y, z, Sounds.BOMB_WHISTLE, 1.0F, 1.0F); world.spawnEntityInWorld(bomb); nextUpdate = ((3 - difficulty) * 100) + 50 + world.rand.nextInt(400); } } } scheduleUpdateTick(nextUpdate); }
/** * Destroys part of a random pillar during boss event * @param explode whether a difficulty-scaled explosion should be created as well */ protected void destroyRandomPillar(World world, boolean explode) { Vec3i center = box.getCenter(); int corner = world.rand.nextInt(4); int offset = (box.getXSize() < 11 ? 2 : 3); int x = (corner < 2 ? ((box.getXSize() < 11 ? center.getX() : box.minX) + offset) : ((box.getXSize() < 11 ? center.getX() : box.maxX) - offset)); int y = box.minY + (world.rand.nextInt(3) + 1); int z = (corner % 2 == 0 ? ((box.getZSize() < 11 ? center.getZ() : box.minZ) + offset) : ((box.getZSize() < 11 ? center.getZ() : box.maxZ) - offset)); if (!world.isAirBlock(new BlockPos(x, y, z))) { if (explode) { float radius = 1.5F + (float)(difficulty * 0.5F); CustomExplosion.createExplosion(world, x, y, z, radius, BombType.BOMB_STANDARD); } world.playSoundEffect(x + 0.5D, center.getY(), z + 0.5D, Sounds.ROCK_FALL, 1.0F, 1.0F); StructureGenUtils.destroyBlocksAround(world, x - 1, x + 2, y, box.maxY - 2, z - 1, z + 2, null, false); } }
/** * Called from {@link #endCrisis} to attempt to generate an Ancient Tablet */ protected void generateAncientTablet(World world) { if (world.rand.nextFloat() < 1.0F) { // TODO Config.getAncientTabletGenChance() // Attempt to find a valid block position n times BlockPos pos = null; // TODO allow tablet to spawn up to several chunks away? for (int n = 0; n < 4 && pos == null; ++n) { pos = getRandomPlaceablePosition(world, ZSSBlocks.ancientTablet, box.minX + 1, box.maxY + 1, box.minZ + 1, box.getXSize() - 1, 1, box.getZSize() - 1); } if (pos != null) { BlockAncientTablet.EnumType type = BlockAncientTablet.EnumType.byMetadata(world.rand.nextInt(BlockAncientTablet.EnumType.values().length)); EnumFacing facing = (world.rand.nextInt(2) == 0 ? EnumFacing.SOUTH : EnumFacing.EAST); world.setBlockState(pos, ZSSBlocks.ancientTablet.getDefaultState().withProperty(BlockAncientTablet.VARIANT, type).withProperty(BlockAncientTablet.FACING, facing)); world.playSoundEffect(pos.getX(), pos.getY(), pos.getZ(), Sounds.ROCK_FALL, 1.0F, 1.0F); Vec3i center = box.getCenter(); EntityPlayer player = world.getClosestPlayer(center.getX(), center.getY(), center.getZ(), 16.0D); if (player != null) { new TimedChatDialogue(player, 1250, 1250, new ChatComponentTranslation("chat.zss.ancient_tablet.spawn")); } } } }
/** * Sets 2 air blocks where door used to be, after dungeon defeated * @param dy Amount to adjust y position above box.minY; usually either 1 or 2 */ private void placeOpenDoor(int dy) { if (doorSide == null) { doorSide = EnumFacing.EAST; } Vec3i center = box.getCenter(); int x = center.getX(); int z = center.getZ(); switch(doorSide) { case SOUTH: z = box.maxZ; break; case NORTH: z = box.minZ; break; case EAST: x = box.maxX; break; case WEST: x = box.minX; break; default: // UP and DOWN not possible } worldObj.setBlockToAir(new BlockPos(x, box.minY + dy, z)); worldObj.setBlockToAir(new BlockPos(x, box.minY + dy + 1, z)); }
/** * Returns average distance to ground based on 5 points in bounding box's lowest layer * @param max if any distance exceeds this threshold, this value will be returned */ public static int getAverageDistanceToGround(World world, StructureBoundingBox box, int max) { Vec3i center = box.getCenter(); int i = getDistanceToGround(world, center.getX(), box.minY, center.getZ()); int total = i; if (i > max) { return max; } i = getDistanceToGround(world, box.minX, box.minY, box.minZ); total += i; if (i > max) { return max; } i = getDistanceToGround(world, box.minX, box.minY, box.maxZ); total += i; if (i > max) { return max; } i = getDistanceToGround(world, box.maxX, box.minY, box.minZ); total += i; if (i > max) { return max; } i = getDistanceToGround(world, box.maxX, box.minY, box.maxZ); total += i; if (i > max) { return max; } return total / 5; }
/** * Encapsulates the search on a list. * * @param list * Target list * @param position * Desired coordinates * @param rangeLimit * Maximum distance accepted * @param ageTolerance * Maximum age of event accepted */ private static EventTracker seekValueOnList(List<EventTracker> list, Vec3i position, int rangeLimit, int ageTolerance) { final int thisTick = ServerInfoTracker.ThisTick(); for (final EventTracker et : list) { if (et.getTOB() > 0 && et.getTOB() + ageTolerance >= thisTick && position.distanceSq(et.getPosition()) <= rangeLimit) { if (ConfigurationHandler.onDebug) { LogHelper.info("ServerInfoTracker > found a valid target [" + et + "]"); } et.expireNow(); return et; } } return null; }
public StructureBoundingBox(Vec3i vec1, Vec3i vec2) { this.minX = Math.min(vec1.getX(), vec2.getX()); this.minY = Math.min(vec1.getY(), vec2.getY()); this.minZ = Math.min(vec1.getZ(), vec2.getZ()); this.maxX = Math.max(vec1.getX(), vec2.getX()); this.maxY = Math.max(vec1.getY(), vec2.getY()); this.maxZ = Math.max(vec1.getZ(), vec2.getZ()); }
/** * Offsets the position of pos in the direction of finger and thumb facing by offset amounts, follows the right-hand * rule for cross products (finger, thumb, palm) @return A new BlockPos offset in the facing directions */ protected static BlockPos translateOffset(BlockPos pos, EnumFacing finger, EnumFacing thumb, int palmOffset, int thumbOffset, int fingerOffset) { if (finger != thumb && finger != thumb.getOpposite()) { Vec3i vec3i = new Vec3i(finger.getFrontOffsetX(), finger.getFrontOffsetY(), finger.getFrontOffsetZ()); Vec3i vec3i1 = new Vec3i(thumb.getFrontOffsetX(), thumb.getFrontOffsetY(), thumb.getFrontOffsetZ()); Vec3i vec3i2 = vec3i.crossProduct(vec3i1); return pos.add(vec3i1.getX() * -thumbOffset + vec3i2.getX() * palmOffset + vec3i.getX() * fingerOffset, vec3i1.getY() * -thumbOffset + vec3i2.getY() * palmOffset + vec3i.getY() * fingerOffset, vec3i1.getZ() * -thumbOffset + vec3i2.getZ() * palmOffset + vec3i.getZ() * fingerOffset); } else { throw new IllegalArgumentException("Invalid forwards & up combination"); } }
public RegionRenderCache(World worldIn, BlockPos posFromIn, BlockPos posToIn, int subIn) { super(worldIn, posFromIn, posToIn, subIn); this.position = posFromIn.subtract(new Vec3i(subIn, subIn, subIn)); int i = 8000; this.combinedLights = new int[8000]; Arrays.fill((int[])this.combinedLights, (int) - 1); this.blockStates = new IBlockState[8000]; }
public static EnumFacing getFacingFromVertexData(int[] faceData) { Vector3f vector3f = new Vector3f(Float.intBitsToFloat(faceData[0]), Float.intBitsToFloat(faceData[1]), Float.intBitsToFloat(faceData[2])); Vector3f vector3f1 = new Vector3f(Float.intBitsToFloat(faceData[7]), Float.intBitsToFloat(faceData[8]), Float.intBitsToFloat(faceData[9])); Vector3f vector3f2 = new Vector3f(Float.intBitsToFloat(faceData[14]), Float.intBitsToFloat(faceData[15]), Float.intBitsToFloat(faceData[16])); Vector3f vector3f3 = new Vector3f(); Vector3f vector3f4 = new Vector3f(); Vector3f vector3f5 = new Vector3f(); Vector3f.sub(vector3f, vector3f1, vector3f3); Vector3f.sub(vector3f2, vector3f1, vector3f4); Vector3f.cross(vector3f4, vector3f3, vector3f5); float f = (float)Math.sqrt((double)(vector3f5.x * vector3f5.x + vector3f5.y * vector3f5.y + vector3f5.z * vector3f5.z)); vector3f5.x /= f; vector3f5.y /= f; vector3f5.z /= f; EnumFacing enumfacing = null; float f1 = 0.0F; for (EnumFacing enumfacing1 : EnumFacing.values()) { Vec3i vec3i = enumfacing1.getDirectionVec(); Vector3f vector3f6 = new Vector3f((float)vec3i.getX(), (float)vec3i.getY(), (float)vec3i.getZ()); float f2 = Vector3f.dot(vector3f5, vector3f6); if (f2 >= 0.0F && f2 > f1) { f1 = f2; enumfacing = enumfacing1; } } if (enumfacing == null) { return EnumFacing.UP; } else { return enumfacing; } }
public RegionRenderCache(World worldIn, BlockPos posFromIn, BlockPos posToIn, int subIn) { super(worldIn, posFromIn, posToIn, subIn); this.position = posFromIn.subtract(new Vec3i(subIn, subIn, subIn)); boolean flag = true; this.combinedLights = allocateLights(8000); Arrays.fill((int[])this.combinedLights, (int) - 1); this.blockStates = allocateStates(8000); }
/** * Attempt to parse the given object as a set of parameters for this handler. * * @param params the parameter block to parse * @return true if the object made sense for this handler; false otherwise. */ @Override public boolean parseParameters(Object params) { if (params == null || !(params instanceof BuildBattleDecorator)) return false; this.params = (BuildBattleDecorator) params; this.sourceBounds = this.params.getGoalStructureBounds(); this.destBounds = this.params.getPlayerStructureBounds(); this.delta = new Vec3i(destBounds.getMin().getX() - sourceBounds.getMin().getX(), destBounds.getMin().getY() - sourceBounds.getMin().getY(), destBounds.getMin().getZ() - sourceBounds.getMin().getZ()); this.structureVolume = volumeOfBounds(this.sourceBounds); assert(this.structureVolume == volumeOfBounds(this.destBounds)); this.dest = new ArrayList<IBlockState>(Collections.nCopies(this.structureVolume, (IBlockState)null)); this.source = new ArrayList<IBlockState>(Collections.nCopies(this.structureVolume, (IBlockState)null)); DrawBlockBasedObjectType tickBlock = this.params.getBlockTypeOnCorrectPlacement(); DrawBlockBasedObjectType crossBlock = this.params.getBlockTypeOnIncorrectPlacement(); this.blockTypeOnCorrectPlacement = (tickBlock != null) ? new XMLBlockState(tickBlock.getType(), tickBlock.getColour(), tickBlock.getFace(), tickBlock.getVariant()) : null; this.blockTypeOnIncorrectPlacement = (crossBlock != null) ? new XMLBlockState(crossBlock.getType(), crossBlock.getColour(), crossBlock.getFace(), crossBlock.getVariant()) : null; return true; }
@Override public void renderTileEntityAt(TileEntity t, double x, double y, double z, float f, int i) { TileEntity_IronFence tile = (TileEntity_IronFence) t; if (!tile.isInvalid()) { GL11.glPushMatrix(); GL11.glTranslated(x + 0.5, y, z + 0.5); bindTexture(texture); Block right = tile.getWorld().getBlockState(tile.getPos().add(new Vec3i(1,0,0))).getBlock(); Block left = tile.getWorld().getBlockState(tile.getPos().add(new Vec3i(-1,0,0))).getBlock(); Block front = tile.getWorld().getBlockState(tile.getPos().add(new Vec3i(0,0,1))).getBlock(); Block back = tile.getWorld().getBlockState(tile.getPos().add(new Vec3i(0,0,-1))).getBlock(); if(front instanceof Block_IronFence||!(front instanceof BlockAir)){ model.renderPart("front"); } if(back instanceof Block_IronFence||!(back instanceof BlockAir)){ model.renderPart("back"); } if(left instanceof Block_IronFence||!(left instanceof BlockAir)){ model.renderPart("left"); } if(right instanceof Block_IronFence||!(right instanceof BlockAir)){ model.renderPart("right"); } model.renderPart("post"); GL11.glPopMatrix(); } }
@Override public void renderTileEntityAt(TileEntity t, double x, double y, double z, float f, int i) { TileEntity_IronFence tile = (TileEntity_IronFence) t; if (!tile.isInvalid()) { GL11.glPushMatrix(); GL11.glTranslated(x + 0.5, y, z + 0.5); Block right = tile.getWorld().getBlockState(tile.getPos().add(new Vec3i(1,0,0))).getBlock(); Block left = tile.getWorld().getBlockState(tile.getPos().add(new Vec3i(-1,0,0))).getBlock(); Block front = tile.getWorld().getBlockState(tile.getPos().add(new Vec3i(0,0,1))).getBlock(); Block back = tile.getWorld().getBlockState(tile.getPos().add(new Vec3i(0,0,-1))).getBlock(); if(front instanceof Block_IronFence||!(front instanceof BlockAir)){ bindTexture(new ResourceLocation("reallifemod:textures/models/block/texture_Iron.png")); } if(back instanceof Block_IronFence||!(back instanceof BlockAir)){ model.renderPart("back"); } if(left instanceof Block_IronFence||!(left instanceof BlockAir)){ model.renderPart("left"); } if(right instanceof Block_IronFence||!(right instanceof BlockAir)){ model.renderPart("right"); } model.renderPart("post"); GL11.glPopMatrix(); } }
public TEParticleLauncher(EnumFacing blockFacing) { super(); Vec3i dir = blockFacing.getDirectionVec(); dirX = dir.getX(); dirY = dir.getY(); dirZ = dir.getZ(); }
@Override protected StructureBoundingBox getStructureBBAt(int x, int y, int z) { NBTTagList roomList = getStructureListFor(x >> 4, z >> 4); for (int i = 0; i < roomList.tagCount(); ++i) { NBTTagCompound compound = (NBTTagCompound) roomList.getCompoundTagAt(i); if (compound.hasKey("BB")) { StructureBoundingBox box = new StructureBoundingBox(compound.getIntArray("BB")); if (box.isVecInside(new Vec3i(x, y, z))) { return box; } } } return null; }
@Override public boolean generate(ZSSMapGenBase mapGen, World world, Random rand, int x, int y, int z) { if (y < bBox.maxY) { return false; } inNether = (world.provider.getDimensionName().equals("Nether")); bBox.offset(x, y - bBox.maxY, z); Vec3i center = bBox.getCenter(); int worldHeight = (inNether ? 128 : world.getHeight(new BlockPos(center.getX(), bBox.minY, center.getZ())).getY()); if (bBox.maxY > worldHeight) { bBox.offset(0, worldHeight - bBox.maxY - 1, 0); } if (!validateTopLayer(world) && !placeInOcean(world, true)) { return false; } else if (inNether && submerged && !placeInNether(world)) { return false; } StructureGenUtils.adjustForAir(world, this, bBox); checkSpecialCases(world, rand); setMetadata(world, new BlockPos(bBox.getCenter())); int range = (inOcean ? Config.getMinOceanDistance() : inNether ? Config.getNetherMinDistance() : Config.getMinLandDistance()); if (!mapGen.areStructuresWithinRange(this, range) && isWellHidden(world) && canGenerate(world)) { doStandardRoomGen(world, rand); return true; } else { return false; } }
/** * After a failed validation, attempts to place structure in ocean if applicable * @param sink if true, sinks the structure by some amount into the ocean floor * @return true if successful, in which case inOcean is set to true */ protected boolean placeInOcean(World world, boolean sink) { bBox.offset(0, 4, 0); // move back up a little Vec3i center = bBox.getCenter(); int x = center.getX(); int z = center.getZ(); boolean flag = world.getBiomeGenForCoords(new BlockPos(center)).biomeName.toLowerCase().contains("ocean"); if (flag && !inLava && world.getBlockState(new BlockPos(x, bBox.maxY, z)).getBlock().getMaterial() == Material.water) { int count = 0; while (bBox.minY > 16 && count < 8 && world.getBlockState(new BlockPos(x, bBox.minY, z)).getBlock().getMaterial() == Material.water) { bBox.offset(0, -1, 0); ++count; } if (world.getBlockState(new BlockPos(x, bBox.minY, z)).getBlock().getMaterial() != Material.water) { inOcean = true; StructureGenUtils.adjustCornersForMaterial(world, bBox, Material.water, 6, false, false); if (sink) { int diff = Config.getMainDungeonDifficulty(); int adj = 2 - diff; if (world.rand.nextFloat() > (diff * 0.25F)) { if (diff == 3) { ++adj; } else { adj += (world.rand.nextFloat() < 0.5F ? 1 : -1); } } bBox.offset(0, -(bBox.getYSize() - adj), 0); } return true; } } return false; }
/** * Adjusts nether dungeons to rest on solid ground when submerged in lava * @return true if final bottom block is not another secret dungeon block */ protected boolean placeInNether(World world) { Vec3i center = bBox.getCenter(); int x = center.getX(); int z = center.getZ(); while (bBox.minY > 8 && world.getBlockState(new BlockPos(x, bBox.minY, z)).getBlock().getMaterial() == Material.lava) { bBox.offset(0, -1, 0); } StructureGenUtils.adjustCornersForMaterial(world, bBox, Material.lava, 4, false, false); return (world.getBlockState(new BlockPos(x, bBox.minY, z)).getBlock() != ZSSBlocks.secretStone); }
/** * Determines which side is most suitable for the door */ protected void determineDoorSide(World world) { Vec3i center = bBox.getCenter(); int x = center.getX(); int y = bBox.minY + 1; int z = center.getZ(); int dx, dz; doorSide = EnumFacing.Plane.HORIZONTAL.random(world.rand); for (int i = 0; i < 4; ++i) { dx = x; dz = z; switch(doorSide) { case SOUTH: dz = bBox.maxZ + 1; break; case NORTH: dz = bBox.minZ - 1; break; case EAST: dx = bBox.maxX + 1; break; case WEST: dx = bBox.maxX - 1; break; default: ZSSMain.logger.warn(String.format("Invalid boss door side %d at %d/%d/%d", doorSide, x, y, z)); } Block block1 = world.getBlockState(new BlockPos(dx, y, dz)).getBlock(); Block block2 = world.getBlockState(new BlockPos(dx, y + 1, dz)).getBlock(); if (!block1.isFullBlock() && !block2.isFullBlock()) { return; // the blocks in front of the door are not full blocks, this is a good side for the door } doorSide = doorSide.rotateY(); } doorSide = null; }
/** * Places the center half-slabs and block for either a chest or a pedestal */ protected void placeCenterPiece(World world, Random rand, int meta) { int minX = bBox.getXSize() / 2 - 1; int minY = 1; int minZ = bBox.getZSize() / 2 - 1; if (submerged) { StructureGenUtils.fillWithBlocks(world, bBox, minX, minX + 3, minY, minY + 1, minZ, minZ + 3, BlockSecretStone.EnumType.byMetadata(meta).getDroppedBlock().getDefaultState()); ++minY; } if (!inOcean) { StructureGenUtils.fillWithBlocks(world, bBox, minX, minX + 3, minY, minY + 1, minZ, minZ + 3, BlockSecretStone.EnumType.byMetadata(meta).getSlab()); } Vec3i center = bBox.getCenter(); world.setBlockState(new BlockPos(center.getX(), bBox.minY + (submerged && !inOcean ? 2 : 1), center.getZ()), (type == BossType.TAIGA ? Blocks.quartz_block.getDefaultState() : BlockSecretStone.EnumType.byMetadata(meta).getDroppedBlock().getDefaultState()), 2); placeHinderBlock(world); boolean hasChest = false; switch(type) { case DESERT: // fall through case OCEAN: // fall through case MOUNTAIN: placeMainChest(world, rand, true); hasChest = true; break; case FOREST: if (rand.nextFloat() < Config.getMasterSwordChance()) { placePedestal(world, minY + 1); } else { // chance of double chest placeMainChest(world, rand, true); hasChest = !(rand.nextFloat() < (2 * Config.getDoubleChestChance())); } break; case HELL: placeFlame(world, BlockSacredFlame.EnumType.DIN); break; case SWAMP: placeFlame(world, BlockSacredFlame.EnumType.FARORE); break; case TAIGA: placeFlame(world, BlockSacredFlame.EnumType.NAYRU); break; default: } if (!hasChest) { placeMainChest(world, rand, false); } }
/** * Places the hanging chandelier only if height is sufficient */ protected void placeChandelier(World world) { if (bBox.getYSize() > 7) { Vec3i center = bBox.getCenter(); int x = center.getX(); int y = bBox.maxY - 1; int z = center.getZ(); switch(type) { case OCEAN: world.setBlockState(new BlockPos(x + 1, y, z + 1), Blocks.glowstone.getDefaultState(), 2); world.setBlockState(new BlockPos(x + 1, y, z - 1), Blocks.glowstone.getDefaultState(), 2); world.setBlockState(new BlockPos(x - 1, y, z + 1), Blocks.glowstone.getDefaultState(), 2); world.setBlockState(new BlockPos(x - 1, y, z - 1), Blocks.glowstone.getDefaultState(), 2); world.setBlockState(new BlockPos(x, y, z), Blocks.glowstone.getDefaultState(), 2); break; case SWAMP: world.setBlockState(new BlockPos(bBox.minX + 1, y, bBox.minZ + 1), Blocks.glowstone.getDefaultState(), 2); world.setBlockState(new BlockPos(bBox.minX + 1, y, bBox.maxZ - 1), Blocks.glowstone.getDefaultState(), 2); world.setBlockState(new BlockPos(bBox.maxX - 1, y, bBox.minZ + 1), Blocks.glowstone.getDefaultState(), 2); world.setBlockState(new BlockPos(bBox.maxX - 1, y, bBox.maxZ - 1), Blocks.glowstone.getDefaultState(), 2); break; default: world.setBlockState(new BlockPos(x, y, z), Blocks.oak_fence.getDefaultState(), 2); world.setBlockState(new BlockPos(x + 1, y, z), Blocks.oak_fence.getDefaultState(), 2); world.setBlockState(new BlockPos(x + 1, y, z), Blocks.oak_fence.getDefaultState(), 2); world.setBlockState(new BlockPos(x, y, z + 1), Blocks.oak_fence.getDefaultState(), 2); world.setBlockState(new BlockPos(x, y, z - 1), Blocks.oak_fence.getDefaultState(), 2); world.setBlockState(new BlockPos(x + 1, y, z + 1), Blocks.oak_fence.getDefaultState(), 2); world.setBlockState(new BlockPos(x + 1, y, z - 1), Blocks.oak_fence.getDefaultState(), 2); world.setBlockState(new BlockPos(x - 1, y, z + 1), Blocks.oak_fence.getDefaultState(), 2); world.setBlockState(new BlockPos(x - 1, y, z - 1), Blocks.oak_fence.getDefaultState(), 2); world.setBlockState(new BlockPos(x, y - 1, z), Blocks.oak_fence.getDefaultState(), 2); world.setBlockState(new BlockPos(x + 1, y - 1, z + 1), Blocks.glowstone.getDefaultState(), 2); world.setBlockState(new BlockPos(x + 1, y - 1, z - 1), Blocks.glowstone.getDefaultState(), 2); world.setBlockState(new BlockPos(x - 1, y - 1, z + 1), Blocks.glowstone.getDefaultState(), 2); world.setBlockState(new BlockPos(x - 1, y - 1, z - 1), Blocks.glowstone.getDefaultState(), 2); world.setBlockState(new BlockPos(x, y - 2, z), Blocks.glowstone.getDefaultState(), 2); } } }