net.minecraft.entity.Entity Java Examples

The following examples show how to use net.minecraft.entity.Entity. 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: MoCEntityCrocodile.java    From mocreaturesdev with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected Entity findPlayerToAttack()
{
    if (getHasCaughtPrey()) { return null; }

    if (worldObj.difficultySetting > 0)// && getIsAdult())
    {
        double attackD = 12D;
         
        if (getIsResting())
        {
        	attackD = 6D;
        }
        
        EntityPlayer entityplayer = worldObj.getClosestPlayerToEntity(this, attackD); 
        if((entityplayer != null) && getIsAdult()) 
        { 
        	 return entityplayer; 
        }
        
        EntityLiving entityliving = getClosestEntityLiving(this, attackD);
        return entityliving;
    }
    return null;
}
 
Example #2
Source File: EntityVillageLord.java    From ToroQuest with GNU General Public License v3.0 6 votes vote down vote up
private void dropRepTo(Entity entity) {
	if (entity == null) {
		return;
	}

	if (!(entity instanceof EntityPlayer)) {
		return;
	}

	EntityPlayer player = (EntityPlayer) entity;

	CivilizationType civ = getCivilization();
	if (civ == null) {
		return;
	}

	PlayerCivilizationCapabilityImpl.get(player).adjustReputation(civ, -5);
}
 
Example #3
Source File: MixinPlayerChat_MeCommand.java    From Galaxy with GNU Affero General Public License v3.0 6 votes vote down vote up
@SuppressWarnings("UnresolvedMixinReference")
@Inject(
    method = "method_13238",
    at = @At(
        value = "INVOKE",
        target = "Lnet/minecraft/server/PlayerManager;broadcastChatMessage(Lnet/minecraft/text/Text;Lnet/minecraft/network/MessageType;Ljava/util/UUID;)V",
        ordinal = 0
    ),
    locals = LocalCapture.CAPTURE_FAILSOFT
)
private static void onCommand(CommandContext<ServerCommandSource> context, CallbackInfoReturnable<Integer> cir, TranslatableText translatableText, Entity entity) {
    if (!(entity instanceof ServerPlayerEntity)) return;

    Main main = Main.Companion.getMain();
    ServerPlayerEntity player = (ServerPlayerEntity) entity;

    if (main == null || !main.getEventManager().emit(new PlayerChatEvent(player, translatableText)).getCancel()) {
        player.server.getPlayerManager().broadcastChatMessage(translatableText, MessageType.CHAT, entity.getUuid());
    } else {
        cir.setReturnValue(0);
        cir.cancel();
        player.server.sendSystemMessage(translatableText.append(" (Canceled)"), entity.getUuid());
    }
}
 
Example #4
Source File: MoCEntityOstrich.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 (attackTime <= 0 && (f < 3.0D) && (entity.boundingBox.maxY > boundingBox.minY) && (entity.boundingBox.minY < boundingBox.maxY))
    {
            
    }*/

    if (this.attackTime <= 0 && f < 2.0F && entity.boundingBox.maxY > this.boundingBox.minY && entity.boundingBox.minY < this.boundingBox.maxY)
    {
        this.attackTime = 20;
        openMouth();
        flapWings();
        entity.attackEntityFrom(DamageSource.causeMobDamage(this), 3);
        //this.attackEntityAsMob(par1Entity);
    }

}
 
Example #5
Source File: HackTickHandler.java    From PneumaticCraft with GNU General Public License v3.0 6 votes vote down vote up
@SubscribeEvent
public void worldTick(TickEvent.WorldTickEvent event){
    if(event.phase == TickEvent.Phase.END) {
        try {
            for(Entity entity : (List<Entity>)event.world.loadedEntityList) {
                HackingEntityProperties hackingProps = (HackingEntityProperties)entity.getExtendedProperties("PneumaticCraftHacking");
                if(hackingProps != null) {
                    hackingProps.update(entity);
                } else {
                    Log.warning("Extended entity props HackingEntityProperties couldn't be found in the entity " + entity.getCommandSenderName());
                }
            }
        } catch(Throwable e) {
            //Catching a CME which I have no clue on what might cause it.
        }
    }
}
 
