Java Code Examples for net.minecraft.tileentity.TileEntity

The following are top voted examples for showing how to use net.minecraft.tileentity.TileEntity. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: OpenFlexiTrack   File: BlockRotateable.java   Source Code and License 6 votes vote down vote up
@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);
	}
}
 
Example 2
Project: MobBlocker   File: BlockChunkProtector.java   Source Code and License 6 votes vote down vote up
/**
 * 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;
}
 
Example 3
Project: CustomWorldGen   File: World.java   Source Code and License 6 votes vote down vote up
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;
}
 
Example 4
Project: BaseClient   File: Chunk.java   Source Code and License 6 votes vote down vote up
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);
}
 
Example 5
Project: DecompiledMinecraft   File: BlockBrewingStand.java   Source Code and License 6 votes vote down vote up
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;
    }
}
 
Example 6
Project: Backmemed   File: BlockBeacon.java   Source Code and License 6 votes vote down vote up
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;
    }
}
 
Example 7
Project: Bewitchment   File: IncantationSnuff.java   Source Code and License 6 votes vote down vote up
@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);
}
 
Example 8
Project: BaseClient   File: Minecraft.java   Source Code and License 6 votes vote down vote up
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;
    }
}
 
Example 9
Project: pnc-repressurized   File: AirHandler.java   Source Code and License 6 votes vote down vote up
/**
 * 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;
}
 
Example 10
Project: Thermionics   File: BlockMachineBase.java   Source Code and License 6 votes vote down vote up
@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;
	}
}
 
Example 11
Project: Backmemed   File: BlockJukebox.java   Source Code and License 6 votes vote down vote up
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;
}
 
Example 12
Project: Backmemed   File: Chunk.java   Source Code and License 6 votes vote down vote up
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);
    }
}
 
Example 13
Project: Metalworks   File: Network.java   Source Code and License 6 votes vote down vote up
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());
                    }
                }
            }
        }
    }
}
 
Example 14
Project: Zombe-Modpack   File: NetHandlerPlayClient.java   Source Code and License 6 votes vote down vote up
/**
 * 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();
        }
    }
}
 
Example 15
Project: pnc-repressurized   File: WailaPneumaticHandler.java   Source Code and License 6 votes vote down vote up
@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;
}
 
Example 16
Project: BaseClient   File: StructureComponent.java   Source Code and License 6 votes vote down vote up
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;
    }
}
 
Example 17
Project: pnc-repressurized   File: ItemRemote.java   Source Code and License 6 votes vote down vote up
@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");
                    }
                }
            }
        }
    }
}
 
Example 18
Project: DecompiledMinecraft   File: Block.java   Source Code and License 6 votes vote down vote up
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);
    }
}
 
Example 19
Project: Backmemed   File: BlockContainer.java   Source Code and License 5 votes vote down vote up
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);
    }
}
 
Example 20
Project: Backmemed   File: Chunk.java   Source Code and License 5 votes vote down vote up
/**
 * 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);
    }
}
 
Example 21
Project: pnc-repressurized   File: PneumaticCraftUtils.java   Source Code and License 5 votes vote down vote up
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;
}
 
Example 22
Project: FoodCraft-Reloaded   File: ContainerPressureCooker.java   Source Code and License 5 votes vote down vote up
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));
}
 
Example 23
Project: pnc-repressurized   File: DroneEntityAIInventoryExport.java   Source Code and License 5 votes vote down vote up
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;
    }
 
Example 24
Project: Backmemed   File: RenderGlobal.java   Source Code and License 5 votes vote down vote up
public void updateTileEntities(Collection<TileEntity> tileEntitiesToRemove, Collection<TileEntity> tileEntitiesToAdd)
{
    synchronized (this.setTileEntities)
    {
        this.setTileEntities.removeAll(tileEntitiesToRemove);
        this.setTileEntities.addAll(tileEntitiesToAdd);
    }
}
 
Example 25
Project: ProjectEon   File: WorldUtils.java   Source Code and License 5 votes vote down vote up
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;
}
 
Example 26
Project: Backmemed   File: EntityPlayerMP.java   Source Code and License 5 votes vote down vote up
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);
        }
    }
}
 
Example 27
Project: Bewitchment   File: BlockOven.java   Source Code and License 5 votes vote down vote up
@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);
}
 
Example 28
Project: Thermionics   File: ContainerFirebox.java   Source Code and License 5 votes vote down vote up
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);
}
 
Example 29
Project: Clef   File: GuiPlayTrackBlockHandler.java   Source Code and License 5 votes vote down vote up
@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;
}
 
Example 30
Project: PurificatiMagicae   File: SipUtils.java   Source Code and License 5 votes vote down vote up
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();
}
 
Example 31
Project: CustomWorldGen   File: BlockChest.java   Source Code and License 5 votes vote down vote up
/**
 * 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);
}
 
Example 32
Project: BaseClient   File: BlockTallGrass.java   Source Code and License 5 votes vote down vote up
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);
    }
}
 
Example 33
Project: CustomWorldGen   File: VanillaInventoryCodeHooks.java   Source Code and License 5 votes vote down vote up
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;
}
 
Example 34
Project: OpenSensors   File: GUIHandler.java   Source Code and License 5 votes vote down vote up
@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;
}
 
Example 35
Project: pnc-repressurized   File: TileEntityAssemblyController.java   Source Code and License 5 votes vote down vote up
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());
        }
    }
}
 
Example 36
Project: GeneralLaymansAestheticSpyingScreen   File: PacketWirelessOrder.java   Source Code and License 5 votes vote down vote up
@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);
    }
}
 
Example 37
Project: pnc-repressurized   File: PacketUpdateTextfield.java   Source Code and License 5 votes vote down vote up
@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);
    }
}
 
Example 38
Project: PurificatiMagicae   File: GuiTranslationDesk.java   Source Code and License 5 votes vote down vote up
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;
}
 
Example 39
Project: BaseClient   File: BlockBeacon.java   Source Code and License 5 votes vote down vote up
/**
 * 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());
        }
    }
}
 
Example 40
Project: PurificatiMagicae   File: BlockMagibench.java   Source Code and License 5 votes vote down vote up
@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);
    }
}
 
Example 41
Project: Backmemed   File: World.java   Source Code and License 5 votes vote down vote up
public void addTileEntities(Collection<TileEntity> tileEntityCollection)
{
    if (this.processingLoadedTiles)
    {
        this.addedTileEntityList.addAll(tileEntityCollection);
    }
    else
    {
        for (TileEntity tileentity : tileEntityCollection)
        {
            this.addTileEntity(tileentity);
        }
    }
}
 
Example 42
Project: BaseClient   File: BlockDispenser.java   Source Code and License 5 votes vote down vote up
public void breakBlock(World worldIn, BlockPos pos, IBlockState state)
{
    TileEntity tileentity = worldIn.getTileEntity(pos);

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

    super.breakBlock(worldIn, pos, state);
}
 
Example 43
Project: Backmemed   File: BlockSkull.java   Source Code and License 5 votes vote down vote up
/**
 * 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)
{
    if (!worldIn.isRemote)
    {
        if (!((Boolean)state.getValue(NODROP)).booleanValue())
        {
            TileEntity tileentity = worldIn.getTileEntity(pos);

            if (tileentity instanceof TileEntitySkull)
            {
                TileEntitySkull tileentityskull = (TileEntitySkull)tileentity;
                ItemStack itemstack = this.getItem(worldIn, pos, state);

                if (tileentityskull.getSkullType() == 3 && tileentityskull.getPlayerProfile() != null)
                {
                    itemstack.setTagCompound(new NBTTagCompound());
                    NBTTagCompound nbttagcompound = new NBTTagCompound();
                    NBTUtil.writeGameProfile(nbttagcompound, tileentityskull.getPlayerProfile());
                    itemstack.getTagCompound().setTag("SkullOwner", nbttagcompound);
                }

                spawnAsEntity(worldIn, pos, itemstack);
            }
        }

        super.breakBlock(worldIn, pos, state);
    }
}
 
Example 44
Project: CustomWorldGen   File: BlockCommandBlock.java   Source Code and License 5 votes vote down vote up
/**
 * Called when a neighboring block was changed and marks that this state should perform any checks during a neighbor
 * change. Cases may include when redstone power is updated, cactus blocks popping off due to a neighboring solid
 * block, etc.
 */
