use of net.minecraft.entity.item.EntityMinecart in project Railcraft by Railcraft.
the class ItemTunnelBore method onItemUse.
@Override
public EnumActionResult onItemUse(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
IBlockState existingState = WorldPlugin.getBlockState(world, pos);
if (TrackTools.isRailBlock(existingState)) {
if (Game.isHost(world) && !CartToolsAPI.isMinecartAt(world, pos, 0)) {
BlockRailBase.EnumRailDirection trackShape = TrackTools.getTrackDirection(world, pos, existingState);
if (TrackShapeHelper.isLevelStraight(trackShape)) {
EnumFacing playerFacing = MiscTools.getHorizontalSideFacingPlayer(player).getOpposite();
if (trackShape == BlockRailBase.EnumRailDirection.NORTH_SOUTH) {
if (playerFacing == EnumFacing.WEST)
playerFacing = EnumFacing.NORTH;
else if (playerFacing == EnumFacing.EAST)
playerFacing = EnumFacing.SOUTH;
} else if (trackShape == BlockRailBase.EnumRailDirection.EAST_WEST) {
if (playerFacing == EnumFacing.SOUTH)
playerFacing = EnumFacing.EAST;
else if (playerFacing == EnumFacing.NORTH)
playerFacing = EnumFacing.WEST;
}
// System.out.println("PlayerYaw = " + playerYaw + " Yaw = " + facing + " Meta = " + meta);
EntityMinecart bore = new EntityTunnelBore(world, (float) pos.getX() + 0.5F, (float) pos.getY(), (float) pos.getZ() + 0.5F, playerFacing);
CartToolsAPI.setCartOwner(bore, player);
world.spawnEntityInWorld(bore);
}
}
stack.stackSize--;
return EnumActionResult.SUCCESS;
} else {
return EnumActionResult.FAIL;
}
}
use of net.minecraft.entity.item.EntityMinecart in project Trains-In-Motion-1.7.10 by EternalBlueFlame.
the class CartTools method getMinecartsOnAllSides.
public static List<EntityMinecart> getMinecartsOnAllSides(World world, int i, int j, int k, float sensitivity, Class<? extends EntityMinecart> type, boolean subclass) {
List<EntityMinecart> list = new ArrayList<EntityMinecart>();
List<EntityMinecart> carts = new ArrayList<EntityMinecart>();
for (int side = 0; side < 6; side++) {
list.addAll(getMinecartsOnSide(world, i, j, k, sensitivity, ForgeDirection.getOrientation(side)));
}
for (EntityMinecart cart : list) {
if ((subclass && type.isInstance(cart)) || cart.getClass() == type)
carts.add(cart);
}
return carts;
}
use of net.minecraft.entity.item.EntityMinecart in project Trains-In-Motion-1.7.10 by EternalBlueFlame.
the class CartTools method getMinecartsAt.
/**
* @param world
* @param i
* @param j
* @param k
* @param sensitivity Controls the size of the search box, ranges from
* (-inf, 0.49].
* @return
*/
public static List<EntityMinecart> getMinecartsAt(World world, int i, int j, int k, float sensitivity) {
sensitivity = Math.min(sensitivity, 0.49f);
List entities = world.getEntitiesWithinAABB(EntityMinecart.class, AxisAlignedBB.getBoundingBox(i + sensitivity, j + sensitivity, k + sensitivity, i + 1 - sensitivity, j + 1 - sensitivity, k + 1 - sensitivity));
List<EntityMinecart> carts = new ArrayList<EntityMinecart>();
for (Object o : entities) {
EntityMinecart cart = (EntityMinecart) o;
if (!cart.isDead)
carts.add((EntityMinecart) o);
}
return carts;
}
use of net.minecraft.entity.item.EntityMinecart in project ImmersiveEngineering by BluSunrize.
the class EventHandler method onCapabilitiesAttach.
@SubscribeEvent
public void onCapabilitiesAttach(AttachCapabilitiesEvent.Entity event) {
if (event.getEntity() instanceof EntityMinecart) {
EntityMinecart entityMinecart = (EntityMinecart) event.getEntity();
event.addCapability(new ResourceLocation("immersiveengineering:shader"), new ShaderWrapper_Direct("immersiveengineering:minecart"));
}
}
use of net.minecraft.entity.item.EntityMinecart in project ArsMagica2 by Mithion.
the class AMEventHandler method onEntityJump.
@SubscribeEvent
public void onEntityJump(LivingJumpEvent event) {
if (event.entityLiving.isPotionActive(BuffList.agility.id)) {
event.entityLiving.motionY *= 1.5f;
}
if (event.entityLiving.isPotionActive(BuffList.leap.id)) {
Entity velocityTarget = event.entityLiving;
if (event.entityLiving.ridingEntity != null) {
if (event.entityLiving.ridingEntity instanceof EntityMinecart) {
event.entityLiving.ridingEntity.setPosition(event.entityLiving.ridingEntity.posX, event.entityLiving.ridingEntity.posY + 1.5, event.entityLiving.ridingEntity.posZ);
}
velocityTarget = event.entityLiving.ridingEntity;
}
double yVelocity = 0;
double xVelocity = 0;
double zVelocity = 0;
Vec3 vec = event.entityLiving.getLookVec().normalize();
switch(event.entityLiving.getActivePotionEffect(BuffList.leap).getAmplifier() + 1) {
case BuffPowerLevel.Low:
yVelocity = 0.4;
xVelocity = velocityTarget.motionX * 1.08 * Math.abs(vec.xCoord);
zVelocity = velocityTarget.motionZ * 1.08 * Math.abs(vec.zCoord);
break;
case BuffPowerLevel.Medium:
yVelocity = 0.7;
xVelocity = velocityTarget.motionX * 1.25 * Math.abs(vec.xCoord);
zVelocity = velocityTarget.motionZ * 1.25 * Math.abs(vec.zCoord);
break;
case BuffPowerLevel.High:
yVelocity = 1;
xVelocity = velocityTarget.motionX * 1.75 * Math.abs(vec.xCoord);
zVelocity = velocityTarget.motionZ * 1.75 * Math.abs(vec.zCoord);
break;
default:
break;
}
float maxHorizontalVelocity = 1.45f;
if (event.entityLiving.ridingEntity != null && (event.entityLiving.ridingEntity instanceof EntityMinecart || event.entityLiving.ridingEntity instanceof EntityBoat) || event.entityLiving.isPotionActive(BuffList.haste.id)) {
maxHorizontalVelocity += 25;
xVelocity *= 2.5;
zVelocity *= 2.5;
}
if (xVelocity > maxHorizontalVelocity) {
xVelocity = maxHorizontalVelocity;
} else if (xVelocity < -maxHorizontalVelocity) {
xVelocity = -maxHorizontalVelocity;
}
if (zVelocity > maxHorizontalVelocity) {
zVelocity = maxHorizontalVelocity;
} else if (zVelocity < -maxHorizontalVelocity) {
zVelocity = -maxHorizontalVelocity;
}
if (ExtendedProperties.For(event.entityLiving).getIsFlipped()) {
yVelocity *= -1;
}
velocityTarget.addVelocity(xVelocity, yVelocity, zVelocity);
}
if (event.entityLiving.isPotionActive(BuffList.entangled.id)) {
event.entityLiving.motionY = 0;
}
if (event.entityLiving instanceof EntityPlayer) {
ItemStack boots = ((EntityPlayer) event.entityLiving).inventory.armorInventory[0];
if (boots != null && boots.getItem() == ItemsCommonProxy.enderBoots && event.entityLiving.isSneaking()) {
ExtendedProperties.For(event.entityLiving).toggleFlipped();
}
if (ExtendedProperties.For(event.entityLiving).getFlipRotation() > 0)
((EntityPlayer) event.entityLiving).addVelocity(0, -2 * event.entityLiving.motionY, 0);
}
}
Aggregations