Search in sources :

Example 21 with EntityMinecart

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();
}
Also used : EntityMinecart(net.minecraft.entity.item.EntityMinecart)

Example 22 with EntityMinecart

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);
            }
        }
    }
}
Also used : ItemGoggles(mods.railcraft.common.items.ItemGoggles) PacketShuntingAura(mods.railcraft.common.util.network.PacketShuntingAura) EntityLivingBase(net.minecraft.entity.EntityLivingBase) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) ItemStack(net.minecraft.item.ItemStack) EntityMinecart(net.minecraft.entity.item.EntityMinecart) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 23 with EntityMinecart

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;
}
Also used : ICartBattery(mods.railcraft.api.charge.ICartBattery) EntityMinecart(net.minecraft.entity.item.EntityMinecart)

Example 24 with EntityMinecart

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();
        }
    }
}
Also used : ItemGoggles(mods.railcraft.common.items.ItemGoggles) EntityPlayer(net.minecraft.entity.player.EntityPlayer) ItemStack(net.minecraft.item.ItemStack) World(net.minecraft.world.World) EntityMinecart(net.minecraft.entity.item.EntityMinecart) Vec3d(net.minecraft.util.math.Vec3d) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 25 with EntityMinecart

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));
    }
}
Also used : EntityMinecart(net.minecraft.entity.item.EntityMinecart)

Aggregations

EntityMinecart (net.minecraft.entity.item.EntityMinecart)45 ItemStack (net.minecraft.item.ItemStack)11 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)11 EntityPlayer (net.minecraft.entity.player.EntityPlayer)10 ILinkageManager (mods.railcraft.api.carts.ILinkageManager)6 World (net.minecraft.world.World)6 Nullable (javax.annotation.Nullable)5 Entity (net.minecraft.entity.Entity)5 List (java.util.List)4 EntityLivingBase (net.minecraft.entity.EntityLivingBase)4 ArrayList (java.util.ArrayList)3 IEnergyTransfer (mods.railcraft.api.carts.IEnergyTransfer)2 ILinkableCart (mods.railcraft.api.carts.ILinkableCart)2 ItemGoggles (mods.railcraft.common.items.ItemGoggles)2 EntityItem (net.minecraft.entity.item.EntityItem)2 Item (net.minecraft.item.Item)2 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)2 AxisAlignedBB (net.minecraft.util.math.AxisAlignedBB)2 ShaderWrapper_Direct (blusunrize.immersiveengineering.api.shader.CapabilityShader.ShaderWrapper_Direct)1 HashMultiset (com.google.common.collect.HashMultiset)1