Example #6
Source File: CraftEventFactory.java    From Thermos with GNU General Public License v3.0 6 votes vote down vote up
private static EntityDamageEvent callEntityDamageEvent(Entity damager, Entity damagee, DamageCause cause, Map<DamageModifier, Double> modifiers, Map<DamageModifier, Function<? super Double, Double>> modifierFunctions) {
    EntityDamageEvent event;
    if (damager != null) {
        event = new EntityDamageByEntityEvent(damager.getBukkitEntity(), damagee.getBukkitEntity(), cause, modifiers, modifierFunctions);
    } else {
        event = new EntityDamageEvent(damagee.getBukkitEntity(), cause, modifiers, modifierFunctions);
    }

    callEvent(event);

    if (!event.isCancelled()) {
        event.getEntity().setLastDamageCause(event);
    }

    return event;
}
 
Example #7
Source File: CraftEventFactory.java    From Thermos with GNU General Public License v3.0 6 votes vote down vote up
public static boolean handleNonLivingEntityDamageEvent(Entity entity, DamageSource source, double damage) {
    if (entity instanceof EntityEnderCrystal && !(source instanceof EntityDamageSource)) {
        return false;
    }

    final EnumMap<DamageModifier, Double> modifiers = new EnumMap<DamageModifier, Double>(DamageModifier.class);
    final EnumMap<DamageModifier, Function<? super Double, Double>> functions = new EnumMap(DamageModifier.class);

    modifiers.put(DamageModifier.BASE, damage);
    functions.put(DamageModifier.BASE, ZERO);

    final EntityDamageEvent event = handleEntityDamageEvent(entity, source, modifiers, functions);
    if (event == null) {
        return false;
    }
    return event.isCancelled() || (event.getDamage() == 0 && !(entity instanceof EntityItemFrame)); // Cauldron - fix frame removal
}
 
Example #8
Source File: BloodBlock.java    From the-hallow with MIT License 6 votes vote down vote up
@Override
public void onEntityCollision(BlockState blockState, World world, BlockPos pos, Entity entity) {
	if(!world.isClient) {
		if (pos.equals(entity.getBlockPos())) {
			if (entity instanceof ItemEntity && !((ItemEntity) entity).getStack().isEmpty()) {
				ItemEntity itemEntity = (ItemEntity) entity;
				ItemStack stack = itemEntity.getStack();
				if (stack.getItem() instanceof DyeableItem) {
					DyeableItem item = (DyeableItem) stack.getItem();
					if (item.hasColor(stack)) item.setColor(stack, 0xFF0000 | item.getColor(stack));
					else item.setColor(stack, 0xFF0000);

					return;
				}
			}
		}
	}

	super.onEntityCollision(blockState, world, pos, entity);
}
 
Example #9
Source File: ThermiteTeleportationHandler.java    From Thermos with GNU General Public License v3.0 6 votes vote down vote up
public static void transferEntityToDimension(Entity ent, int dim, ServerConfigurationManager manager, Environment environ) {

		if (ent instanceof EntityPlayerMP) {
			transferPlayerToDimension((EntityPlayerMP) ent, dim, manager, environ);
			return;
		}
		WorldServer worldserver = manager.getServerInstance().worldServerForDimension(ent.dimension);
		ent.dimension = dim;
		WorldServer worldserver1 = manager.getServerInstance().worldServerForDimension(ent.dimension);
		worldserver.removePlayerEntityDangerously(ent);
		if (ent.riddenByEntity != null) {
			ent.riddenByEntity.mountEntity(null);
		}
		if (ent.ridingEntity != null) {
			ent.mountEntity(null);
		}
		ent.isDead = false;
		transferEntityToWorld(ent, worldserver, worldserver1);
	}
 
