本文整理匯總了Java中net.minecraft.block.BlockContainer類的典型用法代碼示例。如果您正苦於以下問題:Java BlockContainer類的具體用法?Java BlockContainer怎麽用?Java BlockContainer使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
BlockContainer類屬於net.minecraft.block包,在下文中一共展示了BlockContainer類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: shouldEat
import net.minecraft.block.BlockContainer; //導入依賴的package包/類
private boolean shouldEat()
{
if(!Wrapper.getPlayer().canEat(false))
return false;
if(Wrapper.getMinecraft().currentScreen != null)
return false;
if(Wrapper.getMinecraft().currentScreen == null && Wrapper.getMinecraft().objectMouseOver != null)
{
Entity entity = Wrapper.getMinecraft().objectMouseOver.entityHit;
if(entity instanceof EntityVillager || entity instanceof EntityTameable)
return false;
if(Wrapper.getMinecraft().objectMouseOver.getBlockPos() != null && Wrapper.getWorld().
getBlockState(Wrapper.getMinecraft().objectMouseOver.getBlockPos()).getBlock() instanceof BlockContainer)
return false;
}
return true;
}
示例2: onItemUse
import net.minecraft.block.BlockContainer; //導入依賴的package包/類
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int i, int j, int k, int side, float f, float f1, float f2)
{
if (player.isSneaking()) {
return false;
}
if (!world.isRemote)
{
if (!world.canMineBlock(player, i, j, k)) {
return false;
}
if (!player.canPlayerEdit(i, j, k, side, stack)) {
return false;
}
Block block = world.getBlock(i, j, k);
if (prohibitedBlocks.contains(block)) {
return false;
}
if ((block instanceof BlockContainer)) {
return false;
}
int data = world.getBlockMetadata(i, j, k);
world.setBlock(i, j, k, Blocks.air, 0, 3);
world.spawnEntityInWorld(new EnderBlock(world, player, block, data));
}
return true;
}
示例3: buildBlock
import net.minecraft.block.BlockContainer; //導入依賴的package包/類
/**
* Places the block in the world, at the location specified in the slot.
*/
public void buildBlock(BptSlotInfo slot, IBptContext context) {
// Meta needs to be specified twice, depending on the block behavior
context.world().setBlock(slot.x, slot.y, slot.z, slot.blockId, slot.meta,3);
context.world().setBlockMetadataWithNotify(slot.x, slot.y, slot.z, slot.meta,3);
if (Block.blocksList[slot.blockId] instanceof BlockContainer) {
TileEntity tile = context.world().getBlockTileEntity(slot.x, slot.y, slot.z);
slot.cpt.setInteger("x", slot.x);
slot.cpt.setInteger("y", slot.y);
slot.cpt.setInteger("z", slot.z);
if (tile != null) {
tile.readFromNBT(slot.cpt);
}
}
}
示例4: initializeFromWorld
import net.minecraft.block.BlockContainer; //導入依賴的package包/類
/**
* Initializes a slot from the blueprint according to an objet placed on {x, y, z} on the world. This typically means adding entries in slot.cpt. Note that
* "id" and "meta" will be set automatically, corresponding to the block id and meta.
*
* By default, if the block is a BlockContainer, tile information will be to save / load the block.
*/
public void initializeFromWorld(BptSlotInfo slot, IBptContext context, int x, int y, int z) {
if (Block.blocksList[slot.blockId] instanceof BlockContainer) {
TileEntity tile = context.world().getBlockTileEntity(x, y, z);
if (tile != null) {
tile.writeToNBT(slot.cpt);
}
}
if (Block.blocksList[slot.blockId] != null) {
ArrayList<ItemStack> req = Block.blocksList[slot.blockId].getBlockDropped(context.world(), x, y, z, context.world().getBlockMetadata(x, y, z), 0);
if (req != null) {
slot.storedRequirements.addAll(req);
}
}
}
示例5: getSignature
import net.minecraft.block.BlockContainer; //導入依賴的package包/類
/**
* By default, block class name, block tile name and block name are used to define block signature. Overriding this subprogram may allow to replace some of
* these with stars, specify the mod that this block kind is coming from or add custom data to the signature.
*/
public BlockSignature getSignature(Block block) {
BlockSignature sig = new BlockSignature();
if (block.blockID > BuildCraftAPI.LAST_ORIGINAL_BLOCK) {
sig.blockClassName = block.getClass().getSimpleName();
if (block instanceof BlockContainer) {
// TODO: Try to see if we can get a world instance to call with instead of null
TileEntity tile = ((BlockContainer) block).createNewTileEntity(null);
if (tile != null) {
sig.tileClassName = tile.getClass().getSimpleName();
}
}
}
sig.blockName = block.getUnlocalizedName();
sig.replaceNullWithStar();
return sig;
}
示例6: isPlantValidForSlot
import net.minecraft.block.BlockContainer; //導入依賴的package包/類
public boolean isPlantValidForSlot (World world, int x, int y, int z, int slot, PlantItem plant) {
if (plant == null)
return false;
if (plant.getPlantBlock() instanceof BlockContainer)
return false;
if (!slotProfile.isPlantValidForSlot(world, x, y, z, slot, plant))
return false;
if (!enoughSpaceAround(world, x, y, z, slot, plant))
return false;
if (!isPlantValidForSubstrate(getGardenSubstrate(world, x, y, z, slot), plant))
return false;
if (canSustainPlantIndependently(world, x, y, z, plant))
return false;
return true;
}
示例7: shouldEat
import net.minecraft.block.BlockContainer; //導入依賴的package包/類
private boolean shouldEat()
{
// check hunger
if(!WMinecraft.getPlayer().canEat(false))
return false;
// check screen
if(!ignoreScreen.isChecked() && mc.currentScreen != null)
return false;
// check for clickable objects
if(mc.currentScreen == null && mc.objectMouseOver != null)
{
// clickable entities
Entity entity = mc.objectMouseOver.entityHit;
if(entity instanceof EntityVillager
|| entity instanceof EntityTameable)
return false;
// clickable blocks
BlockPos pos = mc.objectMouseOver.getBlockPos();
if(pos != null)
{
Block block =
WMinecraft.getWorld().getBlockState(pos).getBlock();
if(block instanceof BlockContainer
|| block instanceof BlockWorkbench)
return false;
}
}
return true;
}
示例8: shouldEatSoup
import net.minecraft.block.BlockContainer; //導入依賴的package包/類
private boolean shouldEatSoup()
{
// check health
if(WMinecraft.getPlayer().getHealth() > health.getValueF() * 2F)
return false;
// check screen
if(!ignoreScreen.isChecked() && mc.currentScreen != null)
return false;
// check for clickable objects
if(mc.currentScreen == null && mc.objectMouseOver != null)
{
// clickable entities
Entity entity = mc.objectMouseOver.entityHit;
if(entity instanceof EntityVillager
|| entity instanceof EntityTameable)
return false;
// clickable blocks
if(mc.objectMouseOver.getBlockPos() != null && WBlock.getBlock(
mc.objectMouseOver.getBlockPos()) instanceof BlockContainer)
return false;
}
return true;
}
示例9: initClient
import net.minecraft.block.BlockContainer; //導入依賴的package包/類
@Mod.EventHandler
@SideOnly(Side.CLIENT)
public void initClient(FMLPreInitializationEvent event) {
for (Block b : chest_blocks) {
BlockContainer chest = (BlockContainer) b;
TileEntity te = chest.createNewTileEntity(null, 0);
if (te == null) continue;
TileEntityRendererDispatcher.instance.mapSpecialRenderers.remove(te.getClass());
}
// TODO: Needs a custom item renderer. Whatever. 1.8'll be here eventually.
}
示例10: register3DItem
import net.minecraft.block.BlockContainer; //導入依賴的package包/類
public void register3DItem(BlockContainer theBlock, TileEntitySpecialRenderer renderer) {
try {
MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(theBlock),
new GenericBlockItemRenderer(renderer, theBlock.createNewTileEntity(null, 0)));
} catch (Exception e) {
e.printStackTrace();
}
}
示例11: updateWorldInfo
import net.minecraft.block.BlockContainer; //導入依賴的package包/類
@Override
public void updateWorldInfo(World worldIn, BlockPos pos)
{
adjAirCount = 0;
List<HeatManager> adjacentManagers = new ArrayList<HeatManager>();
// For each adjacent block
for (EnumFacing f : EnumFacing.VALUES) {
BlockPos adjPos = pos.offset(f);
Block block = worldIn.getBlockState(adjPos).getBlock();
if (block.isAir(worldIn, adjPos))
{
// The block is an air block, will lose heat.
if (ventSides.contains(f)) {
adjAirCount += ventEfficiency;
}
else {
adjAirCount ++;
}
}
else if (block instanceof BlockContainer)
{
TileEntity te = worldIn.getTileEntity(adjPos);
if (te instanceof ITileEntityHeated) {
// This adjacent machine can exchange heat
adjacentManagers.add(((ITileEntityHeated) te).getHeatManager());
}
}
}
adjManagers = adjacentManagers.toArray(new HeatManager[adjacentManagers.size()]);
}
示例12: getOutputInventory
import net.minecraft.block.BlockContainer; //導入依賴的package包/類
private IInventory getOutputInventory() throws LuaException {
ForgeDirection outDir = playerInterface.outputSide;
if (outDir == null) {
throw new LuaException("Output Side has not yet been set.");
}
Location blockLoc = new Location(playerInterface.xCoord + outDir.offsetX, playerInterface.yCoord + outDir.offsetY, playerInterface.zCoord + outDir.offsetZ, playerInterface.getWorldObj());
Block block = playerInterface.getWorldObj().getBlock(blockLoc.getRoundedX(), blockLoc.getRoundedY(), blockLoc.getRoundedZ());
if (block instanceof BlockContainer) {
return (IInventory) playerInterface.getWorldObj().getTileEntity(blockLoc.getRoundedX(), blockLoc.getRoundedY(), blockLoc.getRoundedZ());
} else {
throw new LuaException("Invalid Output Inventory.");
}
}
示例13: getInputInventory
import net.minecraft.block.BlockContainer; //導入依賴的package包/類
private IInventory getInputInventory() throws LuaException {
ForgeDirection inDir = playerInterface.inputSide;
if (inDir == null) {
throw new LuaException("Input Side has not yet been set.");
}
Location blockLoc = new Location(playerInterface.xCoord + inDir.offsetX, playerInterface.yCoord + inDir.offsetY, playerInterface.zCoord + inDir.offsetZ, playerInterface.getWorldObj());
Block block = playerInterface.getWorldObj().getBlock(blockLoc.getRoundedX(), blockLoc.getRoundedY(), blockLoc.getRoundedZ());
if (block instanceof BlockContainer) {
return (IInventory) playerInterface.getWorldObj().getTileEntity(blockLoc.getRoundedX(), blockLoc.getRoundedY(), blockLoc.getRoundedZ());
} else {
throw new LuaException("Invalid Input Inventory.");
}
}
示例14: isInventoryOnSide
import net.minecraft.block.BlockContainer; //導入依賴的package包/類
private boolean isInventoryOnSide(ForgeDirection dir) {
if (!worldObj.isAirBlock(xCoord+dir.offsetX, yCoord+dir.offsetY, zCoord+dir.offsetZ)) {
Block block = worldObj.getBlock(xCoord+dir.offsetX, yCoord+dir.offsetY, zCoord+dir.offsetZ);
if (block instanceof BlockContainer || block instanceof IInventory)
return true;
if (block.hasTileEntity(worldObj.getBlockMetadata(xCoord+dir.offsetX, yCoord+dir.offsetY, zCoord+dir.offsetZ))) {
return worldObj.getTileEntity(xCoord+dir.offsetX, yCoord+dir.offsetY, zCoord+dir.offsetZ) instanceof IInventory;
}
}
return false;
}
示例15: getInventoryForSide
import net.minecraft.block.BlockContainer; //導入依賴的package包/類
private IInventory getInventoryForSide(ForgeDirection dir) {
if (!worldObj.isAirBlock(xCoord+dir.offsetX, yCoord+dir.offsetY, zCoord+dir.offsetZ)) {
Block block = worldObj.getBlock(xCoord+dir.offsetX, yCoord+dir.offsetY, zCoord+dir.offsetZ);
if (block instanceof IInventory) {
return (IInventory) block;
}
if (block instanceof BlockContainer && block.hasTileEntity(worldObj.getBlockMetadata(xCoord+dir.offsetX, yCoord+dir.offsetY, zCoord+dir.offsetZ)))
return (IInventory)worldObj.getTileEntity(xCoord+dir.offsetX, yCoord+dir.offsetY, zCoord+dir.offsetZ);
}
return null;
}