Java Code Examples for net.minecraft.util.EnumFacing#getFrontOffsetY()
The following examples show how to use
net.minecraft.util.EnumFacing#getFrontOffsetY() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RecipeLogicSteam.java From GregTech with GNU Lesser General Public License v3.0 | 6 votes |
protected void tryDoVenting() { BlockPos machinePos = metaTileEntity.getPos(); EnumFacing ventingSide = getVentingSide(); BlockPos ventingBlockPos = machinePos.offset(ventingSide); IBlockState blockOnPos = metaTileEntity.getWorld().getBlockState(ventingBlockPos); if (blockOnPos.getCollisionBoundingBox(metaTileEntity.getWorld(), ventingBlockPos) == Block.NULL_AABB) { metaTileEntity.getWorld() .getEntitiesWithinAABB(EntityLivingBase.class, new AxisAlignedBB(ventingBlockPos), EntitySelectors.CAN_AI_TARGET) .forEach(entity -> entity.attackEntityFrom(DamageSources.getHeatDamage(), 6.0f)); WorldServer world = (WorldServer) metaTileEntity.getWorld(); double posX = machinePos.getX() + 0.5 + ventingSide.getFrontOffsetX() * 0.6; double posY = machinePos.getY() + 0.5 + ventingSide.getFrontOffsetY() * 0.6; double posZ = machinePos.getZ() + 0.5 + ventingSide.getFrontOffsetZ() * 0.6; world.spawnParticle(EnumParticleTypes.SMOKE_LARGE, posX, posY, posZ, 7 + world.rand.nextInt(3), ventingSide.getFrontOffsetX() / 2.0, ventingSide.getFrontOffsetY() / 2.0, ventingSide.getFrontOffsetZ() / 2.0, 0.1); world.playSound(null, posX, posY, posZ, SoundEvents.BLOCK_LAVA_EXTINGUISH, SoundCategory.BLOCKS, 1.0f, 1.0f); setNeedsVenting(false); } else if (!ventingStuck) { setVentingStuck(true); } }
Example 2
Source File: DispenserBehaviorFireball.java From Artifacts with MIT License | 6 votes |
/** * Dispense the specified stack, play the dispense sound and spawn particles. */ public ItemStack dispenseStack(IBlockSource par1IBlockSource, ItemStack par2ItemStack) { EnumFacing enumfacing = BlockTrap.getFacing(par1IBlockSource.getBlockMetadata()); IPosition iposition = BlockTrap.getIPositionFromBlockSource(par1IBlockSource); double d0 = iposition.getX() + (double)((float)enumfacing.getFrontOffsetX() * 0.3F); double d1 = iposition.getY() + (double)((float)enumfacing.getFrontOffsetX() * 0.3F); double d2 = iposition.getZ() + (double)((float)enumfacing.getFrontOffsetZ() * 0.3F); World world = par1IBlockSource.getWorld(); Random random = world.rand; double d3 = random.nextGaussian() * 0.05D + (double)enumfacing.getFrontOffsetX(); double d4 = random.nextGaussian() * 0.05D + (double)enumfacing.getFrontOffsetY(); double d5 = random.nextGaussian() * 0.05D + (double)enumfacing.getFrontOffsetZ(); world.spawnEntityInWorld(new EntitySmallFireball(world, d0, d1, d2, d3, d4, d5)); par2ItemStack.splitStack(1); return par2ItemStack; }
Example 3
Source File: DispenserBehaviorMobEgg.java From Artifacts with MIT License | 6 votes |
/** * Dispense the specified stack, play the dispense sound and spawn particles. */ public ItemStack dispenseStack(IBlockSource par1IBlockSource, ItemStack par2ItemStack) { EnumFacing enumfacing = BlockDispenser.func_149937_b/*getFacing*/(par1IBlockSource.getBlockMetadata()); double d0 = par1IBlockSource.getX() + (double)enumfacing.getFrontOffsetX(); double d1 = (double)((float)par1IBlockSource.getYInt() + 0.2F) + enumfacing.getFrontOffsetY(); double d2 = par1IBlockSource.getZ() + (double)enumfacing.getFrontOffsetZ(); Entity entity = ItemMonsterPlacer.spawnCreature(par1IBlockSource.getWorld(), par2ItemStack.getItemDamage(), d0, d1, d2); if (entity instanceof EntityLiving && par2ItemStack.hasDisplayName()) { ((EntityLiving)entity).setCustomNameTag(par2ItemStack.getDisplayName()); } par2ItemStack.splitStack(1); return par2ItemStack; }
Example 4
Source File: ShapeModelGenerator.java From GregTech with GNU Lesser General Public License v3.0 | 5 votes |
public static CCModel[] generateRotatedVariants(CCModel originalModel) { CCModel[] result = new CCModel[6]; double modelHeight = originalModel.verts[2].vec.y; double translate = 1.0 - modelHeight; for (int i = 0; i < 3; i++) { EnumFacing side = EnumFacing.VALUES[i * 2 + 1]; Transformation rotation = Rotation.sideRotations[i * 2].at(Vector3.center); Transformation translation = new Translation(side.getFrontOffsetX() * translate, side.getFrontOffsetY() * translate, side.getFrontOffsetZ() * translate); CCModel negativeModel = originalModel.copy().apply(rotation); CCModel positiveModel = negativeModel.copy().apply(translation); result[i * 2] = negativeModel; result[i * 2 + 1] = positiveModel; } return result; }
Example 5
Source File: ItemPLTreetap.java From Production-Line with MIT License | 5 votes |
private static void ejectResin(World world, BlockPos pos, EnumFacing side, int quantity) { double ejectBias = 0.3D; double ejectX = (double) pos.getX() + 0.5D + (double) side.getFrontOffsetX() * 0.3D; double ejectY = (double) pos.getY() + 0.5D + (double) side.getFrontOffsetY() * 0.3D; double ejectZ = (double) pos.getZ() + 0.5D + (double) side.getFrontOffsetZ() * 0.3D; for (int i = 0; i < quantity; ++i) { EntityItem entityitem = new EntityItem(world, ejectX, ejectY, ejectZ, ItemName.misc_resource.getItemStack(MiscResourceType.resin)); entityitem.setDefaultPickupDelay(); world.spawnEntity(entityitem); } }
Example 6
Source File: BlockPressurizedFluidTank.java From AdvancedRocketry with MIT License | 5 votes |
@Override public boolean shouldSideBeRendered(IBlockState blockState, IBlockAccess blockAccess, BlockPos pos, EnumFacing side) { if(side.getFrontOffsetY() != 0) { if(blockAccess.getBlockState(pos).getBlock() == this) return true; } return super.shouldSideBeRendered(blockState, blockAccess, pos, side); }
Example 7
Source File: StorageChunk.java From AdvancedRocketry with MIT License | 5 votes |
@Override public boolean isSideSolid(BlockPos pos, EnumFacing side, boolean _default) { int x = pos.getX(); int y = pos.getY(); int z = pos.getZ(); if(x < 0 || x >= sizeX || y < 0 || y >= sizeY || z < 0 || z >= sizeZ || x + side.getFrontOffsetX() < 0 || x + side.getFrontOffsetX() >= sizeX || y + side.getFrontOffsetY() < 0 || y + side.getFrontOffsetY() >= sizeY || z + side.getFrontOffsetZ() < 0 || z + side.getFrontOffsetZ() >= sizeZ) return false; return blocks[x + side.getFrontOffsetX()][y + side.getFrontOffsetY()][z + side.getFrontOffsetZ()].isSideSolid(blocks[x + side.getFrontOffsetX()][y + side.getFrontOffsetY()][z + side.getFrontOffsetZ()].getStateFromMeta(metas[x + side.getFrontOffsetX()][y + side.getFrontOffsetY()][z + side.getFrontOffsetZ()]), this, pos.offset(side), side.getOpposite()); }
Example 8
Source File: GeometryUtils.java From OpenModsLib with MIT License | 5 votes |
private Octant(String friendlyName, EnumFacing dirX, EnumFacing dirY, EnumFacing dirZ) { this.x = dirX.getFrontOffsetX() + dirY.getFrontOffsetX() + dirZ.getFrontOffsetX(); this.y = dirX.getFrontOffsetY() + dirY.getFrontOffsetY() + dirZ.getFrontOffsetY(); this.z = dirX.getFrontOffsetZ() + dirY.getFrontOffsetZ() + dirZ.getFrontOffsetZ(); this.dirs = EnumSet.of(dirX, dirY, dirZ); this.name = friendlyName; }
Example 9
Source File: BlockMEDropper.java From ExtraCells1 with MIT License | 5 votes |
public static IPosition getIPositionFromBlockSource(IBlockSource par0IBlockSource) { EnumFacing enumfacing = getFacing(par0IBlockSource.getBlockMetadata()); double d0 = par0IBlockSource.getX() + 0.7D * enumfacing.getFrontOffsetX(); double d1 = par0IBlockSource.getY() + 0.7D * enumfacing.getFrontOffsetY(); double d2 = par0IBlockSource.getZ() + 0.7D * enumfacing.getFrontOffsetZ(); return new PositionImpl(d0, d1, d2); }
Example 10
Source File: BlockTrap.java From Artifacts with MIT License | 5 votes |
public static IPosition getIPositionFromBlockSource(IBlockSource par0IBlockSource) { EnumFacing enumfacing = getFacing(par0IBlockSource.getBlockMetadata()); double d0 = par0IBlockSource.getX() + 0.7D * (double)enumfacing.getFrontOffsetX(); double d1 = par0IBlockSource.getY() + 0.7D * (double)enumfacing.getFrontOffsetY(); double d2 = par0IBlockSource.getZ() + 0.7D * (double)enumfacing.getFrontOffsetZ(); return new PositionImpl(d0, d1, d2); }
Example 11
Source File: BlockTeleportRail.java From Signals with GNU General Public License v3.0 | 4 votes |
private void teleport(EntityMinecart cart, MCPos destination){ if(cart instanceof EntityMinecartContainer) { ((EntityMinecartContainer)cart).dropContentsWhenDead = false; } int dimensionIn = destination.getDimID(); BlockPos destPos = destination.getPos(); if(!ForgeHooks.onTravelToDimension(cart, destination.getDimID())) return; MinecraftServer minecraftserver = cart.getServer(); int i = cart.dimension; WorldServer worldserver = minecraftserver.getWorld(i); WorldServer worldserver1 = minecraftserver.getWorld(dimensionIn); cart.dimension = dimensionIn; /*if (i == 1 && dimensionIn == 1) { worldserver1 = minecraftserver.getWorld(0); this.dimension = 0; }*/ cart.world.removeEntity(cart); cart.isDead = false; BlockPos blockpos = destination.getPos(); /* double moveFactor = worldserver.provider.getMovementFactor() / worldserver1.provider.getMovementFactor(); double d0 = MathHelper.clamp(this.posX * moveFactor, worldserver1.getWorldBorder().minX() + 16.0D, worldserver1.getWorldBorder().maxX() - 16.0D); double d1 = MathHelper.clamp(this.posZ * moveFactor, worldserver1.getWorldBorder().minZ() + 16.0D, worldserver1.getWorldBorder().maxZ() - 16.0D); double d2 = 8.0D;*/ cart.moveToBlockPosAndAngles(destPos, 90.0F, 0.0F); /*Teleporter teleporter = worldserver1.getDefaultTeleporter(); teleporter.placeInExistingPortal(this, f); blockpos = new BlockPos(this);*/ worldserver.updateEntityWithOptionalForce(cart, false); Entity entity = EntityList.newEntity(cart.getClass(), worldserver1); if(entity != null) { copyDataFromOld(entity, cart); entity.moveToBlockPosAndAngles(blockpos, entity.rotationYaw, entity.rotationPitch); IBlockState state = destination.getLoadedBlockState(); if(state.getBlock() == ModBlocks.TELEPORT_RAIL) { //If the destination is a teleport track, use its rail direction to push the cart the right direction EnumFacing teleportDir = getTeleportDirection(state); double speed = 0.2; entity.motionX = teleportDir.getFrontOffsetX() * speed; entity.motionY = teleportDir.getFrontOffsetY() * speed; entity.motionZ = teleportDir.getFrontOffsetZ() * speed; } else { entity.motionX = entity.motionY = entity.motionZ = 0; } boolean flag = entity.forceSpawn; entity.forceSpawn = true; worldserver1.spawnEntity(entity); entity.forceSpawn = flag; worldserver1.updateEntityWithOptionalForce(entity, false); } cart.isDead = true; worldserver.resetUpdateEntityTick(); worldserver1.resetUpdateEntityTick(); }
Example 12
Source File: BlockPos.java From Et-Futurum with The Unlicense | 4 votes |
public BlockPos offset(EnumFacing facing, int n) { return new BlockPos(getX() + facing.getFrontOffsetX() * n, getY() + facing.getFrontOffsetY() * n, getZ() + facing.getFrontOffsetZ() * n); }
Example 13
Source File: MBlockPos.java From LunatriusCore with MIT License | 4 votes |
@Override public MBlockPos offset(final EnumFacing facing, final int n) { return new MBlockPos(this.x + facing.getFrontOffsetX() * n, this.y + facing.getFrontOffsetY() * n, this.z + facing.getFrontOffsetZ() * n); }