Example #10
Source File: ItemThiefArmor.java    From HexxitGear with GNU General Public License v3.0 6 votes vote down vote up
@Override
public String getArmorTexture(ItemStack stack, Entity entity, int slot,
                              int layer) {
    if (entity instanceof EntityPlayer) {
        EntityPlayer player = (EntityPlayer) entity;
        if (player.isPotionActive(Potion.invisibility))
            return "/textures/armor/invisible.png";
    }

    // If the helmet slot, return helmet texture map
    if (slot == 0)
        return "/textures/maps/HoodHelmet.png";

    if (stack.itemID == HexxitGear.thiefLeggings.itemID)
        return "/textures/armor/thief2.png";

    return "/textures/armor/thief.png";
}
 
Example #11
Source File: MoCEntityAnimal.java    From mocreaturesdev with GNU General Public License v3.0 6 votes vote down vote up
/**
 * This method must be overrided to work in conjunction with our
 * onLivingUpdate update packets. It is currently used to fix mount bug when
 * players reconnect.
 */
@Override
public void mountEntity(Entity par1Entity)
{
	if (updateMount())
	{
		if (par1Entity == null)
		{
			if (this.ridingEntity != null)
			{
				this.setLocationAndAngles(this.ridingEntity.posX, this.ridingEntity.boundingBox.minY + (double) this.ridingEntity.height, this.ridingEntity.posZ, this.rotationYaw, this.rotationPitch);
				this.ridingEntity.riddenByEntity = null;
			}
			this.ridingEntity = null;
		}
		else
		{
			this.ridingEntity = par1Entity;
			par1Entity.riddenByEntity = this;
		}
	}
	else
	{
		super.mountEntity(par1Entity);
	}
}
 
Example #12
Source File: MoCModelMouse.java    From mocreaturesdev with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5)
{
    super.render(entity, f, f1, f2, f3, f4, f5);
    setRotationAngles(f, f1, f2, f3, f4, f5);
    Head.render(f5);
    EarR.render(f5);
    EarL.render(f5);
    WhiskerR.render(f5);
    WhiskerL.render(f5);
    Tail.render(f5);
    FrontL.render(f5);
    FrontR.render(f5);
    RearL.render(f5);
    RearR.render(f5);
    BodyF.render(f5);
}
 
Example #13
Source File: MoCEntityWerewolf.java    From mocreaturesdev with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onDeath(DamageSource damagesource)
{
    Entity entity = damagesource.getEntity();
    if ((scoreValue > 0) && (entity != null))
    {
        entity.addToPlayerScore(this, scoreValue);
    }
    if (entity != null)
    {
        entity.onKillEntity(this);
    }
    //unused_flag = true;
    if (!worldObj.isRemote)
    {
        for (int i = 0; i < 2; i++)
        {
            int j = getDropItemId();
            if (j > 0)
            {
                dropItem(j, 1);
            }
        }

    }
}
 
Example #14
Source File: SelectionManager.java    From litematica with GNU Lesser General Public License v3.0 6 votes vote down vote up
public boolean changeSelection(World world, Entity entity, int maxDistance)
{
    AreaSelection area = this.getCurrentSelection();

    if (area != null)
    {
        RayTraceWrapper trace = RayTraceUtils.getWrappedRayTraceFromEntity(world, entity, maxDistance);

        if (trace.getHitType() == HitType.SELECTION_BOX_CORNER || trace.getHitType() == HitType.SELECTION_BOX_BODY || trace.getHitType() == HitType.SELECTION_ORIGIN)
        {
            this.changeSelection(area, trace);
            return true;
        }
        else if (trace.getHitType() == HitType.MISS)
        {
            area.clearCurrentSelectedCorner();
            area.setSelectedSubRegionBox(null);
            area.setOriginSelected(false);
            return true;
        }
    }

    return false;
}
 