public void neighborChanged(IBlockState state, World worldIn, BlockPos pos, Block blockIn)
{
    if (!worldIn.isRemote)
    {
        TileEntity tileentity = worldIn.getTileEntity(pos);

        if (tileentity instanceof TileEntityCommandBlock)
        {
            TileEntityCommandBlock tileentitycommandblock = (TileEntityCommandBlock)tileentity;
            boolean flag = worldIn.isBlockPowered(pos);
            boolean flag1 = tileentitycommandblock.isPowered();
            boolean flag2 = tileentitycommandblock.isAuto();

            if (flag && !flag1)
            {
                tileentitycommandblock.setPowered(true);

                if (tileentitycommandblock.getMode() != TileEntityCommandBlock.Mode.SEQUENCE && !flag2)
                {
                    boolean flag3 = !tileentitycommandblock.isConditional() || this.isNextToSuccessfulCommandBlock(worldIn, pos, state);
                    tileentitycommandblock.setConditionMet(flag3);
                    worldIn.scheduleUpdate(pos, this, this.tickRate(worldIn));

                    if (flag3)
                    {
                        this.propagateUpdate(worldIn, pos);
                    }
                }
            }
            else if (!flag && flag1)
            {
                tileentitycommandblock.setPowered(false);
            }
        }
    }
}
 
