net.minecraft.entity.item.EntityBoat Java Examples

The following examples show how to use net.minecraft.entity.item.EntityBoat. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TracersModule.java    From seppuku with GNU General Public License v3.0 6 votes vote down vote up
private boolean checkFilter(Entity entity) {
    boolean ret = false;

    if (this.players.getValue() && entity instanceof EntityPlayer && entity != Minecraft.getMinecraft().player) {
        ret = true;
    }

    if (this.mobs.getValue() && entity instanceof IMob) {
        ret = true;
    }

    if (this.animals.getValue() && entity instanceof IAnimals && !(entity instanceof IMob)) {
        ret = true;
    }

    if (this.vehicles.getValue() && (entity instanceof EntityBoat || entity instanceof EntityMinecart || entity instanceof EntityMinecartContainer)) {
        ret = true;
    }

    if (this.items.getValue() && entity instanceof EntityItem) {
        ret = true;
    }

    return ret;
}
 
Example #2
Source File: EventsCommon.java    From Valkyrien-Skies with Apache License 2.0 6 votes vote down vote up
@SubscribeEvent(priority = EventPriority.HIGHEST)
public void onEntityJoinWorldEvent(EntityJoinWorldEvent event) {
    Entity entity = event.getEntity();

    World world = entity.world;
    BlockPos posAt = new BlockPos(entity);

    Optional<PhysicsObject> physicsObject = ValkyrienUtils.getPhysicsObject(world, posAt);
    if (!event.getWorld().isRemote && physicsObject.isPresent()
        && !(entity instanceof EntityFallingBlock)) {
        if (entity instanceof EntityArmorStand
            || entity instanceof EntityPig || entity instanceof EntityBoat) {
            EntityMountable entityMountable = new EntityMountable(world,
                entity.getPositionVector(), CoordinateSpaceType.SUBSPACE_COORDINATES, posAt);
            world.spawnEntity(entityMountable);
            entity.startRiding(entityMountable);
        }
        physicsObject.get()
            .getShipTransformationManager()
            .getCurrentTickTransform().transform(entity,
            TransformType.SUBSPACE_TO_GLOBAL);
        // TODO: This should work but it doesn't because of sponge. Instead we have to rely on MixinChunk.preAddEntity() to fix this
        // event.setCanceled(true);
        // event.getWorld().spawnEntity(entity);
    }
}
 
Example #3
Source File: MoCEntityShark.java    From mocreaturesdev with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void attackEntity(Entity entity, float f)
{
    if (entity.isInsideOfMaterial(Material.water) && (f < 3.5D) && (entity.boundingBox.maxY > boundingBox.minY) && (entity.boundingBox.minY < boundingBox.maxY) && (getEdad() >= 100))
    {
    	if (entity instanceof EntityPlayer && ((EntityPlayer)entity).ridingEntity != null)
    	{
    		Entity playerMount = ((EntityPlayer)entity).ridingEntity;
    		if (playerMount instanceof EntityBoat) 
    		{
    			return;
    		}
    	}
    	attackTime = 20;
        entity.attackEntityFrom(DamageSource.causeMobDamage(this), 5);
        if (!(entity instanceof EntityPlayer))
        {
            MoCTools.destroyDrops(this, 3D);
        }
        
    }
}
 
Example #4
Source File: CraftBoat.java    From Kettle with GNU General Public License v3.0 6 votes vote down vote up
public static TreeSpecies getTreeSpecies(EntityBoat.Type boatType) {
    switch (boatType) {
        case SPRUCE:
            return TreeSpecies.REDWOOD;
        case BIRCH:
            return TreeSpecies.BIRCH;
        case JUNGLE:
            return TreeSpecies.JUNGLE;
        case ACACIA:
            return TreeSpecies.ACACIA;
        case DARK_OAK:
            return TreeSpecies.DARK_OAK;
        case OAK:
        default:
            return TreeSpecies.GENERIC;
    }
}
 
