本文整理汇总了Java中net.minecraftforge.common.util.ForgeDirection类的典型用法代码示例。如果您正苦于以下问题:Java ForgeDirection类的具体用法?Java ForgeDirection怎么用?Java ForgeDirection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ForgeDirection类属于net.minecraftforge.common.util包,在下文中一共展示了ForgeDirection类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: canPlantStay
import net.minecraftforge.common.util.ForgeDirection; //导入依赖的package包/类
public static boolean canPlantStay(World world, int x, int y, int z) {
Block block = world.getBlock(x, y - 1, z);
if (block != ModBlocks.chorus_plant && block != Blocks.end_stone) {
if (block.isAir(world, x, y - 1, z)) {
int adjecentCount = 0;
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
Block adjecentBlock = world.getBlock(x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ);
if (adjecentBlock == ModBlocks.chorus_plant)
adjecentCount++;
else if (!adjecentBlock.isAir(world, x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ))
return false;
}
return adjecentCount == 1;
} else
return false;
} else
return true;
}
示例2: updateTick
import net.minecraftforge.common.util.ForgeDirection; //导入依赖的package包/类
@Override
public void updateTick(World world, int x, int y, int z, Random rand) {
if (world.isRemote)
return;
int surroundingBlockCount = 0;
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
Block block = world.getBlock(x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ);
if (block == this || block == Blocks.ice || block == Blocks.packed_ice)
if (++surroundingBlockCount >= 4)
break;
}
if (surroundingBlockCount < 4 || rand.nextInt(100) <= 33) {
int meta = world.getBlockMetadata(x, y, z);
if (meta < 3)
world.setBlockMetadataWithNotify(x, y, z, meta + 1, 2);
else
world.setBlock(x, y, z, Blocks.water);
}
world.scheduleBlockUpdate(x, y, z, this, 40 + rand.nextInt(40));
}
示例3: refresh
import net.minecraftforge.common.util.ForgeDirection; //导入依赖的package包/类
@Override
public void refresh()
{
if (!this.worldObj.isRemote)
{
this.adjacentConnections = null;
for (ForgeDirection side : ForgeDirection.VALID_DIRECTIONS)
{
TileEntity tileEntity = new BlockVec3(this).getTileEntityOnSide(this.worldObj, side);
if (tileEntity != null)
{
if (tileEntity.getClass() == this.getClass() && tileEntity instanceof INetworkProvider && !this.getNetwork().equals(((INetworkProvider) tileEntity).getNetwork()))
{
this.setNetwork((IGridNetwork) this.getNetwork().merge(((INetworkProvider) tileEntity).getNetwork()));
}
}
}
this.getNetwork().refresh();
}
}
示例4: joinLeft
import net.minecraftforge.common.util.ForgeDirection; //导入依赖的package包/类
private void joinLeft()
{
int meta = this.getBlockMetadata();
int side = this.getLeft(meta);
BlockVec3 vec = new BlockVec3(this);
for (int z = -this.connectionsUp; z <= this.connectionsDown; z++)
{
TileEntity tile;
BlockVec3 newVec = vec.clone().modifyPositionFromSide(ForgeDirection.DOWN, z);
if (z == 0) tile = this;
else
{
tile = newVec.getTileEntity(this.worldObj);
}
if (tile instanceof TileEntityScreen && tile.getBlockMetadata() == meta && !tile.isInvalid())
{
TileEntityScreen screenTile = (TileEntityScreen)tile;
screenTile.connectedLeft = true;
TileEntity te2 = newVec.getTileEntityOnSide(this.worldObj, side);
if (te2 instanceof TileEntityScreen && te2.getBlockMetadata() == meta && !te2.isInvalid())
{
screenTile.tryConnectLeft((TileEntityScreen) te2);
}
}
}
}
示例5: acceptsEnergyFrom
import net.minecraftforge.common.util.ForgeDirection; //导入依赖的package包/类
@RuntimeInterface(clazz = "ic2.api.energy.tile.IEnergyAcceptor", modID = "IC2")
public boolean acceptsEnergyFrom(TileEntity emitter, ForgeDirection direction)
{
//Don't add connection to IC2 grid if it's a Galacticraft tile
if (emitter instanceof IElectrical || emitter instanceof IConductor)
{
return false;
}
try
{
Class<?> energyTile = Class.forName("ic2.api.energy.tile.IEnergyTile");
if (!energyTile.isInstance(emitter))
{
return false;
}
}
catch (Exception e)
{
e.printStackTrace();
}
return this.getElectricalInputDirections().contains(direction);
}
示例6: ChunkProviderMars
import net.minecraftforge.common.util.ForgeDirection; //导入依赖的package包/类
public ChunkProviderMars(World par1World, long seed, boolean mapFeaturesEnabled)
{
super(par1World, seed, mapFeaturesEnabled);
this.dungeonGenerator.otherRooms.add(new RoomEmptyMars(null, 0, 0, 0, ForgeDirection.UNKNOWN));
this.dungeonGenerator.otherRooms.add(new RoomSpawnerMars(null, 0, 0, 0, ForgeDirection.UNKNOWN));
this.dungeonGenerator.otherRooms.add(new RoomSpawnerMars(null, 0, 0, 0, ForgeDirection.UNKNOWN));
this.dungeonGenerator.otherRooms.add(new RoomSpawnerMars(null, 0, 0, 0, ForgeDirection.UNKNOWN));
this.dungeonGenerator.otherRooms.add(new RoomSpawnerMars(null, 0, 0, 0, ForgeDirection.UNKNOWN));
this.dungeonGenerator.otherRooms.add(new RoomSpawnerMars(null, 0, 0, 0, ForgeDirection.UNKNOWN));
this.dungeonGenerator.otherRooms.add(new RoomSpawnerMars(null, 0, 0, 0, ForgeDirection.UNKNOWN));
this.dungeonGenerator.otherRooms.add(new RoomSpawnerMars(null, 0, 0, 0, ForgeDirection.UNKNOWN));
this.dungeonGenerator.otherRooms.add(new RoomSpawnerMars(null, 0, 0, 0, ForgeDirection.UNKNOWN));
this.dungeonGenerator.otherRooms.add(new RoomChestsMars(null, 0, 0, 0, ForgeDirection.UNKNOWN));
this.dungeonGenerator.otherRooms.add(new RoomChestsMars(null, 0, 0, 0, ForgeDirection.UNKNOWN));
this.dungeonGenerator.bossRooms.add(new RoomBossMars(null, 0, 0, 0, ForgeDirection.UNKNOWN));
this.dungeonGenerator.treasureRooms.add(new RoomTreasureMars(null, 0, 0, 0, ForgeDirection.UNKNOWN));
}
示例7: getIcon
import net.minecraftforge.common.util.ForgeDirection; //导入依赖的package包/类
@Override
public IIcon getIcon(int side, int metadata)
{
if (side == 0 || side == 1)
{
return this.iconMachineSide;
}
else if (side == metadata + 2)
{
return this.iconOutput;
}
else if (side == ForgeDirection.getOrientation(metadata + 2).getOpposite().ordinal())
{
return this.iconInput;
}
else
{
return this.iconDistributor;
}
}
示例8: drain
import net.minecraftforge.common.util.ForgeDirection; //导入依赖的package包/类
@Override
public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain)
{
int metaside = this.getBlockMetadata() + 2;
int side = from.ordinal();
if (side == (metaside ^ 1))
{
return this.liquidTank2.drain(maxDrain, doDrain);
}
//2->5 3->4 4->2 5->3
if (7 - (metaside ^ (metaside > 3 ? 0 : 1)) == (side ^ 1))
{
return this.liquidTank.drain(maxDrain, doDrain);
}
return null;
}
示例9: getIconIndex
import net.minecraftforge.common.util.ForgeDirection; //导入依赖的package包/类
@Override
public int getIconIndex(ForgeDirection direction) {
switch (direction) {
case UNKNOWN:
return ModPipeIconProvider.TYPE.PipeFluidsBlueSteel_Center.ordinal();
case DOWN:
return ModPipeIconProvider.TYPE.PipeFluidsBlueSteel_Down.ordinal();
case UP:
return ModPipeIconProvider.TYPE.PipeFluidsBlueSteel_Up.ordinal();
case NORTH:
return ModPipeIconProvider.TYPE.PipeFluidsBlueSteel_North.ordinal();
case SOUTH:
return ModPipeIconProvider.TYPE.PipeFluidsBlueSteel_South.ordinal();
case WEST:
return ModPipeIconProvider.TYPE.PipeFluidsBlueSteel_West.ordinal();
case EAST:
return ModPipeIconProvider.TYPE.PipeFluidsBlueSteel_East.ordinal();
default:
throw new IllegalArgumentException("direction out of bounds");
}
}
示例10: fill
import net.minecraftforge.common.util.ForgeDirection; //导入依赖的package包/类
public int fill(final ForgeDirection from, final FluidStack resource, final boolean doFill) {
if (this.sided && from.ordinal() > 1) {
return 0;
}
final boolean t2 = this.tank.getFluid() == null;
final int t3 = this.tank.fill(resource, doFill);
if (doFill) {
if (t2 && this.tank.getFluid() != null && !this.tank.getFluid().isFluidEqual(this.prevFluid)) {
this.prevFluid = this.tank.getFluid().copy();
this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord);
}
if (t3 != 0) {
this.recentlyFilled = true;
this.markDirty();
}
}
return t3;
}
示例11: limitTransfer
import net.minecraftforge.common.util.ForgeDirection; //导入依赖的package包/类
@Override
public int limitTransfer(final TileEntity dest, final ForgeDirection side, final INodeBuffer buffer) {
if (buffer.getBuffer() instanceof ItemStack && dest instanceof IInventory) {
final ItemStack item = (ItemStack)buffer.getBuffer();
final IInventory inv = TNHelper.getInventory(dest);
boolean empty = true;
for (final int i : InvHelper.getSlots(inv, side.ordinal())) {
if (inv.getStackInSlot(i) != null) {
empty = false;
if (InvHelper.sameMod(inv.getStackInSlot(i), item)) {
return -1;
}
}
}
return empty ? -1 : 0;
}
return -1;
}
示例12: onItemUse
import net.minecraftforge.common.util.ForgeDirection; //导入依赖的package包/类
/**
* Callback for item usage. If the item does something special on right clicking, he will have one of those. Return
* True if something happen and false if it don't. This is for ITEMS, not BLOCKS
*/
public boolean onItemUse(ItemStack p_77648_1_, EntityPlayer p_77648_2_, World p_77648_3_, int p_77648_4_, int p_77648_5_, int p_77648_6_, int p_77648_7_, float p_77648_8_, float p_77648_9_, float p_77648_10_)
{
if (p_77648_7_ != 1)
{
return false;
}
else if (p_77648_2_.canPlayerEdit(p_77648_4_, p_77648_5_, p_77648_6_, p_77648_7_, p_77648_1_) && p_77648_2_.canPlayerEdit(p_77648_4_, p_77648_5_ + 1, p_77648_6_, p_77648_7_, p_77648_1_))
{
if (p_77648_3_.getBlock(p_77648_4_, p_77648_5_, p_77648_6_).canSustainPlant(p_77648_3_, p_77648_4_, p_77648_5_, p_77648_6_, ForgeDirection.UP, this) && p_77648_3_.isAirBlock(p_77648_4_, p_77648_5_ + 1, p_77648_6_))
{
p_77648_3_.setBlock(p_77648_4_, p_77648_5_ + 1, p_77648_6_, this.field_150925_a);
--p_77648_1_.stackSize;
return true;
}
else
{
return false;
}
}
else
{
return false;
}
}
示例13: canConnectRedstone
import net.minecraftforge.common.util.ForgeDirection; //导入依赖的package包/类
@Override
public boolean canConnectRedstone(IBlockAccess world, int x, int y, int z, int side)
{
TileEntity te = world.getTileEntity(x, y, z);
ForgeDirection fd;
switch (side)
{
case -1: fd = ForgeDirection.UP; break;
case 0: fd = ForgeDirection.NORTH; break;
case 1: fd = ForgeDirection.EAST; break;
case 2: fd = ForgeDirection.SOUTH; break;
case 3: fd = ForgeDirection.WEST; break;
default: fd = ForgeDirection.UNKNOWN; break;
}
return te instanceof TileEntityTransistor && ((TileEntityTransistor)te).canConnectRedstone(fd);
}
示例14: generateChorusPlant
import net.minecraftforge.common.util.ForgeDirection; //导入依赖的package包/类
public static void generateChorusPlant(World world, int x, int y, int z, int pass) {
int height;
for (height = 0; height < 4; height++) {
if (!ChorusFlower.canPlantStay(world, x, y + height, z)) {
world.setBlock(x, y + height, z, ModBlocks.chorus_flower, 5, 2);
break;
}
world.setBlock(x, y + height, z, ModBlocks.chorus_plant);
}
if (height > 1) {
world.setBlock(x, y + height, z, ModBlocks.chorus_plant);
boolean grew = false;
if (pass < 5) {
ForgeDirection[] dirs = new ForgeDirection[] { ForgeDirection.EAST, ForgeDirection.WEST, ForgeDirection.NORTH, ForgeDirection.SOUTH };
for (int j = 0; j < world.rand.nextInt(4); j++) {
ForgeDirection dir = dirs[world.rand.nextInt(dirs.length)];
int xx = x + dir.offsetX;
int yy = y + height + dir.offsetY;
int zz = z + dir.offsetZ;
if (world.isAirBlock(xx, yy, zz) && ChorusFlower.isSpaceAroundFree(world, xx, yy, zz, dir.getOpposite())) {
generateChorusPlant(world, xx, yy, zz, pass + 1);
grew = true;
}
}
}
if (!grew)
world.setBlock(x, y + height, z, ModBlocks.chorus_flower, 5, 2);
}
}
示例15: isSpaceAroundFree
import net.minecraftforge.common.util.ForgeDirection; //导入依赖的package包/类
public static boolean isSpaceAroundFree(World world, int x, int y, int z, ForgeDirection skip) {
Iterator<ForgeDirection> iterator = Arrays.asList(ForgeDirection.VALID_DIRECTIONS).iterator();
ForgeDirection dir;
do {
if (!iterator.hasNext())
return true;
dir = iterator.next();
} while (dir == skip || world.isAirBlock(x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ));
return false;
}