Search in sources :

Example 6 with EntityBoat

use of net.minecraft.entity.item.EntityBoat in project Valkyrien-Warfare-Revamped by ValkyrienWarfare.

the class ValkyrienWarfareWorldEventListener method onEntityAdded.

@Override
public void onEntityAdded(Entity entityIn) {
    int oldChunkX = MathHelper.floor_double(entityIn.posX / 16.0D);
    int oldChunkZ = MathHelper.floor_double(entityIn.posZ / 16.0D);
    BlockPos posAt = new BlockPos(entityIn);
    PhysicsWrapperEntity wrapper = ValkyrienWarfareMod.physicsManager.getObjectManagingPos(worldObj, posAt);
    if (!(entityIn instanceof EntityFallingBlock) && wrapper != null && wrapper.wrapping.coordTransform != null) {
        if (entityIn instanceof EntityMountingWeaponBase || entityIn instanceof EntityArmorStand || entityIn instanceof EntityPig || entityIn instanceof EntityBoat) {
            //				entity.startRiding(wrapper);
            wrapper.wrapping.fixEntity(entityIn, new Vector(entityIn));
            wrapper.wrapping.queueEntityForMounting(entityIn);
        }
        RotationMatrices.applyTransform(wrapper.wrapping.coordTransform.lToWTransform, wrapper.wrapping.coordTransform.lToWRotation, entityIn);
        int newChunkX = MathHelper.floor_double(entityIn.posX / 16.0D);
        int newChunkZ = MathHelper.floor_double(entityIn.posZ / 16.0D);
        worldObj.getChunkFromChunkCoords(oldChunkX, oldChunkZ).removeEntity(entityIn);
        worldObj.getChunkFromChunkCoords(newChunkX, newChunkZ).addEntity(entityIn);
    }
    if (entityIn instanceof PhysicsWrapperEntity) {
        ValkyrienWarfareMod.physicsManager.onShipLoad((PhysicsWrapperEntity) entityIn);
    }
    if (entityIn.getEntityWorld().isRemote) {
        PhysicsWrapperEntity shipFixOnto = ValkyrienWarfareMod.physicsManager.getManagerForWorld(entityIn.worldObj).getShipFixedOnto(entityIn, true);
        if (shipFixOnto != null) {
            //				System.out.println("Ye");
            entityIn.startRiding(shipFixOnto, true);
        }
    }
}
Also used : EntityFallingBlock(net.minecraft.entity.item.EntityFallingBlock) PhysicsWrapperEntity(ValkyrienWarfareBase.PhysicsManagement.PhysicsWrapperEntity) EntityPig(net.minecraft.entity.passive.EntityPig) EntityBoat(net.minecraft.entity.item.EntityBoat) BlockPos(net.minecraft.util.math.BlockPos) EntityArmorStand(net.minecraft.entity.item.EntityArmorStand) Vector(ValkyrienWarfareBase.API.Vector) EntityMountingWeaponBase(ValkyrienWarfareCombat.Entity.EntityMountingWeaponBase)

Example 7 with EntityBoat

use of net.minecraft.entity.item.EntityBoat in project Charset by CharsetMC.

the class CharsetTransportBoats method onJoinWorld.

@SubscribeEvent
public void onJoinWorld(EntityJoinWorldEvent event) {
    if (event.getEntity().getClass() == EntityBoat.class) {
        ItemStack boatStack = ItemBoatCharset.STACK.get();
        ItemMaterial plankMaterial = (boatStack != null) ? ItemBoatCharset.getMaterial(boatStack) : ItemMaterialRegistry.INSTANCE.getOrCreateMaterial(new ItemStack(Blocks.PLANKS, 1, ((EntityBoat) event.getEntity()).getBoatType().getMetadata()));
        event.setCanceled(true);
        EntityBoatCharset entityBoatCharset = new EntityBoatCharset(event.getWorld(), event.getEntity().posX, event.getEntity().posY, event.getEntity().posZ, plankMaterial);
        entityBoatCharset.rotationYaw = event.getEntity().rotationYaw;
        event.getWorld().spawnEntity(entityBoatCharset);
    }
}
Also used : EntityBoat(net.minecraft.entity.item.EntityBoat) ItemMaterial(pl.asie.charset.lib.material.ItemMaterial) ItemStack(net.minecraft.item.ItemStack) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 8 with EntityBoat

