Java 类net.minecraft.tileentity.TileEntity 实例源码

项目:OpenFlexiTrack    文件:BlockRotateable.java   
@Override
public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase entity, ItemStack stack){

    super.onBlockPlacedBy(world, pos, state, entity, stack);

    TileEntity tile = world.getTileEntity(pos);
    if (tile instanceof TileEntityRotatable) {

        float yaw = entity.rotationYaw;
        while(yaw < 0){
            yaw += 360;
        }

        ((TileEntityRotatable) tile).rotation = (byte) (Math.round(yaw%360/45) % 8);
    }
}
项目:MobBlocker    文件:BlockChunkProtector.java   
/**
 * Called by WAILA/HWYLA compatibility handler
 * @param itemStack
 * @param currenttip
 * @param accessor
 * @param config
 * @return
 */
@Override
public List<String> getWailaBody(ItemStack itemStack, List<String> currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
    TileEntity te = accessor.getTileEntity();
    if (te instanceof TileEntityChunkProtector) {
        TileEntityChunkProtector chunkprotector = (TileEntityChunkProtector) te;
        int secondsLeft = chunkprotector.getSecondsBeforeDestroyed();
        int ticksLeft = chunkprotector.getTicksBeforeDestroyed();
        if (ticksLeft != -1) {
            if (accessor.getPlayer().isSneaking()) {
                currenttip.add(TextFormatting.BLUE + Integer.toString(ticksLeft) + " ticks left in world");
            } else currenttip.add(TextFormatting.BLUE + Integer.toString(secondsLeft) + " seconds left in world");
        } else currenttip.add(TextFormatting.GRAY + "Won't decay");
    }
    return currenttip;
}
项目:CustomWorldGen    文件:World.java   
public boolean addTileEntity(TileEntity tile)
{
    if (tile.getWorld() != null) // Forge - set the world early as vanilla doesn't set it until next tick
        tile.setWorldObj(this);

    List<TileEntity> dest = processingLoadedTiles ? addedTileEntityList : loadedTileEntityList;
    boolean flag = dest.add(tile);

    if (flag && tile instanceof ITickable)
    {
        this.tickableTileEntities.add(tile);
    }

    if (this.isRemote)
    {
        BlockPos blockpos = tile.getPos();
        IBlockState iblockstate = this.getBlockState(blockpos);
        this.notifyBlockUpdate(blockpos, iblockstate, iblockstate, 2);
    }

    return flag;
}
项目:BaseClient    文件:Chunk.java   
public Chunk(World worldIn, int x, int z)
{
    this.storageArrays = new ExtendedBlockStorage[16];
    this.blockBiomeArray = new byte[256];
    this.precipitationHeightMap = new int[256];
    this.updateSkylightColumns = new boolean[256];
    this.chunkTileEntityMap = Maps.<BlockPos, TileEntity>newHashMap();
    this.queuedLightChecks = 4096;
    this.tileEntityPosQueue = Queues.<BlockPos>newConcurrentLinkedQueue();
    this.entityLists = (ClassInheritanceMultiMap[])(new ClassInheritanceMultiMap[16]);
    this.worldObj = worldIn;
    this.xPosition = x;
    this.zPosition = z;
    this.heightMap = new int[256];

    for (int i = 0; i < this.entityLists.length; ++i)
    {
        this.entityLists[i] = new ClassInheritanceMultiMap(Entity.class);
    }

    Arrays.fill((int[])this.precipitationHeightMap, (int) - 999);
    Arrays.fill(this.blockBiomeArray, (byte) - 1);
}
项目:DecompiledMinecraft    文件:BlockBrewingStand.java   
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumFacing side, float hitX, float hitY, float hitZ)
{
    if (worldIn.isRemote)
    {
        return true;
    }
    else
    {
        TileEntity tileentity = worldIn.getTileEntity(pos);

        if (tileentity instanceof TileEntityBrewingStand)
        {
            playerIn.displayGUIChest((TileEntityBrewingStand)tileentity);
            playerIn.triggerAchievement(StatList.field_181729_M);
        }

        return true;
    }
}
项目:Backmemed    文件:BlockBeacon.java   
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing heldItem, float side, float hitX, float hitY)
{
    if (worldIn.isRemote)
    {
        return true;
    }
    else
    {
        TileEntity tileentity = worldIn.getTileEntity(pos);

        if (tileentity instanceof TileEntityBeacon)
        {
            playerIn.displayGUIChest((TileEntityBeacon)tileentity);
            playerIn.addStat(StatList.BEACON_INTERACTION);
        }

        return true;
    }
}
项目:Bewitchment    文件:IncantationSnuff.java   
@Override
public void cast(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException {
    World world = sender.getEntityWorld();
    BlockPos source = sender.getPosition();
    for (BlockPos pos : BlockPos.getAllInBox(source.add(5, 5, 5), source.add(-5, -5, -5))) {
        TileEntity tile = world.getTileEntity(pos);
        if (tile instanceof TileCandle && ((TileCandle) tile).isLit()) {
            for (int i = 0; i < 5; i++) {
                double x = pos.getX() + world.rand.nextFloat();
                double y = pos.getY() + world.rand.nextFloat();
                double z = pos.getZ() + world.rand.nextFloat();
                world.spawnParticle(EnumParticleTypes.FLAME, x, y, z, 0, 0, 0);
            }
            ((TileCandle) tile).unLitCandle();
            PacketHandler.updateToNearbyPlayers(world, pos);
        }
    }
    EnergyHandler.addEnergy((EntityPlayer) sender, 800);
}
项目:BaseClient    文件:Minecraft.java   
private ItemStack func_181036_a(Item p_181036_1_, int p_181036_2_, TileEntity p_181036_3_)
{
    ItemStack itemstack = new ItemStack(p_181036_1_, 1, p_181036_2_);
    NBTTagCompound nbttagcompound = new NBTTagCompound();
    p_181036_3_.writeToNBT(nbttagcompound);

    if (p_181036_1_ == Items.skull && nbttagcompound.hasKey("Owner"))
    {
        NBTTagCompound nbttagcompound2 = nbttagcompound.getCompoundTag("Owner");
        NBTTagCompound nbttagcompound3 = new NBTTagCompound();
        nbttagcompound3.setTag("SkullOwner", nbttagcompound2);
        itemstack.setTagCompound(nbttagcompound3);
        return itemstack;
    }
    else
    {
        itemstack.setTagInfo("BlockEntityTag", nbttagcompound);
        NBTTagCompound nbttagcompound1 = new NBTTagCompound();
        NBTTagList nbttaglist = new NBTTagList();
        nbttaglist.appendTag(new NBTTagString("(+NBT)"));
        nbttagcompound1.setTag("Lore", nbttaglist);
        itemstack.setTagInfo("display", nbttagcompound1);
        return itemstack;
    }
}
项目:pnc-repressurized    文件:AirHandler.java   
/**
 * Retrieves a list of all the connecting pneumatics. It takes sides in account.
 *
 * @return a list of face->air-handler pairs
 */
@Override
public List<Pair<EnumFacing, IAirHandler>> getConnectedPneumatics() {
    List<Pair<EnumFacing, IAirHandler>> teList = new ArrayList<>();
    for (IAirHandler specialConnection : specialConnectedHandlers) {
        teList.add(new ImmutablePair<>(null, specialConnection));
    }
    for (EnumFacing direction : EnumFacing.VALUES) {
        TileEntity te = getTileCache()[direction.ordinal()].getTileEntity();
        IPneumaticMachine machine = ModInteractionUtils.getInstance().getMachine(te);
        if (machine != null && parentPneumatic.getAirHandler(direction) == this && machine.getAirHandler(direction.getOpposite()) != null) {
            teList.add(new ImmutablePair<>(direction, machine.getAirHandler(direction.getOpposite())));
        }
    }
    if (airListener != null) airListener.addConnectedPneumatics(teList);
    return teList;
}
项目:Thermionics    文件:BlockMachineBase.java   
@Override
public int getComparatorInputOverride(IBlockState blockState, World world, BlockPos pos) {
    TileEntity tileentity = world.getTileEntity(pos);
    if (tileentity!=null && tileentity.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null)) {
        IItemHandler inventory = tileentity.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null);

        int capacity = inventory.getSlots();
        int filled = 0;
        for(int i=0; i<capacity; i++) {
            if (!inventory.getStackInSlot(i).isEmpty()) filled++;
        }

        float fraction = filled / (float)capacity;

        return (int)(fraction*15);
    } else {
        return 0;
    }
}
项目:Backmemed    文件:BlockJukebox.java   
public int getComparatorInputOverride(IBlockState blockState, World worldIn, BlockPos pos)
{
    TileEntity tileentity = worldIn.getTileEntity(pos);

    if (tileentity instanceof BlockJukebox.TileEntityJukebox)
    {
        ItemStack itemstack = ((BlockJukebox.TileEntityJukebox)tileentity).getRecord();

        if (!itemstack.func_190926_b())
        {
            return Item.getIdFromItem(itemstack.getItem()) + 1 - Item.getIdFromItem(Items.RECORD_13);
        }
    }

    return 0;
}
项目:Backmemed    文件:Chunk.java   
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);
    }
}
项目:Metalworks    文件:Network.java   
private void recursive(BlockPos from, List<BlockPos> searched, List<BlockPos> found, Map<BlockPos, EnumFacing> receivers){
    for(EnumFacing side : EnumFacing.values()){
        BlockPos newPos = from.offset(side);
        if(!searched.contains(newPos)){
            searched.add(newPos);
            TileEntity tile = this.world.getTileEntity(newPos);
            if(tile != null){
                if(tile instanceof TileCableBasic){
                    found.add(newPos);
                    ((TileCableBasic) tile).network = this;
                    recursive(newPos, searched, found, receivers);
                } else if(tile.hasCapability(CapabilityEnergy.ENERGY, side.getOpposite())){
                    IEnergyStorage storage = tile.getCapability(CapabilityEnergy.ENERGY, side.getOpposite());
                    if(storage != null && storage.canReceive()){
                        receivers.put(newPos, side.getOpposite());
                    }
                }
            }
        }
    }
}
项目:Zombe-Modpack    文件:NetHandlerPlayClient.java   
/**
 * Updates the NBTTagCompound metadata of instances of the following entitytypes: Mob spawners, command blocks,
 * beacons, skulls, flowerpot
 */