Example #5
Source File: CraftBoat.java    From Kettle with GNU General Public License v3.0 6 votes vote down vote up
public static EntityBoat.Type getBoatType(TreeSpecies species) {
    switch (species) {
        case REDWOOD:
            return EntityBoat.Type.SPRUCE;
        case BIRCH:
            return EntityBoat.Type.BIRCH;
        case JUNGLE:
            return EntityBoat.Type.JUNGLE;
        case ACACIA:
            return EntityBoat.Type.ACACIA;
        case DARK_OAK:
            return EntityBoat.Type.DARK_OAK;
        case GENERIC:
        default:
            return EntityBoat.Type.OAK;
    }
}
 
Example #6
Source File: Jesus.java    From ForgeHax with MIT License 6 votes vote down vote up
@SubscribeEvent
public void onAddCollisionBox(AddCollisionBoxToListEvent event) {
  if (getLocalPlayer() != null
      && (event.getBlock() instanceof BlockLiquid)
      && (EntityUtils.isDrivenByPlayer(event.getEntity())
      || EntityUtils.isLocalPlayer(event.getEntity()))
      && !(event.getEntity() instanceof EntityBoat)
      && !getLocalPlayer().isSneaking()
      && getLocalPlayer().fallDistance < 3
      && !isInWater(getLocalPlayer())
      && (isAboveWater(getLocalPlayer(), false) || isAboveWater(getRidingEntity(), false))
      && isAboveBlock(getLocalPlayer(), event.getPos())) {
    AxisAlignedBB axisalignedbb = WATER_WALK_AA.offset(event.getPos());
    if (event.getEntityBox().intersects(axisalignedbb)) {
      event.getCollidingBoxes().add(axisalignedbb);
    }
    // cancel event, which will stop it from calling the original code
    event.setCanceled(true);
  }
}
 
Example #7
Source File: BlockWaterHyacinth.java    From Production-Line with MIT License 5 votes vote down vote up
/**
 * Called When an Entity Collided with the Block
 */
@Override
public void onEntityCollidedWithBlock(World worldIn, BlockPos pos, IBlockState state, Entity entityIn) {
    super.onEntityCollidedWithBlock(worldIn, pos, state, entityIn);

    if (entityIn instanceof EntityBoat) {
        worldIn.destroyBlock(new BlockPos(pos), true);
    }
}
 
Example #8
Source File: VSWorldEventListener.java    From Valkyrien-Skies with Apache License 2.0 5 votes vote down vote up
@Override
public void onEntityAdded(Entity entity) {
    if (entity instanceof PhysicsWrapperEntity) {
        ValkyrienSkiesMod.VS_PHYSICS_MANAGER.onShipLoad((PhysicsWrapperEntity) entity);
    } else {
        // This is really only here because Sponge doesn't call the entity join event for some reason :/
        // So I basically just copied the event code here as well.
        World world = worldObj;
        BlockPos posAt = new BlockPos(entity);
        Optional<PhysicsObject> physicsObject = ValkyrienUtils.getPhysicsObject(world, posAt);

        if (!worldObj.isRemote && physicsObject.isPresent()
            && !(entity instanceof EntityFallingBlock)) {
            if (entity instanceof EntityArmorStand
                || entity instanceof EntityPig || entity instanceof EntityBoat) {
                EntityMountable entityMountable = new EntityMountable(world,
                    entity.getPositionVector(), CoordinateSpaceType.SUBSPACE_COORDINATES,
                    posAt);
                world.spawnEntity(entityMountable);
                entity.startRiding(entityMountable);
            }
            world.getChunk(entity.getPosition().getX() >> 4, entity.getPosition().getZ() >> 4)
                .removeEntity(entity);
            physicsObject.get()
                .getShipTransformationManager()
                .getCurrentTickTransform().transform(entity,
                TransformType.SUBSPACE_TO_GLOBAL);
            world.getChunk(entity.getPosition().getX() >> 4, entity.getPosition().getZ() >> 4)
                .addEntity(entity);
        }
    }
}
 
