@Override public void refresh() { int tierfound = 2; Iterator<IConductor> it = this.conductors.iterator(); while (it.hasNext()) { IConductor conductor = it.next(); if (conductor == null) { it.remove(); continue; } TileEntity tile = (TileEntity) conductor; World world = tile.getWorldObj(); // Remove any conductors in unloaded chunks if (tile.isInvalid() || world == null) { it.remove(); continue; } if (conductor.getTierGC() < 2) { tierfound = 1; } if (conductor.getNetwork() != this) { conductor.setNetwork(this); conductor.onNetworkChanged(); } } // This will set the network tier to 2 if all the conductors are tier 2 this.networkTierGC = tierfound; }
private void runThroughNetwork(BlockPos pos) { for (EnumFacing facing : EnumFacing.values()) { BlockPos searchPos = pos.offset(facing); if (worldObj.getTileEntity(pos) instanceof INetworkPart && !((INetworkPart) worldObj.getTileEntity(pos)).getNeighborFaces().contains(facing)) continue; if (worldObj.getTileEntity(searchPos) instanceof INetworkPart && !((INetworkPart) worldObj.getTileEntity(searchPos)) .getNeighborFaces() .contains(facing.getOpposite())) continue; if (!getWorld().isAirBlock(searchPos)) { TileEntity tile = getWorld().getTileEntity(searchPos); if (tile != null) { if (tile instanceof TileNetworkCore && !tile.getPos().equals(this.pos)) { worldObj.setBlockToAir(searchPos); worldObj.playEvent(2001, searchPos, Block.getIdFromBlock(Registry.networkCore)); StackHelper.spawnItemStack(worldObj, searchPos, new ItemStack(Registry.networkCore)); markForNetworkInit(); } else if (tile instanceof INetworkPart && !network.networkParts.contains(tile)) { network.addPart((INetworkPart) tile); } else if (InvHelper.hasItemHandler(tile, facing.getOpposite()) && !network.networkParts.contains( InvHelper.getItemHandler(tile, facing.getOpposite()))) { network.addPart( new InventoryNetworkPart( tile.getWorld(), searchPos, InvHelper.getItemHandler(tile, facing.getOpposite()))); } else continue; runThroughNetwork(searchPos); } } } }
public static boolean moveBlock( World world, Coord src, Coord tgt, boolean allowBlockReplacement) { if (!world.isRemote && !src.isAirBlock(world) && (tgt.isAirBlock(world) || allowBlockReplacement)) { int blockID = src.getBlockID(world); int metadata = src.getBlockMetadata(world); world.setBlock(tgt.x, tgt.y, tgt.z, blockID, metadata, BlockNotifyFlags.ALL); if (world.blockHasTileEntity(src.x, src.y, src.z)) { TileEntity te = world.getBlockTileEntity(src.x, src.y, src.z); if (te != null) { NBTTagCompound nbt = new NBTTagCompound(); te.writeToNBT(nbt); nbt.setInteger("x", tgt.x); nbt.setInteger("y", tgt.y); nbt.setInteger("z", tgt.z); te = world.getBlockTileEntity(tgt.x, tgt.y, tgt.z); if (te != null) te.readFromNBT(nbt); } } world.setBlockToAir(src.x, src.y, src.z); return true; } return false; }
/* === INFO === */ private void onDebugInfo(NBTTagCompound nbt, EntityPlayer player, Pos pos) { if (pos != null) { player.addChatMessage( new ChatComponentText( EnumChatFormatting.GOLD + "Block Type: " + EnumChatFormatting.RESET + GameData.getBlockRegistry().getNameForObject(pos.getBlock(player.worldObj)))); player.addChatMessage( new ChatComponentText( EnumChatFormatting.GOLD + "Metadata: " + EnumChatFormatting.RESET + pos.getMetadata(player.worldObj))); TileEntity tile = pos.getTileEntity(player.worldObj); if (tile instanceof TileEntitySkull) { NBTTagCompound tag = new NBTTagCompound(); tile.writeToNBT(tag); player.addChatMessage( new ChatComponentText( EnumChatFormatting.GOLD + "Skull Rotation: " + EnumChatFormatting.RESET + tag.getByte("Rot"))); } } }
@Override public boolean onBlockEventReceived( World worldIn, BlockPos pos, IBlockState state, int eventID, int eventParam) { super.onBlockEventReceived(worldIn, pos, state, eventID, eventParam); TileEntity tileentity = worldIn.getTileEntity(pos); return tileentity == null ? false : tileentity.receiveClientEvent(eventID, eventParam); }
@Override public void renderTileEntityAt(TileEntity t, double x, double y, double z, float partialTicks) { tile = (TileEntityHologramProjector) t; // tile.arraySize.updateValue(tile.holoObjects); OpenGLM.pushMatrix(); OpenGLM.translate(x, y, z); GL11U.texture(false); GL11U.glLighting(true); TessUtil.drawCube( t.getBlockType().getBlockBoundsMinX(), t.getBlockType().getBlockBoundsMinY(), t.getBlockType().getBlockBoundsMinZ(), t.getBlockType().getBlockBoundsMaxX(), t.getBlockType().getBlockBoundsMaxY(), t.getBlockType().getBlockBoundsMaxZ()); GL11U.setUpOpaqueRendering(1); GL11U.glScale(0.99999); ColorF color = new ColorF( UtilM.fluctuateSmooth(10, 0) * 0.2 + tile.mainColor.x, UtilM.fluctuateSmooth(35, 0) * 0.2 + tile.mainColor.y, UtilM.fluctuateSmooth(16, 0) * 0.2 + tile.mainColor.z, 0.2); color.bind(); OpenGLM.translate(tile.offset.x, tile.offset.y - UtilM.p * 1.45F, 0.5F); tile.main.draw(); OpenGLM.translate(tile.size.x, tile.size.y, 0); boolean selected = false; tile.selectedObj = null; Iterator<HoloObject> holos = tile.holoObjects.iterator(); while (holos.hasNext()) { HoloObject ro = holos.next(); if (ro.host == null) ro.host = tile; OpenGLM.pushMatrix(); OpenGLM.translate(ro.position.x, ro.position.y, 0); ro.render(color); OpenGLM.popMatrix(); if (((ro.getClass() == TextBox.class && tile.highlights[0]) || (ro.getClass() == Button.class && tile.highlights[1]) || (ro.getClass() == Slider.class && tile.highlights[3]) || (ro.getClass() == Field.class && tile.highlights[2])) && !selected && (ro.isHighlighted || ro.moveMode)) { selected = true; OpenGLM.color(0, 0, 0, 0.4F); OpenGLM.lineWidth(1); GL11U.texture(false); ro.drawHighlight(); GL11U.texture(true); } } GL11U.glColor(ColorF.WHITE); GL11U.glCulFace(true); GL11U.texture(true); GL11U.endOpaqueRendering(); OpenGLM.popMatrix(); // tile.arraySize.updateValue(tile.holoObjects); }
public static EntityBlock create( EntityPlayer player, World world, int x, int y, int z, Class<? extends EntityBlock> klazz) { Block block = world.getBlock(x, y, z); if (block.isAir(world, x, y, z)) return null; int meta = world.getBlockMetadata(x, y, z); final EntityBlock entity; try { entity = klazz.getConstructor(World.class).newInstance(world); } catch (Throwable t) { Log.warn(t, "Failed to create EntityBlock(%s) at %d,%d,%d", klazz, x, y, z); return null; } entity.setBlockNameAndMeta(BlockProperties.getBlockName(block), meta); final TileEntity te = world.getTileEntity(x, y, z); if (te != null) { entity.tileEntity = new NBTTagCompound(); te.writeToNBT(entity.tileEntity); } final boolean blockRemoved = new BlockManipulator(world, player, x, y, z).setSilentTeRemove(true).remove(); if (!blockRemoved) return null; entity.setPositionAndRotation(x + 0.5, y + 0.5, z + 0.5, 0, 0); return entity; }
@Override public void renderTileEntityAt(TileEntity t, double x, double y, double z, float pt) { Block blockType = t.getBlockType(); Tessellator tes = Tessellator.instance; tes.setColorOpaque_F(1.0F, 1.0F, 1.0F); renderBlocks.blockAccess = t.getWorldObj(); { if (Minecraft.isAmbientOcclusionEnabled()) { GL11.glShadeModel(GL11.GL_SMOOTH); } else { GL11.glShadeModel(GL11.GL_FLAT); } RenderHelper.disableStandardItemLighting(); RenderUtils.loadTexture(TextureMap.locationBlocksTexture); tes.startDrawingQuads(); tes.setTranslation(x - t.xCoord, y - t.yCoord, z - t.zCoord); renderBlocks.renderBlockAllFaces(blockType, t.xCoord, t.yCoord, t.zCoord); tes.setTranslation(0, 0, 0); tes.draw(); RenderHelper.enableStandardItemLighting(); } }
@Override @SideOnly(Side.CLIENT) public void renderTileEntityAt(TileEntity te, double x, double y, double z, float scale) { AbstractPowerExpander expander = (AbstractPowerExpander) te; ResourceLocation textures = (new ResourceLocation(ModInfo.ID + ":textures/blocks/expanderPowerTierFour.png")); Minecraft.getMinecraft().renderEngine.bindTexture(textures); int rotation = 0; if (te.getWorldObj() != null) { rotation = te.getBlockMetadata(); } GL11.glPushMatrix(); GL11.glTranslatef((float) x + 0.5F, (float) y + 1.5F, (float) z + 0.5F); GL11.glScalef(1.0F, -1F, -1F); GL11.glRotatef(rotation * 90, 0.0F, 1.0F, 0.0F); model.expander.rotateAngleX = expander.baseFitRotationX; model.expander.rotateAngleY = expander.baseFitRotationZ; model.renderAll(); GL11.glPopMatrix(); }
private void doRender( TileEntity tileEntity, double x, double y, double z, float partialTickTime) { this.bindTexture(resource); /* * 回転用の角度, tick毎に更新される. * なお, インベントリ内部では回転しない. */ float rot = 0.0F; if (tileEntity.getWorldObj() != null) { rot = tileEntity.getWorldObj().getWorldTime() % 360L; } GL11.glPushMatrix(); /* * 位置の調整と色の設定. */ GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); GL11.glTranslatef((float) x + 0.5F, (float) y + 0.5F, (float) z + 0.5F); GL11.glRotatef(-180F, 1.0F, 0.0F, 0.0F); GL11.glTranslatef(0.0F, -0.75F, 0.0F); /* * Y軸を回転させる処理. */ GL11.glRotatef(rot, 0.0F, 1.0F, 0.0F); modelCreeper.render((Entity) null, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0625F); GL11.glPopMatrix(); }
public boolean moveBlockSimple(JumpBlock shipBlock) { try { if (shipBlock == null) { return false; } int oldX = shipBlock.x; int oldY = shipBlock.y; int oldZ = shipBlock.z; int blockID = shipBlock.blockID; int blockMeta = shipBlock.blockMeta; mySetBlock(worldObj, oldX + newX, oldY + newY, oldZ + newZ, blockID, blockMeta, 2); NBTTagCompound oldnbt = new NBTTagCompound(); oldnbt = shipBlock.blockNBT; if (oldnbt != null) { TileEntity newTileEntity; newTileEntity = TileEntity.createAndLoadEntity(oldnbt); newTileEntity.worldObj = worldObj; newTileEntity.validate(); worldObj.setBlockTileEntity(oldX + newX, oldY + newY, oldZ + newZ, newTileEntity); } } catch (Exception exception) { exception.printStackTrace(); return false; } return true; }
/** * Called when the block receives a BlockEvent - see World.addBlockEvent. By default, passes it on * to the tile entity at this location. Args: world, x, y, z, blockID, EventID, event parameter */ @Override public boolean onBlockEventReceived( World par1World, int par2, int par3, int par4, int par5, int par6) { super.onBlockEventReceived(par1World, par2, par3, par4, par5, par6); TileEntity tileentity = par1World.getTileEntity(par2, par3, par4); return tileentity != null && tileentity.receiveClientEvent(par5, par6); }
public boolean onBlockActivated( World par1World, int i, int j, int k, EntityPlayer player, int par6, float par7, float par8, float par9) { if (par1World.isRemote) { return false; } else { ItemStack currentItem = player.inventory.getCurrentItem(); if (currentItem != null && currentItem.getItem() == CustomItems.wand && CustomNpcsPermissions.hasPermission(player, "customnpcs.editblocks")) { TileEntity tile = par1World.getTileEntity(i, j, k); NBTTagCompound compound = new NBTTagCompound(); tile.writeToNBT(compound); Server.sendData( (EntityPlayerMP) player, EnumPacketClient.GUI_WAYPOINT, new Object[] {compound}); return true; } else { return false; } } }
@Override public SpongeBlockSnapshot createSpongeBlockSnapshot( IBlockState state, IBlockState extended, BlockPos pos, int updateFlag) { this.builder.reset(); Location<World> location = new Location<>((World) this, VecHelper.toVector(pos)); this.builder .blockState((BlockState) state) .extendedState((BlockState) extended) .worldId(location.getExtent().getUniqueId()) .position(location.getBlockPosition()); Optional<UUID> creator = getCreator(pos.getX(), pos.getY(), pos.getZ()); Optional<UUID> notifier = getNotifier(pos.getX(), pos.getY(), pos.getZ()); if (creator.isPresent()) { this.builder.creator(creator.get()); } if (notifier.isPresent()) { this.builder.notifier(notifier.get()); } if (state.getBlock() instanceof ITileEntityProvider) { net.minecraft.tileentity.TileEntity te = getTileEntity(pos); if (te != null) { TileEntity tile = (TileEntity) te; for (DataManipulator<?, ?> manipulator : tile.getContainers()) { this.builder.add(manipulator); } NBTTagCompound nbt = new NBTTagCompound(); te.writeToNBT(nbt); this.builder.unsafeNbt(nbt); } } return new SpongeBlockSnapshot(this.builder, updateFlag); }
@Override public void execute() { if (t != null && p != null && t.getWorldObj() != null) if (t.getWorldObj().blockExists(t.xCoord, t.yCoord, t.zCoord)) if (t.getWorldObj().getTileEntity(t.xCoord, t.yCoord, t.zCoord) == t) MiscUtils.sendPacketToPlayer(t.getWorldObj(), t.getDescriptionPacket(), p); }
private void handleChestPage(Packet250CustomPayload packet) { DataInputStream inputStream = new DataInputStream(new ByteArrayInputStream(packet.data)); try { int x = inputStream.readInt(); int y = inputStream.readInt(); int z = inputStream.readInt(); int d = inputStream.readInt(); MinecraftServer s = MinecraftServer.getServer(); WorldServer w = s.worldServerForDimension(d); TileEntity te = w.getBlockTileEntity(x, y, z); if (te instanceof YC_TileEntityBlockChest) { int t = 0; t = inputStream.readInt(); int l = inputStream.readInt(); String PlayerName = ""; for (int i = 0; i < l; i++) { PlayerName = PlayerName + ((char) inputStream.readInt()); } ((YC_TileEntityBlockChest) te).handlePacketDataPage(t, PlayerName); PacketDispatcher.sendPacketToAllAround(x, y, z, 16, d, te.getDescriptionPacket()); } } catch (IOException e) { e.printStackTrace(); return; } }
public ItemStack decrStackSize(int index, int amount) { if (index >= stacks.length) { return null; } if (isGhostSlot(index) || isGhostOutputSlot(index)) { ItemStack old = stacks[index]; stacks[index] = null; if (old == null) { return null; } old.stackSize = 0; return old; } else { if (stacks[index] != null) { if (stacks[index].stackSize <= amount) { ItemStack old = stacks[index]; stacks[index] = null; tileEntity.markDirty(); return old; } ItemStack its = stacks[index].splitStack(amount); if (stacks[index].stackSize == 0) { stacks[index] = null; } tileEntity.markDirty(); return its; } return null; } }
@Override public void renderTileEntityAt(TileEntity te, double x, double y, double z, float scale) { int rotation = 180; switch (te.getBlockMetadata() % 4) { case 0: rotation = 0; break; case 3: rotation = 90; break; case 2: rotation = 180; break; case 1: rotation = 270; break; } GL11.glPushMatrix(); int i = te.getBlockMetadata(); GL11.glTranslatef((float) x + 0.5F, (float) y + 1.5F, (float) z + 0.5F); GL11.glRotatef(rotation, 0.0F, 1.0F, 0.0F); Minecraft.getMinecraft() .renderEngine .bindTexture(new ResourceLocation("Ported_Blocks:textures/texturemaps/Sail_HD.png")); GL11.glScalef(1.0F, -1F, -1F); model.render((Entity) null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F); GL11.glPopMatrix(); }
@Override public void updateEntity() { ItemStack jar = getStackInSlot(0); if (!worldObj.isRemote && jar != null && jar.getItem() instanceof ItemJarFilled) { ItemJarFilled item = (ItemJarFilled) jar.getItem(); AspectList aspectList = item.getAspects(jar); if (aspectList != null && aspectList.size() == 1) { Aspect aspect = aspectList.getAspects()[0]; TileEntity tile = worldObj.getBlockTileEntity(xCoord, yCoord - 1, zCoord); if (tile != null && tile instanceof TileEntityHopper) { TileEntity tile1 = getHopperFacing(tile.xCoord, tile.yCoord, tile.zCoord, tile.getBlockMetadata()); if (tile1 instanceof TileJarFillable) { TileJarFillable jar1 = (TileJarFillable) tile1; AspectList aspectList1 = jar1.getAspects(); if (aspectList1 != null && aspectList1.size() == 0 || aspectList1.getAspects()[0] == aspect && aspectList1.getAmount(aspectList1.getAspects()[0]) < 64) { jar1.addToContainer(aspect, 1); item.setAspects(jar, aspectList.remove(aspect, 1)); } } } } } }
public void renderTileEntityAt(TileEntity tileentity, double x, double y, double z, float f) { int i; if (tileentity.getWorldObj() == null) { i = 0; } else { Block block = tileentity.getBlockType(); i = tileentity.getBlockMetadata(); if ((block != null) && (i == 0)) { i = tileentity.getBlockMetadata(); } } GL11.glPushMatrix(); GL11.glTranslatef((float) x + 0.5F, (float) y + 1.5F, (float) z + 0.5F); Minecraft.getMinecraft().renderEngine.bindTexture(texture); GL11.glPushMatrix(); GL11.glRotatef(180.0F, 180.0F, 0.0F, 0.0F); int j = 0; if (i == 3) { j = 0; } if (i == 2) { j = 180; } if (i == 4) { j = 90; } if (i == 5) { j = 270; } GL11.glRotatef(j, 0.0F, 1.0F, 0.0F); this.model.render((Entity) null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F); GL11.glPopMatrix(); GL11.glPopMatrix(); }
public Schematic flip(final ISchematic schematic, final EnumFacing axis, boolean forced) throws FlipException { final Vec3i dimensionsFlipped = new Vec3i(schematic.getWidth(), schematic.getHeight(), schematic.getLength()); final Schematic schematicFlipped = new Schematic( schematic.getIcon(), dimensionsFlipped.getX(), dimensionsFlipped.getY(), dimensionsFlipped.getZ()); final MBlockPos tmp = new MBlockPos(); for (final MBlockPos pos : BlockPosHelper.getAllInBox( 0, 0, 0, schematic.getWidth() - 1, schematic.getHeight() - 1, schematic.getLength() - 1)) { final IBlockState blockState = schematic.getBlockState(pos); final IBlockState blockStateFlipped = flipBlock(blockState, axis, forced); schematicFlipped.setBlockState(flipPos(pos, axis, dimensionsFlipped, tmp), blockStateFlipped); } final List<TileEntity> tileEntities = schematic.getTileEntities(); for (final TileEntity tileEntity : tileEntities) { final BlockPos pos = tileEntity.getPos(); tileEntity.setPos(new BlockPos(flipPos(pos, axis, dimensionsFlipped, tmp))); schematicFlipped.setTileEntity(tileEntity.getPos(), tileEntity); } return schematicFlipped; }
/** Returns a list of all Tile Entities matching the class given within the bounding box */ public static <T extends TileEntity> List<T> getTileEntitiesWithinAABB( World world, Class<T> clazz, AxisAlignedBB aabb) { List<T> list = new ArrayList<T>(); int minX = MathHelper.floor_double(aabb.minX - World.MAX_ENTITY_RADIUS); int maxX = MathHelper.floor_double(aabb.maxX + World.MAX_ENTITY_RADIUS); int minY = MathHelper.floor_double(aabb.minY - World.MAX_ENTITY_RADIUS); int maxY = MathHelper.floor_double(aabb.maxY + World.MAX_ENTITY_RADIUS); int minZ = MathHelper.floor_double(aabb.minZ - World.MAX_ENTITY_RADIUS); int maxZ = MathHelper.floor_double(aabb.maxZ + World.MAX_ENTITY_RADIUS); if (!world.checkChunksExist(minX, minY, minZ, maxX, maxY, maxZ)) { return list; } for (int i = minX; i <= maxX; ++i) { for (int j = minY; j <= maxY; ++j) { for (int k = minZ; k <= maxZ; ++k) { TileEntity te = world.getTileEntity(i, j, k); if (te != null && clazz.isAssignableFrom(te.getClass())) { list.add((T) te); } } } } return list; }
public static Pipe getPipe(IBlockAccess blockAccess, int i, int j, int k) { TileEntity tile = blockAccess.getBlockTileEntity(i, j, k); if (!(tile instanceof TileGenericPipe) || tile.isInvalid()) return null; return ((TileGenericPipe) tile).pipe; }
public boolean rotateLittleChunk(World world, int x, int y, int z, ForgeDirection axis) { TileEntity tileentity = world.getTileEntity(x, y, z); if (tileentity != null && tileentity instanceof TileEntityLittleChunk) { ((TileEntityLittleChunk) tileentity).rotateContents(axis); tileentity.markDirty(); world.markBlockForUpdate(x, y, z); } return false; }
@Override public boolean onItemUseFirst( ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) { // We want to use onItemUseFirst() here so that this code will run on the server side, // so we don't need the client to send link-related updates to the server. Still, // check whether we have a rift in sight before passing the request over. // On integrated servers, the link won't be removed immediately because of the rift // removal animation. That means we'll have a chance to check for the link before // it's deleted. Otherwise the Rift Remover's durability wouldn't drop. MovingObjectPosition hit = this.getMovingObjectPositionFromPlayer(world, player, true); if (hit != null) { x = hit.blockX; y = hit.blockY; z = hit.blockZ; NewDimData dimension = PocketManager.createDimensionData(world); DimLink link = dimension.getLink(x, y, z); if (world.getBlock(x, y, z) == mod_pocketDim.blockRift && link != null && player.canPlayerEdit(x, y, z, side, stack)) { // Tell the rift's tile entity to do its removal animation TileEntity tileEntity = world.getTileEntity(x, y, z); if (tileEntity != null && tileEntity instanceof TileEntityRift) { ((TileEntityRift) tileEntity).shouldClose = true; tileEntity.markDirty(); } else if (!world.isRemote) { // Only set the block to air on the server side so that we don't // tell the server to remove the rift block before it can use the // Rift Remover. Otherwise, it won't know to reduce durability. world.setBlockToAir(x, y, z); } if (world.isRemote) { // Tell the server about this return false; } else { if (!player.capabilities.isCreativeMode) { stack.damageItem(1, player); } player.worldObj.playSoundAtEntity(player, mod_pocketDim.modid + ":riftClose", 0.8f, 1); } } } return true; }
public static void updateFurnaceBlockState( boolean flag, World world, int i, int j, int k, Block activeID, Block idleID, boolean sounds) { int l = world.getBlockMetadata(i, j, k); TileEntity tileentity = world.getTileEntity(i, j, k); setKeepInventory(true); if (flag) { if (sounds) { world.playSoundEffect( i + 0.5F, j + 0.5F, k + 0.5F, "mob.ghast.fireball", 1.0F, 0.8F + (world.rand.nextFloat() - world.rand.nextFloat()) * 0.7F); world.playSoundEffect( i + 0.5F, j + 0.5F, k + 0.5F, "mob.zombiepig.zpigdeath", 0.1F, 0.1F + (world.rand.nextFloat() - world.rand.nextFloat()) * 0.6F); world.playSoundEffect( i + 0.5F, j + 0.5F, k + 0.5F, "fire.ignite", 1.5F, 1.0F + (world.rand.nextFloat() - world.rand.nextFloat()) * 0.8F); } world.setBlock(i, j, k, activeID); } else { if (sounds) world.playSoundEffect( i + 0.5F, j + 0.5F, k + 0.5F, "ambient.cave.cave", 0.1F, 0.1F + (world.rand.nextFloat() - world.rand.nextFloat()) * 0.8F); world.setBlock(i, j, k, idleID); } setKeepInventory(false); world.setBlockMetadataWithNotify(i, j, k, l, 2); if (tileentity != null) { tileentity.validate(); world.setTileEntity(i, j, k, tileentity); } }
@Override public boolean worksWith(final World world, final int x, final int y, final int z) { final Class<?> filter = getTileEntityClass(); if (filter == null) { // This can happen if filter classes are deduced by reflection and // the class in question is not present. return false; } final TileEntity tileEntity = world.getTileEntity(x, y, z); return tileEntity != null && filter.isAssignableFrom(tileEntity.getClass()); }
public TileEntityConnectable getConnected() { TileEntity te = worldObj.getTileEntity( xCoord + linkedDir.offsetX, yCoord + linkedDir.offsetY, zCoord + linkedDir.offsetZ); if (linkedDir != ForgeDirection.UNKNOWN && te instanceof TileEntityConnectable && te.getClass() == this.getClass()) { return (TileEntityConnectable) te; } return null; }
public static void log(World world, TileEntity te, String message, Object... args) { if (doLogging) { long ticks = world.getTotalWorldTime(); if (ticks != prevTicks) { prevTicks = ticks; getInstance().logger.log(Level.INFO, "=== Time " + ticks + " ==="); } String id = te.getPos().getX() + "," + te.getPos().getY() + "," + te.getPos().getZ() + ": "; getInstance().logger.log(Level.INFO, id + String.format(message, args)); } }
@SuppressWarnings("unchecked") public <TE extends TileEntity> TE getTinkerTE(Class<TE> clazz) { for (Pair<BlockPos, IBlockState> pair : tinkerStationBlocks) { TileEntity te = this.world.getTileEntity(pair.getLeft()); if (te != null && clazz.isAssignableFrom(te.getClass())) { return (TE) te; } } return null; }