public void handleUpdateTileEntity(SPacketUpdateTileEntity packetIn)
{
    PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);

    if (this.gameController.world.isBlockLoaded(packetIn.getPos()))
    {
        TileEntity tileentity = this.gameController.world.getTileEntity(packetIn.getPos());
        int i = packetIn.getTileEntityType();
        boolean flag = i == 2 && tileentity instanceof TileEntityCommandBlock;

        if (i == 1 && tileentity instanceof TileEntityMobSpawner || flag || i == 3 && tileentity instanceof TileEntityBeacon || i == 4 && tileentity instanceof TileEntitySkull || i == 5 && tileentity instanceof TileEntityFlowerPot || i == 6 && tileentity instanceof TileEntityBanner || i == 7 && tileentity instanceof TileEntityStructure || i == 8 && tileentity instanceof TileEntityEndGateway || i == 9 && tileentity instanceof TileEntitySign || i == 10 && tileentity instanceof TileEntityShulkerBox)
        {
            tileentity.readFromNBT(packetIn.getNbtCompound());
        }

        if (flag && this.gameController.currentScreen instanceof GuiCommandBlock)
        {
            ((GuiCommandBlock)this.gameController.currentScreen).updateGui();
        }
    }
}
项目:pnc-repressurized    文件:WailaPneumaticHandler.java   
@Nonnull
@Override
public NBTTagCompound getNBTData(EntityPlayerMP player, TileEntity te, NBTTagCompound tag, World world, BlockPos pos) {
    TileEntity teInfo;
    if(te instanceof IInfoForwarder){
        teInfo = ((IInfoForwarder)te).getInfoTileEntity();
        if(teInfo != null){
            tag.setInteger("infoX", teInfo.getPos().getX());
            tag.setInteger("infoY", teInfo.getPos().getY());
            tag.setInteger("infoZ", teInfo.getPos().getZ());
        }
    }else{
        teInfo = te;
    }

    if (teInfo instanceof IPneumaticMachine) {
        tag.setFloat("pressure", ((IPneumaticMachine) teInfo).getAirHandler(null).getPressure());
    }

    return tag;
}
项目:BaseClient    文件:StructureComponent.java   
protected boolean generateDispenserContents(World worldIn, StructureBoundingBox boundingBoxIn, Random rand, int x, int y, int z, int meta, List<WeightedRandomChestContent> listIn, int max)
{
    BlockPos blockpos = new BlockPos(this.getXWithOffset(x, z), this.getYWithOffset(y), this.getZWithOffset(x, z));

    if (boundingBoxIn.isVecInside(blockpos) && worldIn.getBlockState(blockpos).getBlock() != Blocks.dispenser)
    {
        worldIn.setBlockState(blockpos, Blocks.dispenser.getStateFromMeta(this.getMetadataWithOffset(Blocks.dispenser, meta)), 2);
        TileEntity tileentity = worldIn.getTileEntity(blockpos);

        if (tileentity instanceof TileEntityDispenser)
        {
            WeightedRandomChestContent.generateDispenserContents(rand, listIn, (TileEntityDispenser)tileentity, max);
        }

        return true;
    }
    else
    {
        return false;
    }
}
项目:pnc-repressurized    文件:ItemRemote.java   
@Override
public void onUpdate(ItemStack remote, World worl, Entity entity, int slot, boolean holdingItem) {
    if (!worl.isRemote) {
        NBTTagCompound tag = remote.getTagCompound();
        if (tag != null) {
            if (tag.hasKey("securityX")) {
                int x = tag.getInteger("securityX");
                int y = tag.getInteger("securityY");
                int z = tag.getInteger("securityZ");
                int dimensionId = tag.getInteger("securityDimension");
                WorldServer world = DimensionManager.getWorld(dimensionId);
                if (world != null) {
                    TileEntity te = world.getTileEntity(new BlockPos(x, y, z));
                    if (!(te instanceof TileEntitySecurityStation)) {
                        tag.removeTag("securityX");
                        tag.removeTag("securityY");
                        tag.removeTag("securityZ");
                        tag.removeTag("securityDimension");
                    }
                }
            }
        }
    }
}
项目:DecompiledMinecraft    文件:Block.java   
public void harvestBlock(World worldIn, EntityPlayer player, BlockPos pos, IBlockState state, TileEntity te)
{
    player.triggerAchievement(StatList.mineBlockStatArray[getIdFromBlock(this)]);
    player.addExhaustion(0.025F);

    if (this.canSilkHarvest() && EnchantmentHelper.getSilkTouchModifier(player))
    {
        ItemStack itemstack = this.createStackedBlock(state);

        if (itemstack != null)
        {
            spawnAsEntity(worldIn, pos, itemstack);
        }
    }
    else
    {
        int i = EnchantmentHelper.getFortuneModifier(player);
        this.dropBlockAsItem(worldIn, pos, state, i);
    }
}
项目:Backmemed    文件:BlockContainer.java   
public void harvestBlock(World worldIn, EntityPlayer player, BlockPos pos, IBlockState state, @Nullable TileEntity te, ItemStack stack)
{
    if (te instanceof IWorldNameable && ((IWorldNameable)te).hasCustomName())
    {
        player.addStat(StatList.getBlockStats(this));
        player.addExhaustion(0.005F);

        if (worldIn.isRemote)
        {
            return;
        }

        int i = EnchantmentHelper.getEnchantmentLevel(Enchantments.FORTUNE, stack);
        Item item = this.getItemDropped(state, worldIn.rand, i);

        if (item == Items.field_190931_a)
        {
            return;
        }

        ItemStack itemstack = new ItemStack(item, this.quantityDropped(worldIn.rand));
        itemstack.setStackDisplayName(((IWorldNameable)te).getName());
        spawnAsEntity(worldIn, pos, itemstack);
    }
    else
    {
        super.harvestBlock(worldIn, player, pos, state, (TileEntity)null, stack);
    }
}
项目:Backmemed    文件:Chunk.java   
/**
 * Called when this Chunk is unloaded by the ChunkProvider
 */