Example 45
Project: DecompiledMinecraft   File: BlockBeacon.java   Source Code and License 5 votes vote down vote up
public static void updateColorAsync(final World worldIn, final BlockPos glassPos)
{
    HttpUtil.field_180193_a.submit(new Runnable()
    {
        public void run()
        {
            Chunk chunk = worldIn.getChunkFromBlockCoords(glassPos);

            for (int i = glassPos.getY() - 1; i >= 0; --i)
            {
                final BlockPos blockpos = new BlockPos(glassPos.getX(), i, glassPos.getZ());

                if (!chunk.canSeeSky(blockpos))
                {
                    break;
                }

                IBlockState iblockstate = worldIn.getBlockState(blockpos);

                if (iblockstate.getBlock() == Blocks.beacon)
                {
                    ((WorldServer)worldIn).addScheduledTask(new Runnable()
                    {
                        public void run()
                        {
                            TileEntity tileentity = worldIn.getTileEntity(blockpos);

                            if (tileentity instanceof TileEntityBeacon)
                            {
                                ((TileEntityBeacon)tileentity).updateBeacon();
                                worldIn.addBlockEvent(blockpos, Blocks.beacon, 1, 0);
                            }
                        }
                    });
                }
            }
        }
    });
}
 
Example 46
Project: DecompiledMinecraft   File: BlockJukebox.java   Source Code and License 5 votes vote down vote up
public void insertRecord(World worldIn, BlockPos pos, IBlockState state, ItemStack recordStack)
{
    if (!worldIn.isRemote)
    {
        TileEntity tileentity = worldIn.getTileEntity(pos);

        if (tileentity instanceof BlockJukebox.TileEntityJukebox)
        {
            ((BlockJukebox.TileEntityJukebox)tileentity).setRecord(new ItemStack(recordStack.getItem(), 1, recordStack.getMetadata()));
            worldIn.setBlockState(pos, state.withProperty(HAS_RECORD, Boolean.valueOf(true)), 2);
        }
    }
}
 
Example 47
Project: pnc-repressurized   File: TileEntityAssemblyIOUnit.java   Source Code and License 5 votes vote down vote up
/**
 * Find a slot into which to place an exported item.  Note that other assembly robots are not valid export
 * locations, but any other TE which provides CAPABILITY_ITEM_HANDLER on the top face is a valid candidate.
 *
 * @param exportedItem item to export
 * @param te where the item is being attempted to insert to (will use the top face for IItemHandler cap.)
 * @return the placement slot, or -1 when the item can't be placed / accessed
 */
