@Override public void renderTick(EntityPlayerCustom playerCustom) { if (playerCustom.isRolling || (Util.isCube( Minecraft.getMinecraft() .theWorld .getBlock( MathHelper.floor_double(Minecraft.getMinecraft().thePlayer.posX), MathHelper.floor_double(Minecraft.getMinecraft().thePlayer.posY), MathHelper.floor_double(Minecraft.getMinecraft().thePlayer.posZ))) && playerCustom.wasRolling)) { int x1 = MathHelper.floor_double(Minecraft.getMinecraft().thePlayer.posX); int y1 = MathHelper.floor_double(Minecraft.getMinecraft().thePlayer.posY); int z1 = MathHelper.floor_double(Minecraft.getMinecraft().thePlayer.posZ); ExtendedBlockStorage ebs = ((ExtendedBlockStorage[]) ObfuscationReflectionHelper.getPrivateValue( Chunk.class, Minecraft.getMinecraft().thePlayer.worldObj.getChunkFromBlockCoords(x1, z1), 2)) [y1 >> 4]; if (ebs.getExtSkylightValue((x1 & 15), y1 & 15, (z1 & 15)) == 0) { ebs.setExtSkylightValue((x1 & 15), y1 & 15, (z1 & 15), playerCustom.lastLightValue); } playerCustom.lastLightValue = (byte) ebs.getExtSkylightValue((x1 & 15), y1 & 15, (z1 & 15)); KeyBinding.setKeyBindState( Minecraft.getMinecraft().gameSettings.keyBindSneak.getKeyCode(), true); if (renderer == null) { renderer = new EntityRendererCustom(Minecraft.getMinecraft()); } if (Minecraft.getMinecraft().entityRenderer != renderer) { // be sure to store the previous renderer prevRenderer = Minecraft.getMinecraft().entityRenderer; Minecraft.getMinecraft().entityRenderer = renderer; } } else if (prevRenderer != null && Minecraft.getMinecraft().entityRenderer != prevRenderer && playerCustom.wasRolling) { // reset the renderer KeyBinding.setKeyBindState( Minecraft.getMinecraft().gameSettings.keyBindSneak.getKeyCode(), false); Minecraft.getMinecraft().entityRenderer = prevRenderer; playerCustom.wasRolling = false; } if (!playerCustom.wasRolling) { playerCustom.wasRolling = playerCustom.isRolling; } }
public static S21PacketChunkData.Extracted func_179756_a( Chunk p_179756_0_, boolean p_179756_1_, boolean p_179756_2_, int p_179756_3_) { ExtendedBlockStorage[] aextendedblockstorage = p_179756_0_.getBlockStorageArray(); S21PacketChunkData.Extracted s21packetchunkdata$extracted = new S21PacketChunkData.Extracted(); List<ExtendedBlockStorage> list = Lists.<ExtendedBlockStorage>newArrayList(); for (int i = 0; i < aextendedblockstorage.length; ++i) { ExtendedBlockStorage extendedblockstorage = aextendedblockstorage[i]; if (extendedblockstorage != null && (!p_179756_1_ || !extendedblockstorage.isEmpty()) && (p_179756_3_ & 1 << i) != 0) { s21packetchunkdata$extracted.dataSize |= 1 << i; list.add(extendedblockstorage); } } s21packetchunkdata$extracted.data = new byte [func_180737_a( Integer.bitCount(s21packetchunkdata$extracted.dataSize), p_179756_2_, p_179756_1_)]; int j = 0; for (ExtendedBlockStorage extendedblockstorage1 : list) { char[] achar = extendedblockstorage1.getData(); for (char c0 : achar) { s21packetchunkdata$extracted.data[j++] = (byte) (c0 & 255); s21packetchunkdata$extracted.data[j++] = (byte) (c0 >> 8 & 255); } } for (ExtendedBlockStorage extendedblockstorage2 : list) { j = func_179757_a( extendedblockstorage2.getBlocklightArray().getData(), s21packetchunkdata$extracted.data, j); } if (p_179756_2_) { for (ExtendedBlockStorage extendedblockstorage3 : list) { j = func_179757_a( extendedblockstorage3.getSkylightArray().getData(), s21packetchunkdata$extracted.data, j); } } if (p_179756_1_) { func_179757_a(p_179756_0_.getBiomeArray(), s21packetchunkdata$extracted.data, j); } return s21packetchunkdata$extracted; }
public Chunk getOrCreateChunk(int x, int z) { random.setSeed((long) x * 341873128712L + (long) z * 132897987541L); Chunk chunk; // Get default biome data for chunk CustomBiomeGrid biomegrid = new CustomBiomeGrid(); biomegrid.biome = new BiomeGenBase[256]; world.getWorldChunkManager().getBiomeGenAt(biomegrid.biome, x << 4, z << 4, 16, 16, false); // Try extended block method (1.2+) short[][] xbtypes = generator.generateExtBlockSections( CraftServer.instance().getWorld(world.provider.dimensionId), this.random, x, z, biomegrid); if (xbtypes != null) { chunk = new Chunk(this.world, x, z); ExtendedBlockStorage[] csect = chunk.getBlockStorageArray(); int scnt = Math.min(csect.length, xbtypes.length); // Loop through returned sections for (int sec = 0; sec < scnt; sec++) { if (xbtypes[sec] == null) { continue; } byte[] secBlkID = new byte[4096]; // Allocate blk ID bytes byte[] secExtBlkID = (byte[]) null; // Delay getting extended ID nibbles short[] bdata = xbtypes[sec]; // Loop through data, 2 blocks at a time for (int i = 0, j = 0; i < bdata.length; i += 2, j++) { short b1 = bdata[i]; short b2 = bdata[i + 1]; byte extb = (byte) ((b1 >> 8) | ((b2 >> 4) & 0xF0)); secBlkID[i] = (byte) b1; secBlkID[(i + 1)] = (byte) b2; if (extb != 0) { // If extended block ID data if (secExtBlkID == null) { // Allocate if needed secExtBlkID = new byte[2048]; } secExtBlkID[j] = extb; } } // Build chunk section csect[sec] = new ExtendedBlockStorage(sec << 4, false); // , secBlkID, secExtBlkID); } } else { // Else check for byte-per-block section data byte[][] btypes = generator.generateBlockSections(getWorld(world), this.random, x, z, biomegrid); if (btypes != null) { chunk = new Chunk(this.world, x, z); ExtendedBlockStorage[] csect = chunk.getBlockStorageArray(); int scnt = Math.min(csect.length, btypes.length); for (int sec = 0; sec < scnt; sec++) { if (btypes[sec] == null) { continue; } csect[sec] = new ExtendedBlockStorage(sec << 4, false); // , btypes[sec], null); } } else { // Else, fall back to pre 1.2 method @SuppressWarnings("deprecation") byte[] types = generator.generate(getWorld(world), this.random, x, z); int ydim = types.length / 256; int scnt = ydim / 16; chunk = new Chunk(this.world, x, z); // Create empty chunk ExtendedBlockStorage[] csect = chunk.getBlockStorageArray(); scnt = Math.min(scnt, csect.length); // Loop through sections for (int sec = 0; sec < scnt; sec++) { ExtendedBlockStorage cs = null; // Add sections when needed byte[] csbytes = (byte[]) null; for (int cy = 0; cy < 16; cy++) { int cyoff = cy | (sec << 4); for (int cx = 0; cx < 16; cx++) { int cxyoff = (cx * ydim * 16) + cyoff; for (int cz = 0; cz < 16; cz++) { byte blk = types[cxyoff + (cz * ydim)]; if (blk != 0) { // If non-empty if (cs == null) { // If no section yet, get one cs = csect[sec] = new ExtendedBlockStorage(sec << 4, true); csbytes = cs.getBlockLSBArray(); } csbytes[(cy << 8) | (cz << 4) | cx] = blk; } } } } // If section built, finish prepping its state if (cs != null) { cs.getYLocation(); } } } } // Set biome grid byte[] biomeIndex = chunk.getBiomeArray(); for (int i = 0; i < biomeIndex.length; i++) { biomeIndex[i] = (byte) (biomegrid.biome[i].biomeID & 0xFF); } // Initialize lighting chunk.generateSkylightMap(); return chunk; }
public boolean myChunkSBIDWMT(Chunk c, int x, int y, int z, int blockId, int blockMeta) { int j1 = z << 4 | x; if (y >= c.precipitationHeightMap[j1] - 1) { c.precipitationHeightMap[j1] = -999; } // int k1 = c.heightMap[j1]; int l1 = c.getBlockID(x, y, z); int i2 = c.getBlockMetadata(x, y, z); if (l1 == blockId && i2 == blockMeta) { return false; } else { ExtendedBlockStorage[] storageArrays = c.getBlockStorageArray(); ExtendedBlockStorage extendedblockstorage = storageArrays[y >> 4]; if (extendedblockstorage == null) { if (blockId == 0) { return false; } extendedblockstorage = storageArrays[y >> 4] = new ExtendedBlockStorage(y >> 4 << 4, !c.worldObj.provider.hasNoSky); } int j2 = c.xPosition * 16 + x; int k2 = c.zPosition * 16 + z; extendedblockstorage.setExtBlockID(x, y & 15, z, blockId); if (l1 != 0) { if (!c.worldObj.isRemote) { Block.blocksList[l1].breakBlock(c.worldObj, j2, y, k2, l1, i2); } else if (Block.blocksList[l1] != null && Block.blocksList[l1].hasTileEntity(i2)) { TileEntity te = worldObj.getBlockTileEntity(j2, y, k2); if (te != null && te.shouldRefresh(l1, blockId, i2, blockMeta, worldObj, j2, y, k2)) { c.worldObj.removeBlockTileEntity(j2, y, k2); } } } if (extendedblockstorage.getExtBlockID(x, y & 15, z) != blockId) { return false; } else { extendedblockstorage.setExtBlockMetadata(x, y & 15, z, blockMeta); // Removed light recalculations /*if (flag) { c.generateSkylightMap(); } else { if (c.getBlockLightOpacity(par1, par2, par3) > 0) { if (par2 >= k1) { c.relightBlock(par1, par2 + 1, par3); } } else if (par2 == k1 - 1) { c.relightBlock(par1, par2, par3); } c.propagateSkylightOcclusion(par1, par3); }*/ TileEntity tileentity; if (blockId != 0) { if (Block.blocksList[blockId] != null && Block.blocksList[blockId].hasTileEntity(blockMeta)) { tileentity = c.getChunkBlockTileEntity(x, y, z); if (tileentity == null) { tileentity = Block.blocksList[blockId].createTileEntity(c.worldObj, blockMeta); c.worldObj.setBlockTileEntity(j2, y, k2, tileentity); } if (tileentity != null) { tileentity.updateContainingBlockInfo(); tileentity.blockMetadata = blockMeta; } } } c.isModified = true; return true; } } }