Example #15
Source File: Aimbot.java    From ForgeHax with MIT License 5 votes vote down vote up
private boolean isFiltered(Entity entity) {
  switch (EntityUtils.getRelationship(entity)) {
    case PLAYER:
      return target_players.get();
    case FRIENDLY:
    case NEUTRAL:
      return target_mobs_friendly.get();
    case HOSTILE:
      return target_mobs_hostile.get();
    case INVALID:
    default:
      return false;
  }
}
 
Example #16
Source File: EntitySelectorFromMobName.java    From customstuff4 with GNU General Public License v3.0 5 votes vote down vote up
@Nullable
@Override
public Class<? extends Entity> getEntityClass()
{
    if (entityClass == null)
    {
        entityClass = EntityList.getClass(mobName);
    }

    return entityClass;
}
 
Example #17
Source File: ItemCyberlimb.java    From Cyberware with MIT License 5 votes vote down vote up
@SubscribeEvent
public void handleSound(PlaySoundAtEntityEvent event)
{
	Entity e = event.getEntity();
	if (e instanceof EntityPlayer && event.getSound() == SoundEvents.ENTITY_PLAYER_HURT && e.worldObj.isRemote)
	{
		if (didFall.contains(e.getEntityId()))
		{
			int numLegs = 0;
			
			if (CyberwareAPI.isCyberwareInstalled(e, new ItemStack(this, 1, 2)))
			{
				numLegs++;
			}
			
			if (CyberwareAPI.isCyberwareInstalled(e, new ItemStack(this, 1, 3)))
			{
				numLegs++;
			}
			
			if (numLegs > 0)
			{	
				event.setSound(SoundEvents.ENTITY_IRONGOLEM_HURT);
				event.setPitch(event.getPitch() + 1F);
				didFall.remove((Integer) e.getEntityId());
			}
		}
	}	
}
 
Example #18
Source File: MixinWorld.java    From Hyperium with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * @author asbyth
 * @reason Post event
 */
@Overwrite
public void loadEntities(Collection<Entity> entityCollection) {
    for (Entity entity : entityCollection) {
        EntityJoinWorldEvent event = new EntityJoinWorldEvent((World) (Object) this, entity);
        EventBus.INSTANCE.post(event);
        if (!event.isCancelled()) {
            loadedEntityList.add(entity);
            onEntityAdded(entity);
        }
    }
}
 
Example #19
Source File: MoCEntityAnimal.java    From mocreaturesdev with GNU General Public License v3.0 5 votes vote down vote up
protected void getPathOrWalkableBlock(Entity entity, float f)
{
	PathEntity pathentity = worldObj.getPathEntityToEntity(this, entity, 16F, true, false, false, true);
	if ((pathentity == null) && (f > 8F))
	{
		int i = MathHelper.floor_double(entity.posX) - 2;
		int j = MathHelper.floor_double(entity.posZ) - 2;
		int k = MathHelper.floor_double(entity.boundingBox.minY);
		for (int l = 0; l <= 4; l++)
		{
			for (int i1 = 0; i1 <= 4; i1++)
			{
				if (((l < 1) || (i1 < 1) || (l > 3) || (i1 > 3)) && worldObj.isBlockNormalCube(i + l, k - 1, j + i1) && !worldObj.isBlockNormalCube(i + l, k, j + i1) && !worldObj.isBlockNormalCube(i + l, k + 1, j + i1))
				{
					setLocationAndAngles((i + l) + 0.5F, k, (j + i1) + 0.5F, rotationYaw, rotationPitch);
					return;
				}
			}

		}

	}
	else
	{
		setPathToEntity(pathentity);
	}
}
 
Example #20
Source File: MixinBlock.java    From LiquidBounce with GNU General Public License v3.0 5 votes vote down vote up
/**
 * @author CCBlueX
 */