private static int getPlacementSlot(ItemStack exportedItem, TileEntity te) {
    if (te != null && !(te instanceof TileEntityAssemblyRobot) && te.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, EnumFacing.UP)) {
        IItemHandler handler = te.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, EnumFacing.UP);
        for (int slot = 0; slot < handler.getSlots(); slot++) {
            ItemStack excess = handler.insertItem(slot, exportedItem, true);
            if (excess.getCount() < exportedItem.getCount()) {
                return slot;
            }
        }
    }
    return -1;
}
 
Example 48
Project: CustomWorldGen   File: BlockPistonMoving.java   Source Code and License 5 votes vote down vote up
/**
 * 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 TileEntityPiston)
    {
        ((TileEntityPiston)tileentity).clearPistonTileEntity();
    }
    else
    {
        super.breakBlock(worldIn, pos, state);
    }
}
 
Example 49
Project: pnc-repressurized   File: BlockAirCannon.java   Source Code and License 4 votes vote down vote up
@Override
protected Class<? extends TileEntity> getTileEntityClass() {
    return TileEntityAirCannon.class;
}
 
Example 50
Project: Thermionics   File: BlockBattery.java   Source Code and License 4 votes vote down vote up
@Override
public TileEntity createNewTileEntity(World worldIn, int meta) {
	return new TileEntityBattery();
}
 
Example 51
Project: pnc-repressurized   File: WorldTimeSensor.java   Source Code and License 4 votes vote down vote up
@Override
public int getPollFrequency(TileEntity te) {
    return 40;
}
 
Example 52
Project: Infernum   File: PigmanMageTowerGenerator.java   Source Code and License 4 votes vote down vote up
public void generateTower(WorldServer world, BlockPos pos, Random rand) {
	MinecraftServer server = world.getMinecraftServer();
	Template template = world.getStructureTemplateManager().getTemplate(server, TOWER_STRUCTURE);
	PlacementSettings settings = new PlacementSettings();
	settings.setRotation(Rotation.values()[rand.nextInt(Rotation.values().length)]);
	
	BlockPos size = template.getSize();
	int airBlocks = 0;
	for(int x = 0; x < size.getX(); x++) {
		for (int z = 0; z < size.getZ(); z++) {
			if (world.isAirBlock(pos.add(template.transformedBlockPos(settings, new BlockPos(x, 0, z))))) {
				airBlocks++;
				if (airBlocks > 0.33 * (size.getX() * size.getZ())) {
					return;
				}
			}
		}
	}
	for (int x = 0; x < size.getX(); x++) {
		for (int z = 0; z < size.getZ(); z++) {
			if (x == 0 || x == size.getX() - 1 || z == 0 || z == size.getZ() - 1) {
				for (int y = 0; y < size.getY(); y++) {
					BlockPos checkPos = pos.add(template.transformedBlockPos(settings, new BlockPos(x, y, z)));
					IBlockState checkState = world.getBlockState(checkPos);
					if (!checkState.getBlock().isAir(checkState, world, checkPos)) {
						if (!(y <= 3 && (checkState.getBlock() == Blocks.NETHERRACK || checkState.getBlock() == Blocks.QUARTZ_ORE || checkState.getBlock() == Blocks.MAGMA))) {
							return;
						}
					}
				}
			}
		}
	}

	template.addBlocksToWorld(world, pos, settings);

	Map<BlockPos, String> dataBlocks = template.getDataBlocks(pos, settings);
	for (Entry<BlockPos, String> entry : dataBlocks.entrySet()) {
		String[] tokens = entry.getValue().split(" ");
		if (tokens.length == 0)
			return;

		BlockPos dataPos = entry.getKey();
		EntityPigMage pigMage;

		switch (tokens[0]) {
		case "pigman_mage":
			pigMage = new EntityPigMage(world);
			pigMage.setPosition(dataPos.getX() + 0.5, dataPos.getY(), dataPos.getZ() + 0.5);
			pigMage.onInitialSpawn(world.getDifficultyForLocation(dataPos), null);
			world.spawnEntity(pigMage);
			break;
		case "fortress_chest":
			IBlockState chestState = Blocks.CHEST.getDefaultState().withRotation(settings.getRotation());
			chestState = chestState.withMirror(Mirror.FRONT_BACK);
			world.setBlockState(dataPos, chestState);
			TileEntity tile = world.getTileEntity(dataPos);
			if (tile != null && tile instanceof TileEntityLockableLoot)
				((TileEntityLockableLoot) tile).setLootTable(NETHER_BRIDGE_LOOT_TABLE, rand.nextLong());
			break;
		}
	}

}
 
Example 53
Project: Defier   File: DefierBlock.java   Source Code and License 4 votes vote down vote up
@Override
public TileEntity createNewTileEntity(World worldIn, int meta) {
	return new DefierTileEntity();
}
 
Example 54
Project: Zombe-Modpack   File: NetHandlerPlayServer.java   Source Code and License 4 votes vote down vote up
/**
 * Update the server with an ItemStack in a slot.
 */
