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);
}
}
}
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);
}
}
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();
}
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);
}
}
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;
}
Aggregations