Example #9
Source File: EntityBas.java    From ToroQuest with GNU General Public License v3.0 5 votes vote down vote up
public void onLivingUpdate() {
	super.onLivingUpdate();

	if (world.getTotalWorldTime() % 100 == 0) {
		spawnLimitedBats();
	}

	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)) {
			boolean flag = true;
			ItemStack itemstack = this.getItemStackFromSlot(EntityEquipmentSlot.HEAD);

			if (!itemstack.isEmpty()) {
				if (itemstack.isItemStackDamageable()) {
					itemstack.setItemDamage(itemstack.getItemDamage() + this.rand.nextInt(2));

					if (itemstack.getItemDamage() >= itemstack.getMaxDamage()) {
						this.renderBrokenItemStack(itemstack);
						this.setItemStackToSlot(EntityEquipmentSlot.HEAD, ItemStack.EMPTY);
					}
				}

				flag = false;
			}

			if (flag) {
				this.setFire(8);
			}
		}
	}

}
 
Example #10
Source File: BlockWaterHyacinth.java    From Production-Line with MIT License 5 votes vote down vote up
@Override
@SuppressWarnings("deprecation")
public void addCollisionBoxToList(IBlockState state, @Nonnull World worldIn, @Nonnull BlockPos pos, @Nonnull AxisAlignedBB entityBox, @Nonnull List<AxisAlignedBB> collidingBoxes, @Nullable Entity entityIn) {
    if (!(entityIn instanceof EntityBoat)) {
        addCollisionBoxToList(pos, entityBox, collidingBoxes, box);
    }
}
 
Example #11
Source File: Jesus.java    From ForgeHax with MIT License 5 votes vote down vote up
@SubscribeEvent
public void onLocalPlayerUpdate(LocalPlayerUpdateEvent event) {
  if (!getModManager().get(FreecamMod.class).map(BaseMod::isEnabled).orElse(false)) {
    if (isInWater(getLocalPlayer()) && !getLocalPlayer().isSneaking()) {
      getLocalPlayer().motionY = 0.1;
      if (getLocalPlayer().getRidingEntity() != null
          && !(getLocalPlayer().getRidingEntity() instanceof EntityBoat)) {
        getLocalPlayer().getRidingEntity().motionY = 0.3;
      }
    }
  }
}
 
Example #12
Source File: ForgeHaxHooks.java    From ForgeHax with MIT License 5 votes vote down vote up
public static float onRenderBoat(EntityBoat boat, float entityYaw) {
  if (HOOK_onRenderBoat.reportHook()) {
    RenderBoatEvent event = new RenderBoatEvent(boat, entityYaw);
    MinecraftForge.EVENT_BUS.post(event);
    return event.getYaw();
  } else {
    return entityYaw;
  }
}
 
Example #13
Source File: BlockCrate.java    From archimedes-ships with MIT License 5 votes vote down vote up
@Override
public void onEntityCollidedWithBlock(World world, int x, int y, int z, Entity entity)
{
	if (!(entity instanceof EntityPlayer) && entity instanceof EntityLivingBase || (entity instanceof EntityBoat && !(entity instanceof EntityShip)) || entity instanceof EntityMinecart)
	{
		TileEntity te = world.getTileEntity(x, y, z);
		if (te instanceof TileEntityCrate)
		{
			if (((TileEntityCrate) te).canCatchEntity() && ((TileEntityCrate) te).getContainedEntity() == null)
			{
				((TileEntityCrate) te).setContainedEntity(entity);
			}
		}
	}
}
 
Example #14
Source File: KillAuraModule.java    From seppuku with GNU General Public License v3.0 5 votes vote down vote up
private boolean checkFilter(Entity entity) {
    boolean ret = false;

    if (this.players.getValue() && entity instanceof EntityPlayer && entity != Minecraft.getMinecraft().player && Seppuku.INSTANCE.getFriendManager().isFriend(entity) == null && !entity.getName().equals(Minecraft.getMinecraft().player.getName())) {
        ret = true;
    }

    if (this.mobs.getValue() && entity instanceof IMob) {
        ret = true;
    }

    if (this.animals.getValue() && entity instanceof IAnimals && !(entity instanceof IMob)) {
        ret = true;
    }

    if (this.vehicles.getValue() && (entity instanceof EntityBoat || entity instanceof EntityMinecart || entity instanceof EntityMinecartContainer)) {
        ret = true;
    }

    if (this.projectiles.getValue() && (entity instanceof EntityShulkerBullet || entity instanceof EntityFireball)) {
        ret = true;
    }

    if (entity instanceof EntityLivingBase) {
        final EntityLivingBase entityLivingBase = (EntityLivingBase) entity;
        if (entityLivingBase.getHealth() <= 0) {
            ret = false;
        }
    }

    return ret;
}
 