@Overwrite
public void addCollisionBoxesToList(World worldIn, BlockPos pos, IBlockState state, AxisAlignedBB mask, List<AxisAlignedBB> list, Entity collidingEntity) {
    AxisAlignedBB axisalignedbb = this.getCollisionBoundingBox(worldIn, pos, state);
    BlockBBEvent blockBBEvent = new BlockBBEvent(pos, blockState.getBlock(), axisalignedbb);
    LiquidBounce.eventManager.callEvent(blockBBEvent);
    axisalignedbb = blockBBEvent.getBoundingBox();
    if(axisalignedbb != null && mask.intersectsWith(axisalignedbb))
        list.add(axisalignedbb);
}
 
Example #21
Source File: BlockWall.java    From customstuff4 with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void addCollisionBoxToList(IBlockState state, World worldIn, BlockPos pos, AxisAlignedBB entityBox, List<AxisAlignedBB> collidingBoxes, @Nullable Entity entityIn, boolean p_185477_7_)
{
    if (!p_185477_7_)
    {
        state = this.getActualState(state, worldIn, pos);
    }

    addCollisionBoxToList(pos, entityBox, collidingBoxes, CLIP_AABB_BY_INDEX[getAABBIndex(state)]);
}
 
Example #22
Source File: LitematicaRenderer.java    From litematica with GNU Lesser General Public License v3.0 5 votes vote down vote up
private ICamera createCamera(Entity entity, float partialTicks)
{
    double x = entity.lastTickPosX + (entity.posX - entity.lastTickPosX) * (double) partialTicks;
    double y = entity.lastTickPosY + (entity.posY - entity.lastTickPosY) * (double) partialTicks;
    double z = entity.lastTickPosZ + (entity.posZ - entity.lastTickPosZ) * (double) partialTicks;

    this.entity = entity;
    this.camera = new Frustum();
    this.camera.setPosition(x, y, z);

    return this.camera;
}
 
Example #23
Source File: ScanResult.java    From GardenCollection with MIT License 5 votes vote down vote up
public ScanResult(byte type, int blockId, int blockMeta, Entity entity,
		String phenomena) {
	super();
	this.type = type;
	this.id = blockId;
	this.meta = blockMeta;		
	this.entity = entity;
	this.phenomena = phenomena;
}
 
Example #24
Source File: ItemEspHack.java    From Wurst7 with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onUpdate()
{
	items.clear();
	for(Entity entity : MC.world.getEntities())
		if(entity instanceof ItemEntity)
			items.add((ItemEntity)entity);
}
 
Example #25
Source File: CraftEventFactory.java    From Kettle with GNU General Public License v3.0 5 votes vote down vote up
public static ProjectileHitEvent callProjectileHitEvent(Entity entity, RayTraceResult position) {
    Block hitBlock = null;
    if (position.typeOfHit == RayTraceResult.Type.BLOCK) {
        BlockPos blockposition = position.getBlockPos();
        hitBlock = entity.getBukkitEntity().getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ());
    }

    ProjectileHitEvent event = new ProjectileHitEvent((Projectile) entity.getBukkitEntity(), position.entityHit == null ? null : position.entityHit.getBukkitEntity(), hitBlock);
    entity.world.getServer().getPluginManager().callEvent(event);
    return event;
}
 
Example #26
Source File: TofuBlockUtils.java    From TofuCraftReload with MIT License 5 votes vote down vote up
public static void onFallenUponFragileTofu(World par1World, Entity par5Entity, Block block, float par6,
		BlockUtils.IEntityWeightingBlockHandler handler) {
	if (!par1World.isRemote) {
		if (par6 > 0.5F) {
			if (!(par5Entity instanceof EntityPlayer) && !par1World.getGameRules().getBoolean("mobGriefing"))
				return;
			BlockUtils.handleEntityWeightingBlock(par1World, par5Entity, block, handler);
		}
	}
}
 
Example #27
Source File: PathFinderDrone.java    From PneumaticCraft with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Internal implementation of creating a path from an entity to a point
 */
