use of net.minecraft.entity.item.EntityMinecart 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.EntityMinecart in project Trains-In-Motion-1.7.10 by EternalBlueFlame.
the class SignalBlock method determineMyAspect.
private SignalAspect determineMyAspect(WorldCoordinate otherCoord) {
WorldCoordinate myTrack = getTrackLocation();
if (myTrack == null)
return SignalAspect.RED;
WorldCoordinate otherTrack = getOtherTrackLocation(otherCoord);
if (otherTrack == null)
return SignalAspect.YELLOW;
TrackScanner.ScanResult scan = getOrCreateTrackScan(otherTrack);
int y1 = scan.minY;
int y2 = scan.maxY + 1;
int x1 = Math.min(myTrack.x, otherTrack.x);
int z1 = Math.min(myTrack.z, otherTrack.z);
int x2 = Math.max(myTrack.x, otherTrack.x) + 1;
int z2 = Math.max(myTrack.z, otherTrack.z) + 1;
boolean zAxis = Math.abs(myTrack.x - otherTrack.x) < Math.abs(myTrack.z - otherTrack.z);
int xOffset = otherTrack.x > myTrack.x ? -3 : 3;
int zOffset = otherTrack.z > myTrack.z ? -3 : 3;
List<EntityMinecart> carts = CartTools.getMinecartsIn(tile.getWorldObj(), x1, y1, z1, x2, y2, z2);
// System.out.printf("%d, %d, %d, %d, %d, %d\n", i1, j1, k1, i2, j2, k2);
// System.out.println("carts = " + carts.size());
SignalAspect newAspect = SignalAspect.GREEN;
for (EntityMinecart cart : carts) {
int cartX = MathHelper.floor_double(cart.posX);
int cartZ = MathHelper.floor_double(cart.posZ);
if (Math.abs(cart.motionX) < 0.08 && Math.abs(cart.motionZ) < 0.08)
return SignalAspect.RED;
else if (zAxis)
if (cartZ > myTrack.z + zOffset && cart.motionZ < 0)
return SignalAspect.RED;
else if (cartZ < myTrack.z + zOffset && cart.motionZ > 0)
return SignalAspect.RED;
else
newAspect = SignalAspect.YELLOW;
else if (cartX > myTrack.x + xOffset && cart.motionX < 0)
return SignalAspect.RED;
else if (cartX < myTrack.x + xOffset && cart.motionX > 0)
return SignalAspect.RED;
else
newAspect = SignalAspect.YELLOW;
}
return newAspect;
}
use of net.minecraft.entity.item.EntityMinecart in project Trains-In-Motion-1.7.10 by EternalBlueFlame.
the class CartTools method getMinecartsIn.
public static List<EntityMinecart> getMinecartsIn(World world, int i1, int j1, int k1, int i2, int j2, int k2) {
List entities = world.getEntitiesWithinAABB(EntityMinecart.class, AxisAlignedBB.getBoundingBox(i1, j1, k1, i2, j2, k2));
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 Railcraft by Railcraft.
the class TileManipulatorCart method update.
@Override
public final void update() {
super.update();
if (Game.isClient(getWorld()))
return;
upkeep();
if (pause > 0)
pause--;
boolean wasProcessing = isProcessing();
setProcessing(false);
// Find cart to play with
EntityMinecart cart = getCart();
setCurrentCart(cart);
// Wait for reset timer (used by loaders that trickle fill forever)
if (resetTimer > 0)
resetTimer--;
if (resetTimer > 0) {
waitForReset(cart);
return;
}
// We are alone
if (cart == null) {
onNoCart();
return;
}
// We only like some carts
if (!canHandleCart(cart)) {
sendCart(cart);
return;
}
// Time out
if (isPaused())
return;
// Play time!
processCart(cart);
// We did something!
if (isProcessing())
setPowered(false);
else
// Are we done?
trySendCart(cart);
// Tell our twin
if (isProcessing() != wasProcessing)
sendUpdateToClient();
}
use of net.minecraft.entity.item.EntityMinecart in project Railcraft by Railcraft.
the class TrackKitDetector method getComparatorInputOverride.
@Override
public int getComparatorInputOverride() {
if (isEmittingPower()) {
World world = theWorldAsserted();
List<EntityMinecart> carts = EntitySearcher.findMinecarts().inFloorBox(getPos(), 0.2F).at(world);
if (!carts.isEmpty() && carts.get(0).getComparatorLevel() > -1)
return carts.get(0).getComparatorLevel();
List<EntityMinecartCommandBlock> commandCarts = EntitySearcher.find(EntityMinecartCommandBlock.class).inFloorBox(getPos(), 0.2F).with(EntitySelectors.HAS_INVENTORY).at(world);
if (!commandCarts.isEmpty()) {
return commandCarts.get(0).getCommandBlockLogic().getSuccessCount();
}
List<EntityMinecart> chestCarts = EntitySearcher.findMinecarts().inFloorBox(getPos(), 0.2F).andWith(EntitySelectors.HAS_INVENTORY).at(world);
if (!chestCarts.isEmpty()) {
return Container.calcRedstoneFromInventory((IInventory) chestCarts.get(0));
}
}
return 0;
}
Aggregations