本文整理汇总了Java中net.minecraft.util.EnumFacing.getFrontOffsetY方法的典型用法代码示例。如果您正苦于以下问题:Java EnumFacing.getFrontOffsetY方法的具体用法?Java EnumFacing.getFrontOffsetY怎么用?Java EnumFacing.getFrontOffsetY使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraft.util.EnumFacing
的用法示例。
在下文中一共展示了EnumFacing.getFrontOffsetY方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onBlockPlacedBy
import net.minecraft.util.EnumFacing; //导入方法依赖的package包/类
/**
* Called when the block is placed in the world.
*/
@Override
public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase entityLiving, ItemStack iStack) {
super.onBlockPlacedBy(world, pos, state, entityLiving, iStack);
EnumFacing rotation = getRotation(world, pos);
if (rotation.getAxis() == Axis.Y) {
TileEntity te = world.getTileEntity(pos);
if (te instanceof TileEntityAphorismTile) {
TileEntityAphorismTile teAT = (TileEntityAphorismTile) te;
float yaw = entityLiving.rotationYaw; if (yaw < 0) yaw += 360;
teAT.textRotation = (((int) yaw + 45) / 90 + 2) % 4;
if (rotation.getFrontOffsetY() > 0 && (teAT.textRotation == 1 || teAT.textRotation == 3)) {
// fudge - reverse rotation if placing above, and player is facing on east/west axis
teAT.textRotation = 4 - teAT.textRotation;
}
}
}
if (world.isRemote && entityLiving instanceof EntityPlayer) {
((EntityPlayer) entityLiving).openGui(PneumaticCraftRepressurized.instance, EnumGuiId.APHORISM_TILE.ordinal(), world, pos.getX(), pos.getY(), pos.getZ());
sendEditorMessage((EntityPlayer) entityLiving);
}
}
示例2: getBoundingBox
import net.minecraft.util.EnumFacing; //导入方法依赖的package包/类
@Override
public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) {
if (!source.getBlockState(pos).getPropertyKeys().contains(ROTATION)) {
// getBoundingBox() can be called during placement (from World#mayPlace), before the
// block is actually placed; handle this, or we'll crash with an IllegalArgumentException
return FULL_BLOCK_AABB;
}
EnumFacing dir = getRotation(source, pos);
return new AxisAlignedBB(
dir.getFrontOffsetX() <= 0 ? 0 : 1F - BBConstants.HEAT_SINK_THICKNESS,
dir.getFrontOffsetY() <= 0 ? 0 : 1F - BBConstants.HEAT_SINK_THICKNESS,
dir.getFrontOffsetZ() <= 0 ? 0 : 1F - BBConstants.HEAT_SINK_THICKNESS,
dir.getFrontOffsetX() >= 0 ? 1 : BBConstants.HEAT_SINK_THICKNESS,
dir.getFrontOffsetY() >= 0 ? 1 : BBConstants.HEAT_SINK_THICKNESS,
dir.getFrontOffsetZ() >= 0 ? 1 : BBConstants.HEAT_SINK_THICKNESS
);
}
示例3: onBlockActivated
import net.minecraft.util.EnumFacing; //导入方法依赖的package包/类
@Override
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
if (!worldIn.isRemote ) {
if( state.getValue(FRUITING) == 2){
for (ItemStack item : this.getDrops(worldIn, pos, state, 0)) {
worldIn.playSound(null, playerIn.posX, playerIn.posY, playerIn.posZ, SoundEvents.BLOCK_GRASS_BREAK, SoundCategory.NEUTRAL, 0.6F, 0.8F / (worldIn.rand.nextFloat() * 0.4F + 0.8F));
EntityItem entityitem = new EntityItem(worldIn, pos.getX() + 0.5 + facing.getFrontOffsetX() * 0.7, pos.getY() + 0.5 + facing.getFrontOffsetY() * 0.7, pos.getZ() + 0.5 + facing.getFrontOffsetZ() * 0.7, item);
entityitem.motionX *= 0.2;
entityitem.motionY = 0;
entityitem.motionZ *= 0.2;
worldIn.spawnEntity(entityitem);
worldIn.setBlockState(pos, state.withProperty(FRUITING, 0), 2);
}
}
}
return super.onBlockActivated(worldIn, pos, state, playerIn, hand, facing, hitX, hitY, hitZ);
}
示例4: update
import net.minecraft.util.EnumFacing; //导入方法依赖的package包/类
private void update()
{
for (int i = 0; i < 6; ++i)
{
BlockPosM blockposm = this.facings[i];
if (blockposm != null)
{
EnumFacing enumfacing = EnumFacing.VALUES[i];
int j = this.mx + enumfacing.getFrontOffsetX();
int k = this.my + enumfacing.getFrontOffsetY();
int l = this.mz + enumfacing.getFrontOffsetZ();
blockposm.setXyz(j, k, l);
}
}
this.needsUpdate = false;
}
示例5: offset
import net.minecraft.util.EnumFacing; //导入方法依赖的package包/类
/**
* Offset this BlockPos 1 block in the given direction
*/
public BlockPos offset(EnumFacing facing)
{
if (this.level <= 0)
{
return super.offset(facing, 1).toImmutable();
}
else
{
if (this.facings == null)
{
this.facings = new BlockPosM[EnumFacing.VALUES.length];
}
if (this.needsUpdate)
{
this.update();
}
int i = facing.getIndex();
BlockPosM blockposm = this.facings[i];
if (blockposm == null)
{
int j = this.mx + facing.getFrontOffsetX();
int k = this.my + facing.getFrontOffsetY();
int l = this.mz + facing.getFrontOffsetZ();
blockposm = new BlockPosM(j, k, l, this.level - 1);
this.facings[i] = blockposm;
}
return blockposm;
}
}
示例6: getDispensePosition
import net.minecraft.util.EnumFacing; //导入方法依赖的package包/类
/**
* Get the position where the dispenser at the given Coordinates should dispense to.
*/
public static IPosition getDispensePosition(IBlockSource coords)
{
EnumFacing enumfacing = (EnumFacing)coords.getBlockState().getValue(FACING);
double d0 = coords.getX() + 0.7D * (double)enumfacing.getFrontOffsetX();
double d1 = coords.getY() + 0.7D * (double)enumfacing.getFrontOffsetY();
double d2 = coords.getZ() + 0.7D * (double)enumfacing.getFrontOffsetZ();
return new PositionImpl(d0, d1, d2);
}
示例7: translateOffset
import net.minecraft.util.EnumFacing; //导入方法依赖的package包/类
/**
* Offsets the position of pos in the direction of finger and thumb facing by offset amounts, follows the right-hand
* rule for cross products (finger, thumb, palm) @return A new BlockPos offset in the facing directions
*/
protected static BlockPos translateOffset(BlockPos pos, EnumFacing finger, EnumFacing thumb, int palmOffset, int thumbOffset, int fingerOffset)
{
if (finger != thumb && finger != thumb.getOpposite())
{
Vec3i vec3i = new Vec3i(finger.getFrontOffsetX(), finger.getFrontOffsetY(), finger.getFrontOffsetZ());
Vec3i vec3i1 = new Vec3i(thumb.getFrontOffsetX(), thumb.getFrontOffsetY(), thumb.getFrontOffsetZ());
Vec3i vec3i2 = vec3i.crossProduct(vec3i1);
return pos.add(vec3i1.getX() * -thumbOffset + vec3i2.getX() * palmOffset + vec3i.getX() * fingerOffset, vec3i1.getY() * -thumbOffset + vec3i2.getY() * palmOffset + vec3i.getY() * fingerOffset, vec3i1.getZ() * -thumbOffset + vec3i2.getZ() * palmOffset + vec3i.getZ() * fingerOffset);
}
else
{
throw new IllegalArgumentException("Invalid forwards & up combination");
}
}
示例8: dispenseStack
import net.minecraft.util.EnumFacing; //导入方法依赖的package包/类
public ItemStack dispenseStack(IBlockSource source, ItemStack stack)
{
EnumFacing enumfacing = BlockDispenser.getFacing(source.getBlockMetadata());
World world = source.getWorld();
double d0 = source.getX() + (double)enumfacing.getFrontOffsetX() * 1.125D;
double d1 = Math.floor(source.getY()) + (double)enumfacing.getFrontOffsetY();
double d2 = source.getZ() + (double)enumfacing.getFrontOffsetZ() * 1.125D;
BlockPos blockpos = source.getBlockPos().offset(enumfacing);
IBlockState iblockstate = world.getBlockState(blockpos);
BlockRailBase.EnumRailDirection blockrailbase$enumraildirection = iblockstate.getBlock() instanceof BlockRailBase ? (BlockRailBase.EnumRailDirection)iblockstate.getValue(((BlockRailBase)iblockstate.getBlock()).getShapeProperty()) : BlockRailBase.EnumRailDirection.NORTH_SOUTH;
double d3;
if (BlockRailBase.isRailBlock(iblockstate))
{
if (blockrailbase$enumraildirection.isAscending())
{
d3 = 0.6D;
}
else
{
d3 = 0.1D;
}
}
else
{
if (iblockstate.getBlock().getMaterial() != Material.air || !BlockRailBase.isRailBlock(world.getBlockState(blockpos.down())))
{
return this.behaviourDefaultDispenseItem.dispense(source, stack);
}
IBlockState iblockstate1 = world.getBlockState(blockpos.down());
BlockRailBase.EnumRailDirection blockrailbase$enumraildirection1 = iblockstate1.getBlock() instanceof BlockRailBase ? (BlockRailBase.EnumRailDirection)iblockstate1.getValue(((BlockRailBase)iblockstate1.getBlock()).getShapeProperty()) : BlockRailBase.EnumRailDirection.NORTH_SOUTH;
if (enumfacing != EnumFacing.DOWN && blockrailbase$enumraildirection1.isAscending())
{
d3 = -0.4D;
}
else
{
d3 = -0.9D;
}
}
EntityMinecart entityminecart = EntityMinecart.func_180458_a(world, d0, d1 + d3, d2, ((ItemMinecart)stack.getItem()).minecartType);
if (stack.hasDisplayName())
{
entityminecart.setCustomNameTag(stack.getDisplayName());
}
world.spawnEntityInWorld(entityminecart);
stack.splitStack(1);
return stack;
}
示例9: offset
import net.minecraft.util.EnumFacing; //导入方法依赖的package包/类
/**
* Offsets this BlockPos n blocks in the given direction
*/
public BlockPos offset(EnumFacing facing, int n)
{
return n == 0 ? this : new BlockPos(this.getX() + facing.getFrontOffsetX() * n, this.getY() + facing.getFrontOffsetY() * n, this.getZ() + facing.getFrontOffsetZ() * n);
}
示例10: getBoundingBox
import net.minecraft.util.EnumFacing; //导入方法依赖的package包/类
public AxisAlignedBB getBoundingBox(World worldIn, BlockPos pos, IBlockState extendingBlock, float progress, EnumFacing direction)
{
if (extendingBlock.getBlock() != this && extendingBlock.getBlock().getMaterial() != Material.air)
{
AxisAlignedBB axisalignedbb = extendingBlock.getBlock().getCollisionBoundingBox(worldIn, pos, extendingBlock);
if (axisalignedbb == null)
{
return null;
}
else
{
double d0 = axisalignedbb.minX;
double d1 = axisalignedbb.minY;
double d2 = axisalignedbb.minZ;
double d3 = axisalignedbb.maxX;
double d4 = axisalignedbb.maxY;
double d5 = axisalignedbb.maxZ;
if (direction.getFrontOffsetX() < 0)
{
d0 -= (double)((float)direction.getFrontOffsetX() * progress);
}
else
{
d3 -= (double)((float)direction.getFrontOffsetX() * progress);
}
if (direction.getFrontOffsetY() < 0)
{
d1 -= (double)((float)direction.getFrontOffsetY() * progress);
}
else
{
d4 -= (double)((float)direction.getFrontOffsetY() * progress);
}
if (direction.getFrontOffsetZ() < 0)
{
d2 -= (double)((float)direction.getFrontOffsetZ() * progress);
}
else
{
d5 -= (double)((float)direction.getFrontOffsetZ() * progress);
}
return new AxisAlignedBB(d0, d1, d2, d3, d4, d5);
}
}
else
{
return null;
}
}
示例11: moveCollidedEntities
import net.minecraft.util.EnumFacing; //导入方法依赖的package包/类
private void moveCollidedEntities(float p_184322_1_)
{
EnumFacing enumfacing = this.extending ? this.pistonFacing : this.pistonFacing.getOpposite();
double d0 = (double)(p_184322_1_ - this.progress);
List<AxisAlignedBB> list = Lists.<AxisAlignedBB>newArrayList();
this.func_190606_j().addCollisionBoxToList(this.world, BlockPos.ORIGIN, new AxisAlignedBB(BlockPos.ORIGIN), list, (Entity)null, true);
if (!((List)list).isEmpty())
{
AxisAlignedBB axisalignedbb = this.func_190607_a(this.func_191515_a(list));
List<Entity> list1 = this.world.getEntitiesWithinAABBExcludingEntity((Entity)null, this.func_190610_a(axisalignedbb, enumfacing, d0).union(axisalignedbb));
if (!list1.isEmpty())
{
boolean flag = this.pistonState.getBlock() == Blocks.SLIME_BLOCK;
for (int i = 0; i < list1.size(); ++i)
{
Entity entity = (Entity)list1.get(i);
if (entity.getPushReaction() != EnumPushReaction.IGNORE)
{
if (flag)
{
switch (enumfacing.getAxis())
{
case X:
entity.motionX = (double)enumfacing.getFrontOffsetX();
break;
case Y:
entity.motionY = (double)enumfacing.getFrontOffsetY();
break;
case Z:
entity.motionZ = (double)enumfacing.getFrontOffsetZ();
}
}
double d1 = 0.0D;
for (int j = 0; j < ((List)list).size(); ++j)
{
AxisAlignedBB axisalignedbb1 = this.func_190610_a(this.func_190607_a((AxisAlignedBB)list.get(j)), enumfacing, d0);
AxisAlignedBB axisalignedbb2 = entity.getEntityBoundingBox();
if (axisalignedbb1.intersectsWith(axisalignedbb2))
{
d1 = Math.max(d1, this.func_190612_a(axisalignedbb1, enumfacing, axisalignedbb2));
if (d1 >= d0)
{
break;
}
}
}
if (d1 > 0.0D)
{
d1 = Math.min(d1, d0) + 0.01D;
field_190613_i.set(enumfacing);
entity.moveEntity(MoverType.PISTON, d1 * (double)enumfacing.getFrontOffsetX(), d1 * (double)enumfacing.getFrontOffsetY(), d1 * (double)enumfacing.getFrontOffsetZ());
field_190613_i.set((EnumFacing)null);
if (!this.extending && this.shouldHeadBeRendered)
{
this.func_190605_a(entity, enumfacing, d0);
}
}
}
}
}
}
}
示例12: offset
import net.minecraft.util.EnumFacing; //导入方法依赖的package包/类
public BlockPos offset(EnumFacing facing, int n) {
return new BlockPos(getX() + facing.getFrontOffsetX() * n, getY() + facing.getFrontOffsetY() * n, getZ() + facing.getFrontOffsetZ() * n);
}