private PathEntity createEntityPathTo(Entity par1Entity, double par2, double par4, double par6, float par8){
    path.clearPath();
    pointMap.clearMap();
    boolean flag = isPathingInWater;
    int i = MathHelper.floor_double(par1Entity.boundingBox.minY + 0.5D);

    if(canEntityDrown && par1Entity.isInWater()) {
        i = (int)par1Entity.boundingBox.minY;

        for(Block j = worldMap.getBlock(MathHelper.floor_double(par1Entity.posX), i, MathHelper.floor_double(par1Entity.posZ)); j == Blocks.water || j == Blocks.flowing_water; j = worldMap.getBlock(MathHelper.floor_double(par1Entity.posX), i, MathHelper.floor_double(par1Entity.posZ))) {
            ++i;
        }

        flag = isPathingInWater;
        isPathingInWater = false;
    } else {
        i = MathHelper.floor_double(par1Entity.boundingBox.minY + 0.5D);
    }

    PathPoint pathpoint = openPoint(MathHelper.floor_double(par1Entity.boundingBox.minX), i, MathHelper.floor_double(par1Entity.boundingBox.minZ));
    PathPoint pathpoint1 = openPoint(MathHelper.floor_double(par2 - par1Entity.width / 2.0F), MathHelper.floor_double(par4), MathHelper.floor_double(par6 - par1Entity.width / 2.0F));
    PathPoint pathpoint2 = new PathPoint(MathHelper.floor_float(par1Entity.width + 1.0F), MathHelper.floor_float(par1Entity.height + 1.0F), MathHelper.floor_float(par1Entity.width + 1.0F));
    PathEntity pathentity = addToPath(par1Entity, pathpoint, pathpoint1, pathpoint2, par8);
    isPathingInWater = flag;
    return pathentity;
}
 
Example #28
Source File: BlockEnderUtilitiesPortal.java    From enderutilities with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void onEntityCollision(World worldIn, BlockPos pos, IBlockState state, Entity entityIn)
{
    if (worldIn.isRemote == false)
    {
        if (entityIn instanceof EntityPlayer)
        {
            TickHandler.instance().addPlayerToTeleport((EntityPlayer) entityIn);
        }
        else
        {
            this.teleportEntity(worldIn, pos, state, entityIn);
        }
    }
}
 
Example #29
Source File: ItemFakeHaloHead.java    From Wizardry with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void onUpdate(ItemStack stack, World worldIn, Entity entityIn, int itemSlot, boolean isSelected) {
	if (worldIn.isRemote) return;

	try (ManaManager.CapManagerBuilder mgr = ManaManager.forObject(entityIn)) {
		mgr.setMaxMana(ConfigValues.crudeHaloBufferSize);
		mgr.setMaxBurnout(ConfigValues.crudeHaloBufferSize);
		mgr.removeBurnout(mgr.getMaxBurnout() * ConfigValues.haloGenSpeed * 2);
	}
}
 
Example #30
Source File: SpellRing.java    From Wizardry with GNU Lesser General Public License v3.0 5 votes vote down vote up
public boolean taxCaster(@Nonnull World world, SpellData data, double multiplier, boolean failSound) {
	if(data.getData(SpellData.DefaultKeys.CASTER) == null) return true;

	Entity caster = world.getEntityByID(data.getData(SpellData.DefaultKeys.CASTER));

	if(caster == null) {
		Wizardry.LOGGER.warn("Caster was null!");
		return true;
	}

	IManaCapability cap = ManaCapabilityProvider.getCap(caster);
	if (cap == null) return false;

	double manaDrain = getManaDrain(data) * multiplier;
	double burnoutFill = getBurnoutFill(data) * multiplier;

	boolean fail = false;

	try (ManaManager.CapManagerBuilder mgr = ManaManager.forObject(cap)) {
		if (mgr.getMana() < manaDrain) fail = true;

		mgr.removeMana(manaDrain);
		mgr.addBurnout(burnoutFill);
	}

	if (fail && failSound) {

		Vec3d origin = data.getOriginWithFallback(world);
		if (origin != null)
			world.playSound(null, new BlockPos(origin), ModSounds.SPELL_FAIL, SoundCategory.NEUTRAL, 1f, 1f);
	}

	return !fail;
}