use of net.minecraft.entity.item.EntityMinecart in project Railcraft by Railcraft.
the class CartTools method getMinecartUUIDsAt.
public static List<UUID> getMinecartUUIDsAt(World world, int i, int j, int k, float sensitivity) {
sensitivity = Math.min(sensitivity, 0.49f);
List<EntityMinecart> entities = world.getEntitiesWithinAABB(EntityMinecart.class, new AxisAlignedBB(i + sensitivity, j + sensitivity, k + sensitivity, i + 1 - sensitivity, j + 1 - sensitivity, k + 1 - sensitivity));
return entities.stream().filter(cart -> !cart.isDead).map(Entity::getPersistentID).collect(Collectors.toList());
}
use of net.minecraft.entity.item.EntityMinecart in project Railcraft by Railcraft.
the class EntityLocomotive method canLinkWithCart.
@Override
public boolean canLinkWithCart(EntityMinecart cart) {
if (isExemptFromLinkLimits(cart))
return true;
LinkageManager lm = LinkageManager.instance();
EntityMinecart linkA = lm.getLinkedCartA(this);
if (linkA != null && !isExemptFromLinkLimits(linkA))
return false;
EntityMinecart linkB = lm.getLinkedCartB(this);
return linkB == null || isExemptFromLinkLimits(linkB);
}
use of net.minecraft.entity.item.EntityMinecart in project Railcraft by Railcraft.
the class ItemMagnifyingGlass method onEntityInteract.
@SubscribeEvent
public void onEntityInteract(PlayerInteractEvent.EntityInteract event) {
EntityPlayer thePlayer = event.getEntityPlayer();
Entity entity = event.getTarget();
ItemStack stack = event.getItemStack();
if (stack != null && stack.getItem() instanceof ItemMagnifyingGlass)
thePlayer.swingArm(event.getHand());
if (Game.isClient(thePlayer.worldObj))
return;
if (stack != null && stack.getItem() instanceof ItemMagnifyingGlass)
if (entity instanceof EntityMinecart) {
EntityMinecart cart = (EntityMinecart) entity;
ChatPlugin.sendLocalizedChatFromServer(thePlayer, "gui.railcraft.mag.glass.placedby", LocalizationPlugin.getEntityLocalizationTag(cart), CartToolsAPI.getCartOwner(cart));
event.setCanceled(true);
}
}
use of net.minecraft.entity.item.EntityMinecart in project NyaSamaRailway by NSDN.
the class BlockRailReception method onRailPowered.
@Override
public void onRailPowered(World world, int x, int y, int z, int meta, boolean hasCart) {
boolean playerDetectable = false;
if (!checkNearbySameRail(world, x, y, z))
playerDetectable = true;
if (playerDetectable) {
TileEntityRailReception rail = null;
if (world.getTileEntity(x, y, z) instanceof TileEntityRailReception) {
rail = (TileEntityRailReception) world.getTileEntity(x, y, z);
}
if (rail != null) {
if (!rail.cartType.isEmpty() && !world.isRemote) {
if (rail.cartType.equals("loco")) {
return;
}
if (!hasCart && (isRailPowered(world, x + 1, y, z) || isRailPowered(world, x, y, z - 1))) {
spawnCart(world, x, y, z);
rail.delay = 0;
rail.enable = false;
}
if (hasCart && (isRailPowered(world, x - 1, y, z) || isRailPowered(world, x, y, z + 1))) {
EntityMinecart cart = getMinecart(world, x, y, z);
if (cart == null)
return;
cart.killMinecart(new DamageSource("nsr"));
}
}
}
}
}
use of net.minecraft.entity.item.EntityMinecart in project NyaSamaRailway by NSDN.
the class BlockRailReception method spawnCart.
public void spawnCart(World world, int x, int y, int z) {
TileEntityRailReception rail = null;
if (world.getTileEntity(x, y, z) instanceof TileEntityRailReception) {
rail = (TileEntityRailReception) world.getTileEntity(x, y, z);
}
if (rail != null) {
if (rail.cartType.isEmpty())
return;
if (rail.cartType.equals("loco"))
return;
if (rail.cartType.equals(NSTCT1.class.getName())) {
MinecartBase cart = new NSTCT1(world, (double) x + 0.5, (double) y + 0.5, (double) z + 0.5);
world.spawnEntityInWorld(cart);
} else if (rail.cartType.equals(NSBT1.class.getName())) {
MinecartBase cart = new NSBT1(world, (double) x + 0.5, (double) y + 0.5, (double) z + 0.5);
world.spawnEntityInWorld(cart);
} else if (rail.cartType.equals(NSPCT1.class.getName())) {
MinecartBase cart = new NSPCT1(world, (double) x + 0.5, (double) y + 0.5, (double) z + 0.5);
world.spawnEntityInWorld(cart);
} else if (rail.cartType.equals(NSPCT2.class.getName())) {
MinecartBase cart = new NSPCT2(world, (double) x + 0.5, (double) y + 0.5, (double) z + 0.5);
world.spawnEntityInWorld(cart);
} else if (rail.cartType.equals(NSPCT3.class.getName())) {
MinecartBase cart = new NSPCT3(world, (double) x + 0.5, (double) y + 0.5, (double) z + 0.5);
world.spawnEntityInWorld(cart);
} else if (rail.cartType.equals(NSPCT5L.class.getName())) {
MinecartBase cart = new NSPCT5L(world, (double) x + 0.5, (double) y + 0.5, (double) z + 0.5);
world.spawnEntityInWorld(cart);
} else if (rail.cartType.equals(NSPCT6.class.getName())) {
MinecartBase cart = new NSPCT6(world, (double) x + 0.5, (double) y + 0.5, (double) z + 0.5);
world.spawnEntityInWorld(cart);
} else if (rail.cartType.equals(NSPCT8.class.getName())) {
MinecartBase cart = new NSPCT8(world, (double) x + 0.5, (double) y + 0.5, (double) z + 0.5);
world.spawnEntityInWorld(cart);
} else if (rail.cartType.equals(NSPCT9.class.getName())) {
NSPCT9 cart = new NSPCT9(world, (double) x + 0.5, (double) y + 0.5, (double) z + 0.5);
cart.setExtendedInfo(rail.extInfo);
world.spawnEntityInWorld(cart);
} else {
EntityMinecart cart = EntityMinecartEmpty.createMinecart(world, (double) x + 0.5, (double) y + 0.5, (double) z + 0.5, -1);
world.spawnEntityInWorld(cart);
}
}
}
Aggregations