public void onChunkUnload()
{
    this.isChunkLoaded = false;

    for (TileEntity tileentity : this.chunkTileEntityMap.values())
    {
        this.worldObj.markTileEntityForRemoval(tileentity);
    }

    for (ClassInheritanceMultiMap<Entity> classinheritancemultimap : this.entityLists)
    {
        this.worldObj.unloadEntities(classinheritancemultimap);
    }
}
项目:pnc-repressurized    文件:PneumaticCraftUtils.java   
public static TileEntity getTileEntity(BlockPos pos, int dimension) {
    World world = DimensionManager.getWorld(dimension);
    if (world != null && world.isBlockLoaded(pos)) {
        return world.getTileEntity(pos);
    }
    return null;
}
项目:FoodCraft-Reloaded    文件:ContainerPressureCooker.java   
public ContainerPressureCooker(InventoryPlayer playerInventory, TileEntity tileEntity) {
    this.inventoryPlayer = playerInventory;
    this.itemHandler = (IItemHandlerModifiable) tileEntity.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null);
    for (int i = 0; i < 2; ++i)
        for (int j = 0; j < 3; ++j)
            addSlotToContainer(new SlotItemHandler(itemHandler, j + i * 2, 43 + j * 24, 15 + i * 34));
    addSlotToContainer(new SlotItemHandler(itemHandler, 6, 141 + 4, 28 + 4));
    for (int i = 0; i < 3; ++i)
        for (int j = 0; j < 9; ++j)
            this.addSlotToContainer(new Slot(playerInventory, j + i * 9 + 9, 8 + j * 18, 84 + i * 18));

    for (int k = 0; k < 9; ++k)
        this.addSlotToContainer(new Slot(playerInventory, k, 8 + k * 18, 142));
}
项目:pnc-repressurized    文件:DroneEntityAIInventoryExport.java   
private boolean export(BlockPos pos, boolean simulate) {
        TileEntity te = drone.world().getTileEntity(pos);
        if (te != null) {
            for (int i = 0; i < drone.getInv().getSlots(); i++) {
                ItemStack droneStack = drone.getInv().getStackInSlot(i);
                if (!droneStack.isEmpty()) {
                    if (widget.isItemValidForFilters(droneStack)) {
                        for (int side = 0; side < 6; side++) {
                            if (((ISidedWidget) widget).getSides()[side]) {
                                droneStack = droneStack.copy();
                                int oldCount = droneStack.getCount();
                                if (((ICountWidget) widget).useCount()) {
                                    droneStack.setCount(Math.min(droneStack.getCount(), getRemainingCount()));
                                }
                                ItemStack remainder = IOHelper.insert(te, droneStack.copy(), EnumFacing.getFront(side), simulate);
                                int stackSize = drone.getInv().getStackInSlot(i).getCount() - (remainder.isEmpty() ? droneStack.getCount() : droneStack.getCount() - remainder.getCount());
                                droneStack.setCount(stackSize);
                                int exportedItems = oldCount - stackSize;
                                if (!simulate) {
                                    drone.getInv().setStackInSlot(i, stackSize > 0 ? droneStack : ItemStack.EMPTY);
                                    decreaseCount(exportedItems);
                                }
                                if (simulate && exportedItems > 0) return true;
//                                if (!(inv instanceof ISidedInventory))
//                                    break; //doing it for every side for no side sensitive inventories would be a waste.
                            }
                        }
                        if (droneStack.isEmpty() && !simulate) drone.addAir(null, -PneumaticValues.DRONE_USAGE_INV);
                        else drone.addDebugEntry("gui.progWidget.inventoryExport.debug.filledToMax", pos);
                    } else {
                        drone.addDebugEntry("gui.progWidget.inventoryExport.debug.stackdoesntPassFilter", pos);
                    }
                }
            }
        } else {
            drone.addDebugEntry("gui.progWidget.inventory.debug.noInventory", pos);
        }
        return false;
    }
