本文整理汇总了Java中net.minecraft.tileentity.TileEntity类的典型用法代码示例。如果您正苦于以下问题:Java TileEntity类的具体用法?Java TileEntity怎么用?Java TileEntity使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TileEntity类属于net.minecraft.tileentity包,在下文中一共展示了TileEntity类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onBlockPlacedBy
import net.minecraft.tileentity.TileEntity; //导入依赖的package包/类
@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);
}
}
示例2: getWailaBody
import net.minecraft.tileentity.TileEntity; //导入依赖的package包/类
/**
* 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;
}
示例3: addTileEntity
import net.minecraft.tileentity.TileEntity; //导入依赖的package包/类
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;
}
示例4: Chunk
import net.minecraft.tileentity.TileEntity; //导入依赖的package包/类
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);
}
示例5: onBlockActivated
import net.minecraft.tileentity.TileEntity; //导入依赖的package包/类
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;
}
}
示例6: onBlockActivated
import net.minecraft.tileentity.TileEntity; //导入依赖的package包/类
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;
}
}
示例7: cast
import net.minecraft.tileentity.TileEntity; //导入依赖的package包/类
@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);
}
示例8: func_181036_a
import net.minecraft.tileentity.TileEntity; //导入依赖的package包/类
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;
}
}
示例9: getConnectedPneumatics
import net.minecraft.tileentity.TileEntity; //导入依赖的package包/类
/**
* 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;
}
示例10: getComparatorInputOverride
import net.minecraft.tileentity.TileEntity; //导入依赖的package包/类
@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;
}
}
示例11: getComparatorInputOverride
import net.minecraft.tileentity.TileEntity; //导入依赖的package包/类
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;
}
示例12: addTileEntity
import net.minecraft.tileentity.TileEntity; //导入依赖的package包/类
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);
}
}
示例13: recursive
import net.minecraft.tileentity.TileEntity; //导入依赖的package包/类
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());
}
}
}
}
}
}
示例14: handleUpdateTileEntity
import net.minecraft.tileentity.TileEntity; //导入依赖的package包/类
/**
* 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();
}
}
}
示例15: getNBTData
import net.minecraft.tileentity.TileEntity; //导入依赖的package包/类
@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;
}