use of net.minecraft.entity.item.EntityMinecartEmpty in project MineFactoryReloaded by powercrystals.
the class BlockRailPassengerDropoff method onEntityCollidedWithBlock.
@Override
public void onEntityCollidedWithBlock(World world, int x, int y, int z, Entity entity) {
if (world.isRemote || !(entity instanceof EntityMinecartEmpty)) {
return;
}
EntityMinecartEmpty minecart = (EntityMinecartEmpty) entity;
if (minecart.riddenByEntity == null || !(minecart.riddenByEntity instanceof EntityPlayer)) {
return;
}
int[] dropCoords = findSpaceForPlayer(x, y, z, world);
if (dropCoords[1] < 0) {
return;
}
Entity player = minecart.riddenByEntity;
player.mountEntity(minecart);
MineFactoryReloadedCore.proxy.movePlayerToCoordinates((EntityPlayer) player, dropCoords[0] + 0.5, dropCoords[1] + 0.5, dropCoords[2] + 0.5);
}
use of net.minecraft.entity.item.EntityMinecartEmpty in project MineFactoryReloaded by powercrystals.
the class BlockRailPassengerPickup method onEntityCollidedWithBlock.
@Override
public void onEntityCollidedWithBlock(World world, int x, int y, int z, Entity entity) {
if (world.isRemote || !(entity instanceof EntityMinecartEmpty)) {
return;
}
EntityMinecart minecart = (EntityMinecart) entity;
if (minecart.riddenByEntity != null) {
return;
}
AxisAlignedBB bb = AxisAlignedBB.getBoundingBox(x - MFRConfig.passengerRailSearchMaxHorizontal.getInt(), y - MFRConfig.passengerRailSearchMaxVertical.getInt(), z - MFRConfig.passengerRailSearchMaxHorizontal.getInt(), x + MFRConfig.passengerRailSearchMaxHorizontal.getInt() + 1, y + MFRConfig.passengerRailSearchMaxVertical.getInt() + 1, z + MFRConfig.passengerRailSearchMaxHorizontal.getInt() + 1);
@SuppressWarnings("rawtypes") List entities = world.getEntitiesWithinAABB(EntityPlayer.class, bb);
for (Object o : entities) {
if (!(o instanceof EntityPlayer)) {
continue;
}
((EntityPlayer) o).mountEntity(minecart);
return;
}
}
use of net.minecraft.entity.item.EntityMinecartEmpty in project PneumaticCraft by MineMaarten.
the class TileEntityAirCannon method getPayloadEntity.
// warning: no null-check for inventory slot 0
private Entity getPayloadEntity() {
if (getUpgrades(ItemMachineUpgrade.UPGRADE_DISPENSER_DAMAGE, getUpgradeSlots()) > 0) {
Item item = inventory[0].getItem();
if (item == Item.getItemFromBlock(Blocks.tnt)) {
EntityTNTPrimed tnt = new EntityTNTPrimed(worldObj);
tnt.fuse = 80;
return tnt;
} else if (item == Items.experience_bottle)
return new EntityExpBottle(worldObj);
else if (item == Items.potionitem) {
EntityPotion potion = new EntityPotion(worldObj);
potion.setPotionDamage(inventory[0].getItemDamage());
return potion;
} else if (item == Items.arrow)
return new EntityArrow(worldObj);
else if (item == Items.egg)
return new EntityEgg(worldObj);
else // EntitySmallFireball(worldObj);
if (item == Items.snowball)
return new EntitySnowball(worldObj);
else if (item == Items.spawn_egg)
return ItemMonsterPlacer.spawnCreature(worldObj, inventory[0].getItemDamage(), 0, 0, 0);
else if (item == Items.minecart)
return new EntityMinecartEmpty(worldObj);
else if (item == Items.chest_minecart)
return new EntityMinecartChest(worldObj);
else if (item == Items.furnace_minecart)
return new EntityMinecartFurnace(worldObj);
else if (item == Items.hopper_minecart)
return new EntityMinecartHopper(worldObj);
else if (item == Items.tnt_minecart)
return new EntityMinecartTNT(worldObj);
else if (item == Items.boat)
return new EntityBoat(worldObj);
}
EntityItem item = new EntityItem(worldObj);
item.setEntityItemStack(inventory[0].copy());
// 1200 ticks left to live, = 60s.
item.age = 4800;
// add
item.lifespan += Math.min(getUpgrades(ItemMachineUpgrade.UPGRADE_ITEM_LIFE, getUpgradeSlots()) * 600, 4800);
// min.
return item;
}
Aggregations