项目:Backmemed    文件:RenderGlobal.java   
public void updateTileEntities(Collection<TileEntity> tileEntitiesToRemove, Collection<TileEntity> tileEntitiesToAdd)
{
    synchronized (this.setTileEntities)
    {
        this.setTileEntities.removeAll(tileEntitiesToRemove);
        this.setTileEntities.addAll(tileEntitiesToAdd);
    }
}
项目:ProjectEon    文件:WorldUtils.java   
public static <T extends TileEntity> T getTileEntity(World w, BlockPos pos, Class<T> type) {
    TileEntity te = w.getTileEntity(pos);
    if(te != null && type.isAssignableFrom(te.getClass())) {
        return (T)te;
    }
    return null;
}
项目:Backmemed    文件:EntityPlayerMP.java   
private void sendTileEntityUpdate(TileEntity p_147097_1_)
{
    if (p_147097_1_ != null)
    {
        SPacketUpdateTileEntity spacketupdatetileentity = p_147097_1_.getUpdatePacket();

        if (spacketupdatetileentity != null)
        {
            this.connection.sendPacket(spacketupdatetileentity);
        }
    }
}
项目:Bewitchment    文件:BlockOven.java   
@Override
public void breakBlock(World worldIn, BlockPos pos, IBlockState state) {
    final TileEntity tile1 = worldIn.getTileEntity(pos);
    if (tile1 != null && tile1 instanceof TileOven) {
        ((TileOven) tile1).dropItems();
    }
    worldIn.removeTileEntity(pos);
}
项目:Thermionics    文件:ContainerFirebox.java   
public ContainerFirebox(IInventory player, IInventory container, TileEntity te) {
    super(player, container);

    this.setTitleColor(0xFFFFFFFF);
    this.setColor(0xCC707070);

    WGridPanel panel = new WGridPanel();
    super.setRootPanel(panel);

    if (Thermionics.isAprilFools()) {
        panel.add(new WPlasma(), 0, 0, 9, 4);
    }

    panel.add(WItemSlot.of(container, 0), 2, 1);
    panel.add(new WBar(
            new ResourceLocation("thermionics","textures/gui/progress.flame.bg.png"),
            new ResourceLocation("thermionics","textures/gui/progress.flame.bar.png"),
            container, 0, 1
            ), 4, 1);

    panel.add(new WBar(
            new ResourceLocation("thermionics","textures/gui/progress.heat.bg.png"),
            new ResourceLocation("thermionics","textures/gui/progress.heat.bar.png"),
            container, 2, 3, WBar.Direction.RIGHT
            ), 1, 2, 7, 1);
    panel.add(WItemSlot.of(container, 1), 6, 1);

    panel.add(this.createPlayerInventoryPanel(), 0, 4);
}
项目:Clef    文件:GuiPlayTrackBlockHandler.java   
@Override
public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z)
{
    TileEntity te = world.getTileEntity(new BlockPos(x, y, z));
    if(te instanceof TileEntityInstrumentPlayer)
    {
        return new ContainerInstrumentPlayer((TileEntityInstrumentPlayer)te);
    }
    return null;
}
项目:PurificatiMagicae    文件:SipUtils.java   
public static String getSipInBlock(@Nullable IBlockAccess access, BlockPos pos)
{
    if(access != null)
    {
        TileEntity te = access.getTileEntity(pos);
        if (te != null && te instanceof TileSingleSip)
        {
            TileSingleSip tss = (TileSingleSip) te;
            return tss.getType();
        }
    }
    return PurMag.INSTANCE.getSipRegistry().getDefaultType().getName();
}
项目:CustomWorldGen    文件:BlockChest.java   
/**
 * Called serverside after this block is replaced with another in Chunk, but before the Tile Entity is updated
 */