public void processCreativeInventoryAction(CPacketCreativeInventoryAction packetIn)
{
    PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.playerEntity.getServerWorld());

    if (this.playerEntity.interactionManager.isCreative())
    {
        boolean flag = packetIn.getSlotId() < 0;
        ItemStack itemstack = packetIn.getStack();

        if (!itemstack.func_190926_b() && itemstack.hasTagCompound() && itemstack.getTagCompound().hasKey("BlockEntityTag", 10))
        {
            NBTTagCompound nbttagcompound = itemstack.getTagCompound().getCompoundTag("BlockEntityTag");

            if (nbttagcompound.hasKey("x") && nbttagcompound.hasKey("y") && nbttagcompound.hasKey("z"))
            {
                BlockPos blockpos = new BlockPos(nbttagcompound.getInteger("x"), nbttagcompound.getInteger("y"), nbttagcompound.getInteger("z"));
                TileEntity tileentity = this.playerEntity.world.getTileEntity(blockpos);

                if (tileentity != null)
                {
                    NBTTagCompound nbttagcompound1 = tileentity.writeToNBT(new NBTTagCompound());
                    nbttagcompound1.removeTag("x");
                    nbttagcompound1.removeTag("y");
                    nbttagcompound1.removeTag("z");
                    itemstack.setTagInfo("BlockEntityTag", nbttagcompound1);
                }
            }
        }

        boolean flag1 = packetIn.getSlotId() >= 1 && packetIn.getSlotId() <= 45;
        boolean flag2 = itemstack.func_190926_b() || itemstack.getMetadata() >= 0 && itemstack.func_190916_E() <= 64 && !itemstack.func_190926_b();

        if (flag1 && flag2)
        {
            if (itemstack.func_190926_b())
            {
                this.playerEntity.inventoryContainer.putStackInSlot(packetIn.getSlotId(), ItemStack.field_190927_a);
            }
            else
            {
                this.playerEntity.inventoryContainer.putStackInSlot(packetIn.getSlotId(), itemstack);
            }

            this.playerEntity.inventoryContainer.setCanCraft(this.playerEntity, true);
        }
        else if (flag && flag2 && this.itemDropThreshold < 200)
        {
            this.itemDropThreshold += 20;
            EntityItem entityitem = this.playerEntity.dropItem(itemstack, true);

            if (entityitem != null)
            {
                entityitem.setAgeToCreativeDespawnTime();
            }
        }
    }
}
 
Example 55
Project: DecompiledMinecraft   File: NetHandlerPlayServer.java   Source Code and License 4 votes vote down vote up
/**
 * Update the server with an ItemStack in a slot.
 */