use of net.minecraft.entity.item.EntityBoat in project Gaia-Dimension by Andromander.

the class GDShalurker method onLivingUpdate.

public void onLivingUpdate() {
    if (this.world.isDaytime() && !this.world.isRemote) {
        float f = this.getBrightness();
        BlockPos blockpos = this.getRidingEntity() instanceof EntityBoat ? (new BlockPos(this.posX, (double) Math.round(this.posY), this.posZ)).up() : new BlockPos(this.posX, (double) Math.round(this.posY), this.posZ);
        if (f > 0.5F && this.rand.nextFloat() * 30.0F < (f - 0.4F) * 2.0F && this.world.canSeeSky(blockpos)) {
            this.setFire(8);
        }
    }
    super.onLivingUpdate();
}
Also used : EntityBoat(net.minecraft.entity.item.EntityBoat) BlockPos(net.minecraft.util.math.BlockPos)

Example 9 with EntityBoat

use of net.minecraft.entity.item.EntityBoat in project ArsMagica2 by Mithion.

the class AMEventHandler method onEntityJump.

@SubscribeEvent
public void onEntityJump(LivingJumpEvent event) {
    if (event.entityLiving.isPotionActive(BuffList.agility.id)) {
        event.entityLiving.motionY *= 1.5f;
    }
    if (event.entityLiving.isPotionActive(BuffList.leap.id)) {
        Entity velocityTarget = event.entityLiving;
        if (event.entityLiving.ridingEntity != null) {
            if (event.entityLiving.ridingEntity instanceof EntityMinecart) {
                event.entityLiving.ridingEntity.setPosition(event.entityLiving.ridingEntity.posX, event.entityLiving.ridingEntity.posY + 1.5, event.entityLiving.ridingEntity.posZ);
            }
            velocityTarget = event.entityLiving.ridingEntity;
        }
        double yVelocity = 0;
        double xVelocity = 0;
        double zVelocity = 0;
        Vec3 vec = event.entityLiving.getLookVec().normalize();
        switch(event.entityLiving.getActivePotionEffect(BuffList.leap).getAmplifier()) {
            case BuffPowerLevel.Low:
                yVelocity = 0.4;
                xVelocity = velocityTarget.motionX * 1.08 * Math.abs(vec.xCoord);
                zVelocity = velocityTarget.motionZ * 1.08 * Math.abs(vec.zCoord);
                break;
            case BuffPowerLevel.Medium:
                yVelocity = 0.7;
                xVelocity = velocityTarget.motionX * 1.25 * Math.abs(vec.xCoord);
                zVelocity = velocityTarget.motionZ * 1.25 * Math.abs(vec.zCoord);
                break;
            case BuffPowerLevel.High:
                yVelocity = 1;
                xVelocity = velocityTarget.motionX * 1.75 * Math.abs(vec.xCoord);
                zVelocity = velocityTarget.motionZ * 1.75 * Math.abs(vec.zCoord);
                break;
            default:
                break;
        }
        float maxHorizontalVelocity = 1.45f;
        if (event.entityLiving.ridingEntity != null && (event.entityLiving.ridingEntity instanceof EntityMinecart || event.entityLiving.ridingEntity instanceof EntityBoat) || event.entityLiving.isPotionActive(BuffList.haste.id)) {
            maxHorizontalVelocity += 25;
            xVelocity *= 2.5;
            zVelocity *= 2.5;
        }
        if (xVelocity > maxHorizontalVelocity) {
            xVelocity = maxHorizontalVelocity;
        } else if (xVelocity < -maxHorizontalVelocity) {
            xVelocity = -maxHorizontalVelocity;
        }
        if (zVelocity > maxHorizontalVelocity) {
            zVelocity = maxHorizontalVelocity;
        } else if (zVelocity < -maxHorizontalVelocity) {
            zVelocity = -maxHorizontalVelocity;
        }
        if (ExtendedProperties.For(event.entityLiving).getIsFlipped()) {
            yVelocity *= -1;
        }
        velocityTarget.addVelocity(xVelocity, yVelocity, zVelocity);
    }
    if (event.entityLiving.isPotionActive(BuffList.entangled.id)) {
        event.entityLiving.motionY = 0;
    }
    if (event.entityLiving instanceof EntityPlayer) {
        ItemStack boots = ((EntityPlayer) event.entityLiving).inventory.armorInventory[0];
        if (boots != null && boots.getItem() == ItemsCommonProxy.enderBoots && event.entityLiving.isSneaking()) {
            ExtendedProperties.For(event.entityLiving).toggleFlipped();
        }
        if (ExtendedProperties.For(event.entityLiving).getFlipRotation() > 0)
            ((EntityPlayer) event.entityLiving).addVelocity(0, -2 * event.entityLiving.motionY, 0);
    }
}
Also used : Vec3(net.minecraft.util.Vec3) EntityBoat(net.minecraft.entity.item.EntityBoat) EntityPlayer(net.minecraft.entity.player.EntityPlayer) ItemStack(net.minecraft.item.ItemStack) EntityMinecart(net.minecraft.entity.item.EntityMinecart) SubscribeEvent(cpw.mods.fml.common.eventhandler.SubscribeEvent)