Example #15
Source File: TracersModule.java    From seppuku with GNU General Public License v3.0 5 votes vote down vote up
private int getColor(Entity entity) {
    int ret = -1;

    if (entity instanceof IAnimals && !(entity instanceof IMob)) {
        ret = 0xFF00FF44;
    }

    if (entity instanceof IMob) {
        ret = 0xFFFFAA00;
    }

    if (entity instanceof EntityBoat || entity instanceof EntityMinecart || entity instanceof EntityMinecartContainer) {
        ret = 0xFF00FFAA;
    }

    if (entity instanceof EntityItem) {
        ret = 0xFF00FFAA;
    }

    if (entity instanceof EntityPlayer) {
        ret = 0xFFFF4444;

        if (Seppuku.INSTANCE.getFriendManager().isFriend(entity) != null) {
            ret = 0xFF9900EE;
        }
    }

    return ret;
}
 
Example #16
Source File: MoCEntityJellyFish.java    From mocreaturesdev with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void onLivingUpdate()
{
    
    if (rand.nextInt(2) == 0)
    {
        pulsingSize += 0.01F;

    }
    
    if (pulsingSize > 0.4F)
    {
        pulsingSize = 0.0F;
    }
    super.onLivingUpdate();
    if (MoCreatures.isServer())
    {
        
        if(rand.nextInt(200) == 0)
        {
            setGlowing(!worldObj.isDaytime()); 
        }
        
        
        if (!getIsAdult() && (rand.nextInt(200) == 0))
        {
            setEdad(getEdad() + 1);
            if (getEdad() >= 100)
            {
                setAdult(true);
            }
        }

        poisoncounter++;
        

        if (poisoncounter > 250 && (worldObj.difficultySetting > 0))
        {

            EntityPlayer entityplayertarget = worldObj.getClosestPlayer(posX, posY, posZ, 2D);
            {
                if (entityplayertarget != null && entityplayertarget.isInWater())
                {
                	if (entityplayertarget.ridingEntity != null && entityplayertarget.ridingEntity instanceof EntityBoat)
                	{
                		//don't poison players on boats
                	}else
                	{
                    MoCreatures.poisonPlayer(entityplayertarget);
                    entityplayertarget.addPotionEffect(new PotionEffect(Potion.poison.id, 120, 0));
                    poisoncounter = 0;
                	}
                    //attacking = true;
                }

            }
        }

        
        
    }
}
 
Example #17
Source File: MoCEntityRay.java    From mocreaturesdev with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void onLivingUpdate()
{
    /*if (rand.nextInt(200)==0)
    {
        switchany = !switchany;
    }*/

    super.onLivingUpdate();
    if (!worldObj.isRemote)
    {
        if (!getIsAdult() && (rand.nextInt(50) == 0))
        {
            setEdad(getEdad() + 1);
            if ((getType() == 1 && getEdad() >= 180) || (getType() > 1 && getEdad() >= 90))
            {
                setAdult(true);
            }
        }

        poisoncounter++;
        if (poisoncounter > 100)
        {
            attacking = false;
        }

        if (getType() > 1 && poisoncounter > 250 && (worldObj.difficultySetting > 0))
        {

            EntityPlayer entityplayertarget = worldObj.getClosestPlayer(posX, posY, posZ, 2D);
            {
                if (entityplayertarget != null && entityplayertarget.isInWater())
                {
                	if (entityplayertarget.ridingEntity != null && entityplayertarget.ridingEntity instanceof EntityBoat)
                	{
                		//don't poison players on boats
                	}else
                	{
                		MoCreatures.poisonPlayer(entityplayertarget);
                        entityplayertarget.addPotionEffect(new PotionEffect(Potion.poison.id, 120, 0));
                        poisoncounter = 0;
                        attacking = true;
                	}
                    
                }

            }
        }
    }

    //tempRotation = prevRenderYawOffset;
    //float percentChangeRotation = (prevRenderYawOffset - renderYawOffset)

}
 