public void processCreativeInventoryAction(C10PacketCreativeInventoryAction packetIn)
{
    PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.playerEntity.getServerForPlayer());

    if (this.playerEntity.theItemInWorldManager.isCreative())
    {
        boolean flag = packetIn.getSlotId() < 0;
        ItemStack itemstack = packetIn.getStack();

        if (itemstack != null && itemstack.hasTagCompound() && itemstack.getTagCompound().hasKey("BlockEntityTag", 10))
        {
            NBTTagCompound nbttagcompound = itemstack.getTagCompound().getCompoundTag("BlockEntityTag");

            if (nbttagcompound.hasKey("x") && nbttagcompound.hasKey("y") && nbttagcompound.hasKey("z"))
            {
                BlockPos blockpos = new BlockPos(nbttagcompound.getInteger("x"), nbttagcompound.getInteger("y"), nbttagcompound.getInteger("z"));
                TileEntity tileentity = this.playerEntity.worldObj.getTileEntity(blockpos);

                if (tileentity != null)
                {
                    NBTTagCompound nbttagcompound1 = new NBTTagCompound();
                    tileentity.writeToNBT(nbttagcompound1);
                    nbttagcompound1.removeTag("x");
                    nbttagcompound1.removeTag("y");
                    nbttagcompound1.removeTag("z");
                    itemstack.setTagInfo("BlockEntityTag", nbttagcompound1);
                }
            }
        }

        boolean flag1 = packetIn.getSlotId() >= 1 && packetIn.getSlotId() < 36 + InventoryPlayer.getHotbarSize();
        boolean flag2 = itemstack == null || itemstack.getItem() != null;
        boolean flag3 = itemstack == null || itemstack.getMetadata() >= 0 && itemstack.stackSize <= 64 && itemstack.stackSize > 0;

        if (flag1 && flag2 && flag3)
        {
            if (itemstack == null)
            {
                this.playerEntity.inventoryContainer.putStackInSlot(packetIn.getSlotId(), (ItemStack)null);
            }
            else
            {
                this.playerEntity.inventoryContainer.putStackInSlot(packetIn.getSlotId(), itemstack);
            }

            this.playerEntity.inventoryContainer.setCanCraft(this.playerEntity, true);
        }
        else if (flag && flag2 && flag3 && this.itemDropThreshold < 200)
        {
            this.itemDropThreshold += 20;
            EntityItem entityitem = this.playerEntity.dropPlayerItemWithRandomChoice(itemstack, true);

            if (entityitem != null)
            {
                entityitem.setAgeToCreativeDespawnTime();
            }
        }
    }
}
 
Example 56
Project: DecompiledMinecraft   File: Container.java   Source Code and License 4 votes vote down vote up
/**
 * Like the version that takes an inventory. If the given TileEntity is not an Inventory, 0 is returned instead.
 */
public static int calcRedstone(TileEntity te)
{
    return te instanceof IInventory ? calcRedstoneFromInventory((IInventory)te) : 0;
}
 
Example 57
Project: DecompiledMinecraft   File: BlockChest.java   Source Code and License 4 votes vote down vote up
/**
 * Returns a new instance of a block's tile entity class. Called on placing the block.
 */
public TileEntity createNewTileEntity(World worldIn, int meta)
{
    return new TileEntityChest();
}
 
Example 58
Project: Thermionics   File: BlockBattery.java   Source Code and License 4 votes vote down vote up
public void harvestBlock(World world, EntityPlayer player, BlockPos pos, IBlockState state, @Nullable TileEntity te, ItemStack stack) {
ItemStack toDrop = getBatteryItem(te);
//System.out.println("toDrop: "+toDrop);
spawnAsEntity(world, pos, toDrop);
//world.removeTileEntity(pos);
  }
 
Example 59
Project: DecompiledMinecraft   File: BlockBanner.java   Source Code and License 4 votes vote down vote up
/**
 * Returns a new instance of a block's tile entity class. Called on placing the block.
 */
public TileEntity createNewTileEntity(World worldIn, int meta)
{
    return new TileEntityBanner();
}
 
Example 60
Project: pnc-repressurized   File: BlockPressureChamberWallBase.java   Source Code and License 4 votes vote down vote up
@Override
protected Class<? extends TileEntity> getTileEntityClass() {
    return TileEntityPressureChamberWall.class;
}