Example 10 with EntityBoat

use of net.minecraft.entity.item.EntityBoat 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;
}
Also used : EntityArrow(net.minecraft.entity.projectile.EntityArrow) EntityMinecartChest(net.minecraft.entity.item.EntityMinecartChest) EntityTNTPrimed(net.minecraft.entity.item.EntityTNTPrimed) EntityMinecartTNT(net.minecraft.entity.item.EntityMinecartTNT) EntityBoat(net.minecraft.entity.item.EntityBoat) EntityMinecartFurnace(net.minecraft.entity.item.EntityMinecartFurnace) EntityMinecartHopper(net.minecraft.entity.item.EntityMinecartHopper) EntityExpBottle(net.minecraft.entity.item.EntityExpBottle) EntityEgg(net.minecraft.entity.projectile.EntityEgg) Item(net.minecraft.item.Item) EntityItem(net.minecraft.entity.item.EntityItem) EntitySnowball(net.minecraft.entity.projectile.EntitySnowball) EntityPotion(net.minecraft.entity.projectile.EntityPotion) EntityMinecartEmpty(net.minecraft.entity.item.EntityMinecartEmpty) EntityItem(net.minecraft.entity.item.EntityItem)

Aggregations

EntityBoat (net.minecraft.entity.item.EntityBoat)10 BlockPos (net.minecraft.util.math.BlockPos)5 ItemStack (net.minecraft.item.ItemStack)4 EntityArmorStand (net.minecraft.entity.item.EntityArmorStand)3 EntityFallingBlock (net.minecraft.entity.item.EntityFallingBlock)3 EntityPig (net.minecraft.entity.passive.EntityPig)3 World (net.minecraft.world.World)2 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)2 EntityMountable (org.valkyrienskies.mod.common.entity.EntityMountable)2 Vector (ValkyrienWarfareBase.API.Vector)1 PhysicsWrapperEntity (ValkyrienWarfareBase.PhysicsManagement.PhysicsWrapperEntity)1 EntityMountingWeaponBase (ValkyrienWarfareCombat.Entity.EntityMountingWeaponBase)1 MinestuckKeyHandler (com.mraof.minestuck.client.settings.MinestuckKeyHandler)1 EntityBigPart (com.mraof.minestuck.entity.EntityBigPart)1 EntityDecoy (com.mraof.minestuck.entity.EntityDecoy)1 EntityPawn (com.mraof.minestuck.entity.carapacian.EntityPawn)1 ClientEventHandler (com.mraof.minestuck.event.ClientEventHandler)1 SubscribeEvent (cpw.mods.fml.common.eventhandler.SubscribeEvent)1 ModelBiped (net.minecraft.client.model.ModelBiped)1 Render (net.minecraft.client.renderer.entity.Render)1