Example #18
Source File: Entity.java    From TickDynamic with MIT License 4 votes vote down vote up
/**
 * Called when a user uses the creative pick block button on this entity.
 *
 * @param target The full target the player is looking at
 * @return A ItemStack to add to the player's inventory, Null if nothing should be added.
 */
public ItemStack getPickedResult(MovingObjectPosition target)
{
    if (this instanceof EntityPainting)
    {
        return new ItemStack(Items.painting);
    }
    else if (this instanceof EntityLeashKnot)
    {
        return new ItemStack(Items.lead);
    }
    else if (this instanceof EntityItemFrame)
    {
        ItemStack held = ((EntityItemFrame)this).getDisplayedItem();
        if (held == null)
        {
            return new ItemStack(Items.item_frame);
        }
        else
        {
            return held.copy();
        }
    }
    else if (this instanceof EntityMinecart)
    {
        return ((EntityMinecart)this).getCartItem();
    }
    else if (this instanceof EntityBoat)
    {
        return new ItemStack(Items.boat);
    }
    else
    {
        int id = EntityList.getEntityID(this);
        if (id > 0 && EntityList.entityEggs.containsKey(id))
        {
            return new ItemStack(Items.spawn_egg, 1, id);
        }
    }
    return null;
}
 
Example #19
Source File: CraftBoat.java    From Thermos with GNU General Public License v3.0 4 votes vote down vote up
@Override
public EntityBoat getHandle() {
    return (EntityBoat) entity;
}
 
Example #20
Source File: CraftBoat.java    From Thermos with GNU General Public License v3.0 4 votes vote down vote up
public CraftBoat(CraftServer server, EntityBoat entity) {
    super(server, entity);
}
 
Example #21
Source File: BoatFly.java    From ForgeHax with MIT License 4 votes vote down vote up
@SubscribeEvent // disable gravity
public void onLocalPlayerUpdate(LocalPlayerUpdateEvent event) {
  ForgeHaxHooks.isNoBoatGravityActivated =
      getRidingEntity() instanceof EntityBoat; // disable gravity if in boat
}
 
Example #22
Source File: RenderBoatEvent.java    From ForgeHax with MIT License 4 votes vote down vote up
public EntityBoat getBoat() {
  return this.boat;
}
 
Example #23
Source File: RenderBoatEvent.java    From ForgeHax with MIT License 4 votes vote down vote up
public RenderBoatEvent(EntityBoat boatIn, float entityYaw) {
  this.boat = boatIn;
  this.yaw = entityYaw;
}
 
Example #24
Source File: CraftBoat.java    From Kettle with GNU General Public License v3.0 4 votes vote down vote up
@Override
public EntityBoat getHandle() {
    return (EntityBoat) entity;
}
 
Example #25
Source File: CraftBoat.java    From Kettle with GNU General Public License v3.0 4 votes vote down vote up
public CraftBoat(CraftServer server, EntityBoat entity) {
    super(server, entity);
}
 
Example #26
Source File: ChamsModule.java    From seppuku with GNU General Public License v3.0 4 votes vote down vote up
private boolean checkFilter(Entity entity) {
    boolean ret = false;

    if (entity == Minecraft.getMinecraft().player) {
        ret = false;
    }

    final Entity riding = Minecraft.getMinecraft().player.getRidingEntity();

    if (riding != null && entity == riding) {
        ret = false;
    }

    if (this.players.getValue() && entity instanceof EntityPlayer && entity != Minecraft.getMinecraft().player) {
        ret = true;
    }

    if (this.animals.getValue() && entity instanceof IAnimals) {
        ret = true;
    }

    if (this.mobs.getValue() && entity instanceof IMob) {
        ret = true;
    }

    if (this.vehicles.getValue() && (entity instanceof EntityBoat || entity instanceof EntityMinecart || entity instanceof EntityMinecartContainer)) {
        ret = true;
    }

    if (this.crystals.getValue() && entity instanceof EntityEnderCrystal) {
        ret = true;
    }

    if (entity instanceof EntityLivingBase) {
        final EntityLivingBase entityLiving = (EntityLivingBase) entity;

        if (entityLiving.ticksExisted <= 0) {
            ret = false;
        }
    }

    return ret;
}