/** * Registers the given block. * Also adds the respective TileEntity if the block has one. * * @param registerItemBlock - {@code true} to also register the block as item. */ private static void registerBlock(Block block, boolean registerItemBlock) {//TODO REGISTRY - Register block names with "oft." -prefix to avoid name clash between mods. /* Determine block's unlocalised name. */ String name = block.getClass().getSimpleName().toLowerCase().substring(5); /* Register block (and its TileEntity, if existent). */ if (block.getRegistryName() == null) { GameRegistry.register(block.setRegistryName(name).setUnlocalizedName(name)); if(block instanceof ITileEntityProvider){ Class<? extends TileEntity> tileEntityClass = ((ITileEntityProvider) block).createNewTileEntity(null, 0).getClass(); GameRegistry.registerTileEntity(tileEntityClass, tileEntityClass.getSimpleName()); } } /* Register block's item if required. */ if (registerItemBlock && Item.getItemFromBlock(block) == null) { GameRegistry.register(new ItemBlock(block).setRegistryName(name)); } }
public void addTileEntity(BlockPos pos, TileEntity tileEntityIn) { tileEntityIn.setWorldObj(this.worldObj); tileEntityIn.setPos(pos); if (this.getBlock(pos) instanceof ITileEntityProvider) { if (this.chunkTileEntityMap.containsKey(pos)) { ((TileEntity)this.chunkTileEntityMap.get(pos)).invalidate(); } tileEntityIn.validate(); this.chunkTileEntityMap.put(pos, tileEntityIn); } }
public void addTileEntity(BlockPos pos, TileEntity tileEntityIn) { tileEntityIn.setWorldObj(this.worldObj); tileEntityIn.setPos(pos); if (this.getBlockState(pos).getBlock() instanceof ITileEntityProvider) { if (this.chunkTileEntityMap.containsKey(pos)) { ((TileEntity)this.chunkTileEntityMap.get(pos)).invalidate(); } tileEntityIn.validate(); this.chunkTileEntityMap.put(pos, tileEntityIn); } }
public Map<BlockPos, TileEntity> getTileEntityMap(World world) { Map<BlockPos, TileEntity> map = new HashMap<>(); for(BlockPosition position : blocks) { Block block = position.getBlock(); if(block == null) { continue; } if(block instanceof ITileEntityProvider) { TileEntity tile = ((ITileEntityProvider) block).createNewTileEntity(world, position.worldMeta); NBTTagCompound tag = position.getTag(); if(tag == null) { tag = new NBTTagCompound(); } tag.setInteger("x", position.x); tag.setInteger("y", position.y); tag.setInteger("z", position.z); tile.readFromNBT(tag); map.put(position.getBlockPos(), tile); } } return map; }
public static StructureBuildPosition fromSchematicData(World world, BlockPos origin, int rotation, Schematic.BlockPosition schematicData) { BlockPos pos = SchematicRotationTransformer.getInstance().applyRotation(origin, schematicData.x, schematicData.y, schematicData.z, rotation); IBlockState state = schematicData.getBlockState(rotation); ItemStack resource = schematicData.getResourceStack(); boolean fuzzy = schematicData.fuzzy; NBTTagCompound tag = schematicData.getTag(); if(tag != null && (state.getBlock() instanceof ITileEntityProvider)) { tag.setInteger("x", pos.getX()); tag.setInteger("y", pos.getY()); tag.setInteger("z", pos.getZ()); TileEntity tile = ((ITileEntityProvider) state.getBlock()).createNewTileEntity(world, schematicData.worldMeta); SchematicRotationTransformer.getInstance().rotateTileTag(tile, tag, rotation); return new StructureBuildPositionTileEntity(world, pos, state, resource, fuzzy, tag); } else { return new StructureBuildPosition(world, pos, state, resource, fuzzy); } }
/** * A helper method for finding all {@link IAuraAbsorber} around a point * @param world The world of the point * @param x The x coord of the point * @param y The y coord of the point * @param z The z coord of the point * @param range The range * @return All the {@link IAuraAbsorber}s around the point */ public static List<AuraLocation<IAuraAbsorber>> findAllAbsorbersWithinRange(World world, int x, int y, int z, int range) { ArrayList<AuraLocation<IAuraAbsorber>> list = new ArrayList<AuraLocation<IAuraAbsorber>>(); for (int i = 0-range; i < range+1; i++) for (int j = 0-range; j < range+1; j++) for (int k = 0-range; k < range+1; k++) { if (world.blockExists(x+i, y+j, z+k)) if (!world.isAirBlock(x+i, y+j, z+k)) if (world.getBlock(x, y, z) instanceof IAuraAbsorber) { list.add(new AuraLocation<IAuraAbsorber>((IAuraAbsorber) world.getBlock(x, y, z), world, x, y, z)); } else if (world.getBlock(x, y, z) instanceof ITileEntityProvider) { if (world.getTileEntity(x, y, z) instanceof IAuraAbsorber) list.add(new AuraLocation<IAuraAbsorber>((IAuraAbsorber) world.getTileEntity(x, y, z), world, x, y, z)); } } return list; }
/** * A helper method for finding all {@link IAuraEmitter} around a point * @param world The world of the point * @param x The x coord of the point * @param y The y coord of the point * @param z The z coord of the point * @param range The range * @return All the {@link IAuraEmitter}s around the point */ public static List<AuraLocation<IAuraEmitter>> findAllEmittersWithinRange(World world, int x, int y, int z, int range) { ArrayList<AuraLocation<IAuraEmitter>> list = new ArrayList<AuraLocation<IAuraEmitter>>(); for (int i = 0-range; i < range+1; i++) for (int j = 0-range; j < range+1; j++) for (int k = 0-range; k < range+1; k++) { if (world.blockExists(x+i, y+j, z+k)) if (!world.isAirBlock(x+i, y+j, z+k)) if (world.getBlock(x, y, z) instanceof IAuraEmitter) { list.add(new AuraLocation<IAuraEmitter>((IAuraEmitter) world.getBlock(x, y, z), world, x, y, z)); } else if (world.getBlock(x, y, z) instanceof ITileEntityProvider) { if (world.getTileEntity(x, y, z) instanceof IAuraEmitter) list.add(new AuraLocation<IAuraEmitter>((IAuraEmitter) world.getTileEntity(x, y, z), world, x, y, z)); } } return list; }
/** * A helper method for finding all {@link IPassiveAuraEmitter} around a point * @param world The world of the point * @param x The x coord of the point * @param y The y coord of the point * @param z The z coord of the point * @param range The range * @return All the {@link IPassiveAuraEmitter}s around the point */ public static List<AuraLocation<IPassiveAuraEmitter>> findAllPassiveEmittersWithinRange(World world, int x, int y, int z, int range) { ArrayList<AuraLocation<IPassiveAuraEmitter>> list = new ArrayList<AuraLocation<IPassiveAuraEmitter>>(); for (int i = 0-range; i < range+1; i++) for (int j = 0-range; j < range+1; j++) for (int k = 0-range; k < range+1; k++) { if (world.blockExists(x+i, y+j, z+k)) if (!world.isAirBlock(x+i, y+j, z+k)) if (world.getBlock(x, y, z) instanceof IPassiveAuraEmitter) { list.add(new AuraLocation<IPassiveAuraEmitter>((IPassiveAuraEmitter) world.getBlock(x, y, z), world, x, y, z)); } else if (world.getBlock(x, y, z) instanceof ITileEntityProvider) { if (world.getTileEntity(x, y, z) instanceof IPassiveAuraEmitter) list.add(new AuraLocation<IPassiveAuraEmitter>((IPassiveAuraEmitter) world.getTileEntity(x, y, z), world, x, y, z)); } } return list; }
public void func_150812_a(int p_150812_1_, int p_150812_2_, int p_150812_3_, TileEntity p_150812_4_) { ChunkPosition var5 = new ChunkPosition(p_150812_1_, p_150812_2_, p_150812_3_); p_150812_4_.setWorldObj(this.worldObj); p_150812_4_.field_145851_c = this.xPosition * 16 + p_150812_1_; p_150812_4_.field_145848_d = p_150812_2_; p_150812_4_.field_145849_e = this.zPosition * 16 + p_150812_3_; if (this.func_150810_a(p_150812_1_, p_150812_2_, p_150812_3_) instanceof ITileEntityProvider) { if (this.chunkTileEntityMap.containsKey(var5)) { ((TileEntity)this.chunkTileEntityMap.get(var5)).invalidate(); } p_150812_4_.validate(); this.chunkTileEntityMap.put(var5, p_150812_4_); } }
@Override public void readMovementInfo(IMovingBlock block, NBTTagCompound tag) { block.setBlock(GameData.getBlockRegistry().getObject(tag.getString("block"))); block.setMetadata(tag.getInteger("metadata")); TileEntity te = block.getTileEntity(); if (tag.hasKey("data") && (te != null || block.getBlock() instanceof ITileEntityProvider)) { if (te == null) { te = ((ITileEntityProvider) block.getBlock()).createNewTileEntity(FakeWorld.getFakeWorld((MovingBlock) block), block.getMetadata()); System.out.println("creating!"); } if (te != null) { te.readFromNBT(tag.getCompoundTag("data")); block.setTileEntity(te); } } ((MovingBlock) block).setRenderList(-1); }
public EntityBlock(World world, int i, int j, int k) { this(world); setBlock(world.getBlock(i, j, k)); setMeta(world.getBlockMetadata(i, j, k)); TileEntity te = world.getTileEntity(i, j, k); if(te != null && block instanceof ITileEntityProvider) { world.setTileEntity(i, j, k, ((ITileEntityProvider)block).createNewTileEntity(world, getMeta())); tileEntityNBT = new NBTTagCompound(); te.writeToNBT(tileEntityNBT); te.invalidate(); } world.setBlockToAir(i, j, k); setLocationAndAngles(i + 0.5D, j + 0.5D - (double)yOffset, k + 0.5D, 0F, 0F); }
private static String catagorize(ItemStack i) { StringBuilder sb = new StringBuilder(); Item item = i.getItem(); sb.append(GameData.getItemRegistry().getNameForObject(item).getResourceDomain()); if(item instanceof ItemBlock){ if(((ItemBlock)item).getBlock() instanceof ITileEntityProvider){ sb.append("A"); } else { sb.append("B"); } } else { sb.append("I"); } sb.append(item.getUnlocalizedName()); sb.append(i.getMetadata()); return sb.toString(); }
/** * Checks if a connection is valid by looking at the two blocks and asking each if they will connect to the other. * @param connection The connection to check * @return True if the two blocks cen send power to (or through) eachother, false otherwise */ public static boolean areConnectable(PowerConnectorContext connection) { if(connection.thisBlock.getBlock() instanceof ITypedConduit){ if(connection.otherBlock.getBlock() instanceof ITypedConduit){ // both blocks are Power Advantage conductors return ((ITypedConduit)connection.thisBlock.getBlock()).canAcceptConnection(connection) && ((ITypedConduit)connection.otherBlock.getBlock()).canAcceptConnection(connection.reverse()); } else if(connection.otherBlock.getBlock() instanceof ITileEntityProvider){ if(PowerAdvantage.detectedRF && PowerAdvantage.rfConversionTable.containsKey(connection.powerType)) { // RF cross-mod compatibility return connection.world.getTileEntity(connection.otherBlockPosition) instanceof IEnergyReceiver; } if(PowerAdvantage.detectedTechReborn && PowerAdvantage.trConversionTable.containsKey(connection.powerType)) { // TR cross-mod compatibility return connection.world.getTileEntity(connection.otherBlockPosition) instanceof IEnergyInterfaceTile; } } } return false; }
@Override public void renderInventoryBlock(Block block, int metadata, int modelId, RenderBlocks renderer) { if (block instanceof ITileEntityProvider) { ITileEntityProvider prov = (ITileEntityProvider) block; te = prov.createNewTileEntity(null, metadata); te.blockMetadata = metadata; } else return; if (block instanceof IBlockRenderHook) { IBlockRenderHook hook = (IBlockRenderHook) block; hook.callbackInventory(te); } glRotatef(90F, 0F, 1F, 0F); glTranslatef(-0.5F, -0.5F, -0.5F); float scale = 1F; glScalef(scale, scale, scale); glAlphaFunc(GL_GREATER, 0.1F); TileEntityRendererDispatcher.instance.renderTileEntityAt(te, 0.0D, 0.0D, 0.0D, 0.0F); }
@Override public void renderInventoryBlock(Block block, int metadata, int modelId, RenderBlocks renderBlocks) { if (block instanceof ITileEntityProvider) { ITileEntityProvider prov = (ITileEntityProvider) block; te = prov.createNewTileEntity(null, metadata); te.blockMetadata = metadata; } else return; if (block instanceof IBlockRenderHook) { IBlockRenderHook hook = (IBlockRenderHook) block; hook.callbackInventory(te); } glRotatef(90F, 0F, 1F, 0F); glTranslatef(-0.5F, -0.5F, -0.5F); float scale = 1F; glScalef(scale, scale, scale); glAlphaFunc(GL_GREATER, 0.1F); TESRStaticHandler renderer = (TESRStaticHandler) TileEntityRendererDispatcher.instance.mapSpecialRenderers.get(te.getClass()); renderer.renderTile(te, 0.0, 0.0, 0.0, 0, true, renderBlocks); renderer.renderTile(te, 0.0, 0.0, 0.0, 0, false, renderBlocks); }
public boolean func_76589_b(int p_76589_1_, int p_76589_2_, int p_76589_3_, int p_76589_4_) { ExtendedBlockStorage var5 = this.field_76652_q[p_76589_2_ >> 4]; if(var5 == null) { return false; } else { int var6 = var5.func_76665_b(p_76589_1_, p_76589_2_ & 15, p_76589_3_); if(var6 == p_76589_4_) { return false; } else { this.field_76643_l = true; var5.func_76654_b(p_76589_1_, p_76589_2_ & 15, p_76589_3_, p_76589_4_); int var7 = var5.func_76656_a(p_76589_1_, p_76589_2_ & 15, p_76589_3_); if(var7 > 0 && Block.field_71973_m[var7] instanceof ITileEntityProvider) { TileEntity var8 = this.func_76597_e(p_76589_1_, p_76589_2_, p_76589_3_); if(var8 != null) { var8.func_70321_h(); var8.field_70325_p = p_76589_4_; } } return true; } } }
public TileEntity func_76597_e(int p_76597_1_, int p_76597_2_, int p_76597_3_) { ChunkPosition var4 = new ChunkPosition(p_76597_1_, p_76597_2_, p_76597_3_); TileEntity var5 = (TileEntity)this.field_76648_i.get(var4); if(var5 == null) { int var6 = this.func_76610_a(p_76597_1_, p_76597_2_, p_76597_3_); if(var6 <= 0 || !Block.field_71973_m[var6].func_71887_s()) { return null; } if(var5 == null) { var5 = ((ITileEntityProvider)Block.field_71973_m[var6]).func_72274_a(this.field_76637_e); this.field_76637_e.func_72837_a(this.field_76635_g * 16 + p_76597_1_, p_76597_2_, this.field_76647_h * 16 + p_76597_3_, var5); } var5 = (TileEntity)this.field_76648_i.get(var4); } if(var5 != null && var5.func_70320_p()) { this.field_76648_i.remove(var4); return null; } else { return var5; } }
public boolean isValidSourceDefault(@Nonnull ItemStack paintSource) { if (Prep.isInvalid(paintSource)) { return false; } Block block = PaintUtil.getBlockFromItem(paintSource); if (block == null) { return false; } if(isBlacklisted(paintSource)) { return false; } if(isWhitelisted(paintSource)) { return true; } if(!Config.allowTileEntitiesAsPaintSource && block instanceof ITileEntityProvider) { return false; } return true; }
@Nullable private TileEntity createNewTileEntity(BlockPos pos) { IBlockState iblockstate = this.getBlockState(pos); Block block = iblockstate.getBlock(); return !block.hasTileEntity() ? null : ((ITileEntityProvider)block).createNewTileEntity(this.worldObj, iblockstate.getBlock().getMetaFromState(iblockstate)); }
public void die(double X, double Y, double Z) { int x = MathHelper.floor_double(X); int y = MathHelper.floor_double(Y); int z = MathHelper.floor_double(Z); setDead(); worldObj.setBlock(x, y, z, block, metadata, 3); if (block instanceof BlockFalling) ((BlockFalling) block).func_149828_a(worldObj, x, y, z, metadata); if (tileEntityData != null && block instanceof ITileEntityProvider) { TileEntity tileentity = worldObj.getTileEntity(x, y, z); if (tileentity != null) { NBTTagCompound nbttagcompound = new NBTTagCompound(); tileentity.writeToNBT(nbttagcompound); Iterator iter = tileEntityData.func_150296_c().iterator(); while (iter.hasNext()) { String s = (String) iter.next(); NBTBase nbtbase = tileEntityData.getTag(s); if (!s.equals("x") && !s.equals("y") && !s.equals("z")) { nbttagcompound.setTag(s, nbtbase.copy()); } } tileentity.readFromNBT(nbttagcompound); tileentity.markDirty(); } } }
/** * Called throughout the code as a replacement for ITileEntityProvider.createNewTileEntity * Return the same thing you would from that function. * This will fall back to ITileEntityProvider.createNewTileEntity(World) if this block is a ITileEntityProvider * * @param metadata The Metadata of the current block * @return A instance of a class extending TileEntity */ public TileEntity createTileEntity(World world, int metadata) { if (isTileProvider) { return ((ITileEntityProvider)this).createNewTileEntity(world, metadata); } return new TileEntityBlockChristmasPresents_Red(); }
/** * Attempts to find an aura controller near the provided location * @param world The world for the controller * @param x The x coord to start the search from * @param y The y coord to start the search from * @param z The z coord to start the search from * @param range The range to search around * @return The aura controller */ public static IAuraController getControllerForLocation(World world, int x, int y, int z, int range) { List<TileEntity> controllers = new ArrayList<TileEntity>(); for (int i = 0-range; i < range+1; i++) for (int j = 0-range; j < range+1; j++) for (int k = 0-range; k < range+1; k++) { if (world.blockExists(x+i, y+j, z+k)) if (!world.isAirBlock(x+i, y+j, z+k)) if (world.getBlock(x+i, y+j, z+k) instanceof ITileEntityProvider) if (world.getTileEntity(x+i, y+j, z+k) instanceof IAuraController) controllers.add(world.getTileEntity(x+i, y+j, z+k)); } TileEntity closestController = null; for (TileEntity te : controllers) { if (closestController == null) closestController = te; else { Vec3 start = Vec3.createVectorHelper((double) x, (double) y, (double) z); Vec3 original = Vec3.createVectorHelper(closestController.xCoord, closestController.yCoord, closestController.zCoord); Vec3 next = Vec3.createVectorHelper(te.xCoord, te.yCoord, te.zCoord); if (start.distanceTo(original) > start.distanceTo(next)) closestController = te; // else if (start.distanceTo(original) == start.distanceTo(next)) TODO: account for this } } if (closestController != null) return (IAuraController) closestController; try { return (IAuraController) getCachedClass("com.austinv11.dartcraft2.api.implementations.PassiveAuraController").getConstructor(World.class, Integer.class, Integer.class, Integer.class).newInstance(world, x, y, z); } catch (Exception e) { e.printStackTrace(); } return null; // This should never be reached }
/** * Requests an aura burst from the nearest aura controller, if any. If none are found, aura is taken passively * @param world The world of the block requesting aura * @param x The x coord of the block * @param y The y coord of the block * @param z The z coord of the block * @param range The range to look for the aura controller * @throws FailedAPIRequest This is thrown if the block/tile entity requesting aura doesn't implement {@link IAuraAbsorber} */ public static void requestAura(World world, int x, int y, int z, int range) throws FailedAPIRequest { if (!world.blockExists(x, y, z) || world.isAirBlock(x, y, z)) throw new FailedAPIRequest("The block at "+world.provider.dimensionId+":"+x+","+y+","+z+" is non-existant!"); if (!(world.getBlock(x, y, z) instanceof IAuraAbsorber) && !(world.getBlock(x, y, z) instanceof ITileEntityProvider)) throw new FailedAPIRequest("The block at "+world.provider.dimensionId+":"+x+","+y+","+z+" does not implement IAuraAbsorber!"); else if (world.getBlock(x, y, z) instanceof ITileEntityProvider && !(world.getTileEntity(x, y, z) instanceof IAuraAbsorber)) throw new FailedAPIRequest("The block at "+world.provider.dimensionId+":"+x+","+y+","+z+" does not implement IAuraAbsorber!"); IAuraController controller = getControllerForLocation(world, x, y, z, range); controller.burst(); }
/** * Set the metadata of a block in the chunk */ public boolean setBlockMetadata(int par1, int par2, int par3, int par4) { ExtendedBlockStorage var5 = this.storageArrays[par2 >> 4]; if (var5 == null) { return false; } else { int var6 = var5.getExtBlockMetadata(par1, par2 & 15, par3); if (var6 == par4) { return false; } else { this.isModified = true; var5.setExtBlockMetadata(par1, par2 & 15, par3, par4); if (var5.func_150819_a(par1, par2 & 15, par3) instanceof ITileEntityProvider) { TileEntity var7 = this.func_150806_e(par1, par2, par3); if (var7 != null) { var7.updateContainingBlockInfo(); var7.blockMetadata = par4; } } return true; } } }
public TileEntity func_150806_e(int p_150806_1_, int p_150806_2_, int p_150806_3_) { ChunkPosition var4 = new ChunkPosition(p_150806_1_, p_150806_2_, p_150806_3_); TileEntity var5 = (TileEntity)this.chunkTileEntityMap.get(var4); if (var5 == null) { Block var6 = this.func_150810_a(p_150806_1_, p_150806_2_, p_150806_3_); if (!var6.hasTileEntity()) { return null; } var5 = ((ITileEntityProvider)var6).createNewTileEntity(this.worldObj, this.getBlockMetadata(p_150806_1_, p_150806_2_, p_150806_3_)); this.worldObj.setTileEntity(this.xPosition * 16 + p_150806_1_, p_150806_2_, this.zPosition * 16 + p_150806_3_, var5); } if (var5 != null && var5.isInvalid()) { this.chunkTileEntityMap.remove(var4); return null; } else { return var5; } }
@Override public TileEntity createNewTileEntity(World world, int metadata) { if (ReplaceBlock.get(this, metadata).getBlock() instanceof ITileEntityProvider) { return ((ITileEntityProvider) ReplaceBlock.get(this, metadata).getBlock()).createNewTileEntity(world, ReplaceBlock.get(this, metadata).getMetadata(metadata)); } return null; }
public static void init() { binaryComputer = new BlockComputer(); // Done initializing for (Block block : blocks) { GameRegistry.registerBlock(block, block.getUnlocalizedName().substring(5)); if (block.hasTileEntity(0)) { GameRegistry.registerTileEntity(((ITileEntityProvider)block).createNewTileEntity(null,0).getClass(), block.getUnlocalizedName().substring(5) + "TE"); } } }
@Command( name = "itemClass", permission = "mytown.adm.cmd.debug.item", parentName = "mytown.adm.cmd.debug", syntax = "/townadmin debug itemClass", console = false) public static CommandResponse debugItemCommand(ICommandSender sender, List<String> args) { if(sender instanceof EntityPlayer) { EntityPlayer player = (EntityPlayer)sender; List<Class> list = new ArrayList<Class>(); if(player.inventory.getCurrentItem() != null) { if(player.inventory.getCurrentItem().getItem() instanceof ItemBlock) { Block block = ((ItemBlock)player.inventory.getCurrentItem().getItem()).field_150939_a; list.add(block.getClass()); if(block instanceof ITileEntityProvider) { TileEntity te = ((ITileEntityProvider) block).createNewTileEntity(MinecraftServer.getServer().worldServerForDimension(0), 0); list.add(te == null ? TileEntity.class : te.getClass()); } } else { list.add(player.inventory.getCurrentItem().getItem().getClass()); } ChatManager.send(sender, new ChatComponentText("For item: " + player.inventory.getCurrentItem().getDisplayName())); for(Class cls : list) { while (cls != Object.class) { ChatManager.send(sender, new ChatComponentText(cls.getName())); cls = cls.getSuperclass(); } } } } return CommandResponse.DONE; }
public void onAnyBlockPlacement(EntityPlayer player, BlockEvent.PlaceEvent ev) { if(ev.world.isRemote || ev.isCanceled()) { return; } if(player instanceof FakePlayer) { if(!ProtectionManager.getFlagValueAtLocation(FlagType.FAKERS, ev.world.provider.dimensionId, ev.x, ev.y, ev.z)) { ev.setCanceled(true); } } else { Resident res = MyTownUniverse.instance.getOrMakeResident(player); if (!MyTownUniverse.instance.blocks.contains(ev.world.provider.dimensionId, ev.x >> 4, ev.z >> 4)) { int range = Config.instance.placeProtectionRange.get(); Volume placeBox = new Volume(ev.x-range, ev.y-range, ev.z-range, ev.x+range, ev.y+range, ev.z+range); if(!ProtectionManager.hasPermission(res, FlagType.MODIFY, ev.world.provider.dimensionId, placeBox)) { ev.setCanceled(true); return; } } else { if(!ProtectionManager.hasPermission(res, FlagType.MODIFY, ev.world.provider.dimensionId, ev.x, ev.y, ev.z)) { ev.setCanceled(true); return; } } if(ev.block instanceof ITileEntityProvider && ev.itemInHand != null) { TileEntity te = ((ITileEntityProvider) ev.block).createNewTileEntity(MinecraftServer.getServer().worldServerForDimension(ev.world.provider.dimensionId), ev.itemInHand.getItemDamage()); if (te != null && ProtectionManager.isOwnable(te.getClass())) { ThreadPlacementCheck thread = new ThreadPlacementCheck(res, ev.x, ev.y, ev.z, ev.world.provider.dimensionId); activePlacementThreads++; thread.start(); } } } }
public void changeBlock(Block block, int meta) { blockChangedLastTick = true; if (block instanceof ITileEntityProvider && worldObj.getBlockMetadata(xCoord, yCoord, zCoord) == 0) worldObj.setBlockToAir(xCoord, yCoord + 1, zCoord); else worldObj.setBlock(xCoord, yCoord + 1, zCoord, block, meta, 3); }
@Override public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderBlocks) { if (block instanceof ITileEntityProvider) { te = world.getTileEntity(x, y, z); } else return false; Tessellator.instance.draw(); TESRStaticHandler renderer = (TESRStaticHandler) TileEntityRendererDispatcher.instance.mapSpecialRenderers.get(te.getClass()); renderer.renderTile(te, x, y, z, 0, true, renderBlocks); Tessellator.instance.startDrawingQuads(); return true; }
public static void moveBlock(World w, int xD, int yD, int zD, int xS, int yS, int zS, boolean scheduleUpdate, boolean clearSource) { isCurrentlyMovingABlock = true; Chunk cD = ChunkCache.getChunk(w, xD >> 4, zD >> 4, true); Chunk cS = ChunkCache.getChunk(w, xS >> 4, zS >> 4, true); // System.out.println("Moving block from: "+Util.xyzString(xS,yS,zS)+" to "+Util.xyzString(xD,yD,zD)); int idS = cS.getBlockID(xS & 15, yS, zS & 15); int metaS = cS.getBlockMetadata(xS & 15, yS, zS & 15); int idD = cD.getBlockID(xD & 15, yD, zD & 15); int metaD = cD.getBlockMetadata(xD & 15, yS, zD & 15); Block blockS = Block.blocksList[idS]; synchronized (FysiksFun.vanillaMutex) { cD.setBlockIDWithMetadata(xD & 15, yD, zD & 15, idS, metaS); } if (scheduleUpdate) ChunkMarkUpdater.scheduleBlockMark(w, xD, yD, zD, idD, metaD); if (blockS instanceof ITileEntityProvider) { TileEntity entity = cS.getChunkBlockTileEntity(xS & 15, yS, zS & 15); cS.removeChunkBlockTileEntity(xS & 15, yS, zS & 15); entity.xCoord = xD; entity.yCoord = yD; entity.zCoord = zD; entity.validate(); cD.addTileEntity(entity); } if (clearSource) { cS.setBlockIDWithMetadata(xS & 15, yS, zS & 15, 0, 0); if (scheduleUpdate) ChunkMarkUpdater.scheduleBlockMark(w, xS, yS, zS, idD, metaD); } isCurrentlyMovingABlock = false; }
public void func_76604_a(int p_76604_1_, int p_76604_2_, int p_76604_3_, TileEntity p_76604_4_) { ChunkPosition var5 = new ChunkPosition(p_76604_1_, p_76604_2_, p_76604_3_); p_76604_4_.func_70308_a(this.field_76637_e); p_76604_4_.field_70329_l = this.field_76635_g * 16 + p_76604_1_; p_76604_4_.field_70330_m = p_76604_2_; p_76604_4_.field_70327_n = this.field_76647_h * 16 + p_76604_3_; if(this.func_76610_a(p_76604_1_, p_76604_2_, p_76604_3_) != 0 && Block.field_71973_m[this.func_76610_a(p_76604_1_, p_76604_2_, p_76604_3_)] instanceof ITileEntityProvider) { if(this.field_76648_i.containsKey(var5)) { ((TileEntity)this.field_76648_i.get(var5)).func_70313_j(); } p_76604_4_.func_70312_q(); this.field_76648_i.put(var5, p_76604_4_); } }
private static boolean func_72111_a(int p_72111_0_, World p_72111_1_, int p_72111_2_, int p_72111_3_, int p_72111_4_, boolean p_72111_5_) { if(p_72111_0_ == Block.field_72089_ap.field_71990_ca) { return false; } else { if(p_72111_0_ != Block.field_71963_Z.field_71990_ca && p_72111_0_ != Block.field_71956_V.field_71990_ca) { if(Block.field_71973_m[p_72111_0_].func_71934_m(p_72111_1_, p_72111_2_, p_72111_3_, p_72111_4_) == -1.0F) { return false; } if(Block.field_71973_m[p_72111_0_].func_71915_e() == 2) { return false; } if(Block.field_71973_m[p_72111_0_].func_71915_e() == 1) { if(!p_72111_5_) { return false; } return true; } } else if(func_72114_f(p_72111_1_.func_72805_g(p_72111_2_, p_72111_3_, p_72111_4_))) { return false; } return !(Block.field_71973_m[p_72111_0_] instanceof ITileEntityProvider); } }
public static boolean canBeSlippery(Block block) { if ((block instanceof BlockSlippery || block instanceof BlockSlipperyStairs) && block.slipperiness < 1.1F) { return true; } if (block.getRenderType() == 0 || block.getRenderType() == 31 || block.getRenderType() == 10 || block.getRenderType() == 39) { return !(block instanceof ITileEntityProvider) && !(block instanceof BlockSlab); } return false; }
@Override public boolean placeBlockAt(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ, int metadata) { if(super.placeBlockAt(stack, player, world, x, y, z, side, hitX, hitY, hitZ, metadata)) { if(stack.getTagCompound() != null && stack.getTagCompound().hasKey("eid")) { TileEntityEnder ender = (TileEntityEnder)(((ITileEntityProvider)Block.blocksList[this.getBlockID()]).createNewTileEntity(world)); ender.xCoord = x; ender.yCoord = y; ender.zCoord = z; ender.worldObj = world; ender.initWithEnderID(stack.getTagCompound().getInteger("eid")); world.setBlockTileEntity(x, y, z, ender); } return true; } else return false; }
private TileEntity createNewTileEntity(BlockPos pos) { Block block = this.getBlock(pos); return !block.hasTileEntity() ? null : ((ITileEntityProvider)block).createNewTileEntity(this.worldObj, this.getBlockMetadata(pos)); }