use of net.minecraft.entity.item.EntityMinecart in project Railcraft by Railcraft.
the class Train method iterator.
@Override
public Iterator<EntityMinecart> iterator() {
LinkageManager lm = LinkageManager.instance();
List<EntityMinecart> entities = new ArrayList<>(carts.size());
for (UUID cart : carts) {
EntityMinecart entity = CartTools.getCartFromUUID(world, cart);
if (entity != null)
entities.add(entity);
}
return entities.iterator();
}
use of net.minecraft.entity.item.EntityMinecart in project Railcraft by Railcraft.
the class ShuntingAuraTickHandler method tick.
@SubscribeEvent
public void tick(PlayerEvent.LivingUpdateEvent event) {
EntityLivingBase entity = event.getEntityLiving();
if (Game.isClient(entity.worldObj))
return;
clock++;
if (clock % 16 != 0)
return;
if (entity instanceof EntityPlayerMP) {
EntityPlayerMP player = (EntityPlayerMP) entity;
if (ItemGoggles.isPlayerWearing(player)) {
ItemStack goggles = ItemGoggles.getGoggles(player);
ItemGoggles.GoggleAura aura = ItemGoggles.getCurrentAura(goggles);
if (aura == ItemGoggles.GoggleAura.SHUNTING) {
List<EntityMinecart> carts = EntitySearcher.findMinecarts().around(player, 32F).at(player.worldObj);
PacketShuntingAura pkt = new PacketShuntingAura(carts);
PacketDispatcher.sendToPlayer(pkt.getPacket(), player);
}
}
}
}
use of net.minecraft.entity.item.EntityMinecart in project Railcraft by Railcraft.
the class Train method getMaxSpeed.
public float getMaxSpeed() {
float speed = 1.2F;
int numLocomotives = getNumRunningLocomotives();
for (EntityMinecart c : this) {
float baseSpeed = c.getMaxCartSpeedOnRail();
if (numLocomotives > 0 && !(c instanceof CartBaseEnergy) && c.hasCapability(CapabilitiesCharge.CART_BATTERY, null)) {
ICartBattery battery = c.getCapability(CapabilitiesCharge.CART_BATTERY, null);
if (battery.getType() != ICartBattery.Type.USER) {
baseSpeed = Math.min(0.2F, 0.03F + (numLocomotives - 1) * 0.075F);
}
}
speed = Math.min(speed, baseSpeed);
}
return speed;
}
use of net.minecraft.entity.item.EntityMinecart in project Railcraft by Railcraft.
the class GoggleAuraWorldRenderer method onWorldRender.
@SubscribeEvent
public void onWorldRender(final RenderWorldLastEvent event) {
if (cartInfos.isEmpty())
return;
final EntityPlayer player = Minecraft.getMinecraft().thePlayer;
if (ItemGoggles.isPlayerWearing(player)) {
ItemStack goggles = ItemGoggles.getGoggles(player);
ItemGoggles.GoggleAura aura = ItemGoggles.getCurrentAura(goggles);
if (aura == ItemGoggles.GoggleAura.SHUNTING) {
OpenGL.glPushMatrix();
final double px = player.lastTickPosX + (player.posX - player.lastTickPosX) * event.getPartialTicks();
final double py = player.lastTickPosY + (player.posY - player.lastTickPosY) * event.getPartialTicks();
final double pz = player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * event.getPartialTicks();
GlStateManager.translate(-px, -py, -pz);
GL11.glNormal3f(0.0F, 0.0F, 1.0F);
OpenGL.glDisable(GL11.GL_LIGHTING);
OpenGL.glEnable(GL11.GL_BLEND);
OpenGL.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
OpenGL.glDisable(GL11.GL_TEXTURE_2D);
OpenGL.glEnable(GL11.GL_LINE_SMOOTH);
OpenGL.glHint(GL11.GL_LINE_SMOOTH_HINT, GL11.GL_NICEST);
OpenGL.glLineWidth(4F);
OpenGL.glBegin(GL11.GL_LINES);
World world = Minecraft.getMinecraft().theWorld;
for (CartInfo cartInfo : cartInfos) {
EntityMinecart cart = CartTools.getCartFromUUID(world, cartInfo.id);
if (cart == null)
continue;
setColor(cartInfo.train.hashCode());
OpenGL.glVertex(cart.getPositionVector());
Vec3d top = cart.getPositionVector().addVector(0.0, 2.0, 0.0);
OpenGL.glVertex(top);
renderLink(world, top, cartInfo.linkA);
renderLink(world, top, cartInfo.linkB);
}
OpenGL.glEnd();
OpenGL.glLineWidth(2F);
OpenGL.glEnable(GL11.GL_TEXTURE_2D);
OpenGL.glPopMatrix();
}
}
}
use of net.minecraft.entity.item.EntityMinecart in project Railcraft by Railcraft.
the class GoggleAuraWorldRenderer method renderLink.
private void renderLink(World world, Vec3d top, UUID linkId) {
EntityMinecart link = CartTools.getCartFromUUID(world, linkId);
if (link != null) {
// setColor(EnumColor.BLUE.getHexColor());
OpenGL.glVertex(top);
OpenGL.glVertex(link.getPositionVector().addVector(0.0, 1.5, 0.0));
}
}
Aggregations