public void breakBlock(World worldIn, BlockPos pos, IBlockState state)
{
    TileEntity tileentity = worldIn.getTileEntity(pos);

    if (tileentity instanceof IInventory)
    {
        InventoryHelper.dropInventoryItems(worldIn, pos, (IInventory)tileentity);
        worldIn.updateComparatorOutputLevel(pos, this);
    }

    super.breakBlock(worldIn, pos, state);
}
项目:BaseClient    文件:BlockTallGrass.java   
public void harvestBlock(World worldIn, EntityPlayer player, BlockPos pos, IBlockState state, TileEntity te)
{
    if (!worldIn.isRemote && player.getCurrentEquippedItem() != null && player.getCurrentEquippedItem().getItem() == Items.shears)
    {
        player.triggerAchievement(StatList.mineBlockStatArray[Block.getIdFromBlock(this)]);
        spawnAsEntity(worldIn, pos, new ItemStack(Blocks.tallgrass, 1, ((BlockTallGrass.EnumType)state.getValue(TYPE)).getMeta()));
    }
    else
    {
        super.harvestBlock(worldIn, player, pos, state, te);
    }
}
项目:CustomWorldGen    文件:VanillaInventoryCodeHooks.java   
public static boolean insertHook(IHopper hopper, EnumFacing facing)
{
    TileEntity tileEntity = hopper.getWorld().getTileEntity(
            new BlockPos(hopper.getXPos(), hopper.getYPos(), hopper.getZPos()).offset(facing));

    if (tileEntity == null)
        return false;
    if (!tileEntity.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, facing.getOpposite()))
        return false;

    IItemHandler handler = tileEntity.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, facing.getOpposite());

    for (int i = 0; i < hopper.getSizeInventory(); i++)
    {
        ItemStack stackInSlot = hopper.getStackInSlot(i);
        if (stackInSlot != null)
        {
            ItemStack insert = stackInSlot.copy();
            insert.stackSize = 1;
            ItemStack newStack = ItemHandlerHelper.insertItem(handler, insert, true);
            if (newStack == null || newStack.stackSize == 0)
            {
                ItemHandlerHelper.insertItem(handler, hopper.decrStackSize(i, 1), false);
                hopper.markDirty();
                return true;
            }
        }
    }

    return true;
}
项目:OpenSensors    文件:GUIHandler.java   
@Override
public Object getClientGuiElement(int id, EntityPlayer player, World world, int x, int y, int z) {
    if (id == 0) { //Sensor Block GUI
        TileEntity tileEntity = world.getTileEntity(x, y, z);
        if(tileEntity instanceof TileEntitySensor){
            return new SensorGUI(player.inventory, (TileEntitySensor) tileEntity);
        }
        return null;
    }
    return null;
}
项目:pnc-repressurized    文件:TileEntityAssemblyController.java   
private void getMachines(List<IAssemblyMachine> machineList, BlockPos pos) {
    for (EnumFacing dir : EnumFacing.HORIZONTALS) {
        TileEntity te = getWorld().getTileEntity(pos.offset(dir));
        if (te instanceof IAssemblyMachine && !machineList.contains(te)) {
            machineList.add((IAssemblyMachine) te);
            getMachines(machineList, te.getPos());
        }
    }
}
项目:GeneralLaymansAestheticSpyingScreen    文件:PacketWirelessOrder.java   
@Override
public void execute(Side side, EntityPlayer player)
{
    TileEntity te = player.getEntityWorld().getTileEntity(pos);
    if(te instanceof TileEntityGlassMaster && !((TileEntityGlassMaster)te).active)
    {
        ((TileEntityGlassMaster)te).wirelessPos = channel;
        te.markDirty();

        IBlockState state = player.getEntityWorld().getBlockState(pos);
        player.getEntityWorld().notifyBlockUpdate(pos, state, state, 3);
    }
}
项目:pnc-repressurized    文件:PacketUpdateTextfield.java   
@Override
public void handleServerSide(PacketUpdateTextfield message, EntityPlayer player) {
    TileEntity te = message.getTileEntity(player.getEntityWorld());
    if (te instanceof IGUITextFieldSensitive) {
        ((IGUITextFieldSensitive) te).setText(message.textFieldID, message.text);
    }
}
项目:PurificatiMagicae    文件:GuiTranslationDesk.java   
public void updateStatus()
{
    TileEntity te = world.getTileEntity(pos);
    if (te != null && te instanceof TileTranslationDesk)
    {
        TileTranslationDesk ttd = (TileTranslationDesk) te;
        ItemStack stack = ttd.handler.getStackInSlot(0);
        if (panel.translating)
        {
            status = Status.TRANSLATING;
            return;
        }
        entryName = null;
        if (!stack.isEmpty())
        {
            for (Pair<IfEntry, IRSTranslatePapyrus> p : PurMag.INSTANCE.getIfRegistry().getAllResearchableSteps(IRSTranslatePapyrus.class, Minecraft.getMinecraft().player))
            {
                if (p.getRight().isSuitable(stack))
                {
                    this.entryName = p.getLeft().getId();
                    this.stack = stack;
                    status = Status.CAN_TRANSLATE;
                    return;
                }
            }
            status = Status.CANT_TRANSLATE;
            return;
        }
    }
    status = Status.NO_PAPYRUS;
}
项目:BaseClient    文件:BlockBeacon.java   
/**
 * Called by ItemBlocks after a block is set in the world, to allow post-place logic
 */
public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack)
{
    super.onBlockPlacedBy(worldIn, pos, state, placer, stack);

    if (stack.hasDisplayName())
    {
        TileEntity tileentity = worldIn.getTileEntity(pos);

        if (tileentity instanceof TileEntityBeacon)
        {
            ((TileEntityBeacon)tileentity).setName(stack.getDisplayName());
        }
    }
}
项目:PurificatiMagicae    文件:BlockMagibench.java   
@Override
public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack)
{
    TileEntity te = worldIn.getTileEntity(pos);
    if (te != null && te instanceof TileMagibench)
    {
        TileMagibench bench = (TileMagibench) te;
        bench.setTier(stack.getMetadata(), false);
    }
}