Egietje Posted August 22, 2016 Share Posted August 22, 2016 Hello, I have 5 mobs but the loot tables aren't working, the code etc. Entity class: package com.Egietje.KokkieMod.mobs.boom; import java.util.UUID; import javax.annotation.Nullable; import com.Egietje.KokkieMod.init.KokkieItems; import com.Egietje.KokkieMod.init.KokkieSounds; import com.Egietje.KokkieMod.mobs.KokkieLoot; import com.google.common.base.Predicate; import net.minecraft.block.Block; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityAgeable; import net.minecraft.entity.EntityLiving; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.SharedMonsterAttributes; import net.minecraft.entity.ai.EntityAIAttackMelee; import net.minecraft.entity.ai.EntityAIBeg; import net.minecraft.entity.ai.EntityAIFollowOwner; import net.minecraft.entity.ai.EntityAIFollowParent; import net.minecraft.entity.ai.EntityAIHurtByTarget; import net.minecraft.entity.ai.EntityAILeapAtTarget; import net.minecraft.entity.ai.EntityAILookIdle; import net.minecraft.entity.ai.EntityAIMate; import net.minecraft.entity.ai.EntityAINearestAttackableTarget; import net.minecraft.entity.ai.EntityAIOwnerHurtByTarget; import net.minecraft.entity.ai.EntityAIOwnerHurtTarget; import net.minecraft.entity.ai.EntityAIPanic; import net.minecraft.entity.ai.EntityAISit; import net.minecraft.entity.ai.EntityAISwimming; import net.minecraft.entity.ai.EntityAITargetNonTamed; import net.minecraft.entity.ai.EntityAITempt; import net.minecraft.entity.ai.EntityAIWander; import net.minecraft.entity.ai.EntityAIWatchClosest; import net.minecraft.entity.monster.EntityCreeper; import net.minecraft.entity.monster.EntityGhast; import net.minecraft.entity.monster.EntitySkeleton; import net.minecraft.entity.monster.EntitySpider; import net.minecraft.entity.passive.EntityAnimal; import net.minecraft.entity.passive.EntityHorse; import net.minecraft.entity.passive.EntityRabbit; import net.minecraft.entity.passive.EntitySheep; import net.minecraft.entity.passive.EntityTameable; import net.minecraft.entity.passive.EntityWolf; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.projectile.EntityArrow; import net.minecraft.init.Items; import net.minecraft.init.SoundEvents; import net.minecraft.item.EnumDyeColor; import net.minecraft.item.ItemFood; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.network.datasync.DataParameter; import net.minecraft.network.datasync.DataSerializers; import net.minecraft.network.datasync.EntityDataManager; import net.minecraft.util.DamageSource; import net.minecraft.util.EnumHand; import net.minecraft.util.EnumParticleTypes; import net.minecraft.util.ResourceLocation; import net.minecraft.util.SoundEvent; import net.minecraft.util.datafix.DataFixer; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.MathHelper; import net.minecraft.world.World; import net.minecraft.world.storage.loot.LootTableList; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; public class EntityBoomKokkie extends EntityTameable { private static final DataParameter<Float> DATA_HEALTH_ID = EntityDataManager .<Float>createKey(EntityBoomKokkie.class, DataSerializers.FLOAT); private static final DataParameter<Byte> CLIMBING = EntityDataManager.<Byte>createKey(EntityBoomKokkie.class, DataSerializers.BYTE); private float headRotationCourse; private float headRotationCourseOld; public EntityBoomKokkie(World worldIn) { super(worldIn); this.setSize(0.4F, 0.54F); this.setTamed(false); } @Override protected ResourceLocation getLootTable() { return KokkieLoot.ENTITIES_BOOM; } protected void initEntityAI() { this.tasks.addTask(1, new EntityAISwimming(this)); this.tasks.addTask(2, new EntityAIFollowOwner(this, 1.0D, 10.0F, 2.0F)); this.tasks.addTask(3, new EntityAIMate(this, 1.0D)); this.tasks.addTask(4, new EntityAIWander(this, 1.0D)); this.tasks.addTask(5, new EntityAIWatchClosest(this, EntityPlayer.class, 8.0F)); this.tasks.addTask(6, new EntityAILookIdle(this)); this.tasks.addTask(7, new EntityAIAttackMelee(this, 1.0D, true)); this.tasks.addTask(8, new EntityAIFollowParent(this, 1.1D)); this.tasks.addTask(9, new EntityAITempt(this, 0.9D, KokkieItems.BESJE, false)); this.tasks.addTask(10, new EntityAILeapAtTarget(this, 0.4F)); this.targetTasks.addTask(1, new EntityAIOwnerHurtByTarget(this)); this.targetTasks.addTask(2, new EntityAIOwnerHurtTarget(this)); this.targetTasks.addTask(3, new EntityAIHurtByTarget(this, true, new Class[0])); } @Override public boolean isBreedingItem(@Nullable ItemStack stack) { return stack == null ? false : stack.getItem() == KokkieItems.BESJE; } protected void applyEntityAttributes() { super.applyEntityAttributes(); this.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).setBaseValue(0.30000001192092896D); if (this.isTamed()) { this.getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(5.0D); } else { this.getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(2.0D); } this.getAttributeMap().registerAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).setBaseValue(0.5D); } protected void updateAITasks() { this.dataManager.set(DATA_HEALTH_ID, Float.valueOf(this.getHealth())); } protected void entityInit() { super.entityInit(); this.dataManager.register(DATA_HEALTH_ID, Float.valueOf(this.getHealth())); this.dataManager.register(CLIMBING, Byte.valueOf((byte) 0)); } protected void playStepSound(BlockPos pos, Block blockIn) { this.playSound(SoundEvents.ENTITY_ITEMFRAME_REMOVE_ITEM, 0.15F, 1.0F); } public static void func_189788_b(DataFixer p_189788_0_) { EntityLiving.func_189752_a(p_189788_0_, "BoomKokkie"); } protected SoundEvent getAmbientSound() { return this.isAngry() ? KokkieSounds.BOOM_KOKKIE_ANGRY : (this.rand.nextInt(3) == 0 ? (this.isTamed() && ((Float) this.dataManager.get(DATA_HEALTH_ID)).floatValue() < 10.0F ? KokkieSounds.BOOM_KOKKIE_AMBIENCE : KokkieSounds.BOOM_KOKKIE_AMBIENCE) : KokkieSounds.BOOM_KOKKIE_AMBIENCE); } protected SoundEvent getHurtSound() { return KokkieSounds.BOOM_KOKKIE_HURT; } protected SoundEvent getDeathSound() { return KokkieSounds.BOOM_KOKKIE_DEATH; } /** * Returns the volume for the sounds this mob makes. */ protected float getSoundVolume() { return 0.4F; } /** * Called to update the entity's position/logic. */ public void onUpdate() { super.onUpdate(); this.headRotationCourseOld = this.headRotationCourse; this.headRotationCourse += (0.0F - this.headRotationCourse) * 0.4F; if (!this.onGround && this.motionY < 0.0D) { this.motionY *= 0.6D; } if (!this.worldObj.isRemote) { this.setBesideClimbableBlock(this.isCollidedHorizontally); } } public boolean isOnLadder() { return this.isBesideClimbableBlock(); } public boolean isBesideClimbableBlock() { return (((Byte) this.dataManager.get(CLIMBING)).byteValue() & 1) != 0; } /** * Updates the WatchableObject (Byte) created in entityInit(), setting it to * 0x01 if par1 is true or 0x00 if it is false. */ public void setBesideClimbableBlock(boolean climbing) { byte b0 = ((Byte) this.dataManager.get(CLIMBING)).byteValue(); if (climbing) { b0 = (byte) (b0 | 1); } else { b0 = (byte) (b0 & -2); } this.dataManager.set(CLIMBING, Byte.valueOf(b0)); } public void fall(float distance, float damageMultiplier) { } @SideOnly(Side.CLIENT) public float getInterestedAngle(float p_70917_1_) { return (this.headRotationCourseOld + (this.headRotationCourse - this.headRotationCourseOld) * p_70917_1_) * 0.15F * (float) Math.PI; } public float getEyeHeight() { return this.height; } public int getVerticalFaceSpeed() { return this.isSitting() ? 20 : super.getVerticalFaceSpeed(); } public boolean attackEntityAsMob(Entity entityIn) { boolean flag = entityIn.attackEntityFrom(DamageSource.causeMobDamage(this), (float) ((int) this.getEntityAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).getAttributeValue())); if (flag) { this.applyEnchantments(this, entityIn); } return flag; } public void setTamed(boolean tamed) { super.setTamed(tamed); if (tamed) { this.getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(20.0D); } else { this.getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH).setBaseValue(8.0D); } this.getEntityAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).setBaseValue(4.0D); } public boolean processInteract(EntityPlayer player, EnumHand hand, @Nullable ItemStack stack) { if (this.isTamed()) { if (this.isOwner(player) && !this.worldObj.isRemote && !this.isBreedingItem(stack)) { this.isJumping = false; this.navigator.clearPathEntity(); this.setAttackTarget((EntityLivingBase) null); } } else if (stack != null && stack.getItem() == KokkieItems.BESJE) { if (!player.capabilities.isCreativeMode) { --stack.stackSize; } if (!this.worldObj.isRemote) { if (this.rand.nextInt(2) == 0) { this.setTamed(true); this.navigator.clearPathEntity(); this.setAttackTarget((EntityLivingBase) null); this.setHealth(5.0F); this.setOwnerId(player.getUniqueID()); this.playTameEffect(true); this.worldObj.setEntityState(this, (byte) 7); } else { this.playTameEffect(false); this.worldObj.setEntityState(this, (byte) 6); } } return true; } return super.processInteract(player, hand, stack); } public EntityBoomKokkie createChild(EntityAgeable ageable) { EntityBoomKokkie kokkie = new EntityBoomKokkie(this.worldObj); UUID uuid = this.getOwnerId(); if (uuid != null) { kokkie.setOwnerId(uuid); kokkie.setTamed(true); } return kokkie; } public boolean canMateWith(EntityAnimal otherAnimal) { if (otherAnimal == this) { return false; } else if (!this.isTamed()) { return false; } else if (!(otherAnimal instanceof EntityBoomKokkie)) { return false; } else { EntityBoomKokkie entitywolf = (EntityBoomKokkie) otherAnimal; return !entitywolf.isTamed() ? false : (entitywolf.isSitting() ? false : this.isInLove() && entitywolf.isInLove()); } } public boolean isAngry() { return (((Byte) this.dataManager.get(TAMED)).byteValue() & 2) != 0; } public void setAngry(boolean angry) { byte b0 = ((Byte) this.dataManager.get(TAMED)).byteValue(); if (angry) { this.dataManager.set(TAMED, Byte.valueOf((byte) (b0 | 2))); } else { this.dataManager.set(TAMED, Byte.valueOf((byte) (b0 & -3))); } } public boolean shouldAttackEntity(EntityLivingBase p_142018_1_, EntityLivingBase p_142018_2_) { if (!(p_142018_1_ instanceof EntityCreeper) && !(p_142018_1_ instanceof EntityGhast)) { if (p_142018_1_ instanceof EntityBoomKokkie) { EntityBoomKokkie entitywolf = (EntityBoomKokkie) p_142018_1_; if (entitywolf.isTamed() && entitywolf.getOwner() == p_142018_2_) { return false; } } return p_142018_1_ instanceof EntityPlayer && p_142018_2_ instanceof EntityPlayer && !((EntityPlayer) p_142018_2_).canAttackPlayer((EntityPlayer) p_142018_1_) ? false : !(p_142018_1_ instanceof EntityHorse) || !((EntityHorse) p_142018_1_).isTame(); } else { return false; } } public void setAttackTarget(@Nullable EntityLivingBase entitylivingbaseIn) { super.setAttackTarget(entitylivingbaseIn); if (entitylivingbaseIn == null) { this.setAngry(false); } else if (!this.isTamed()) { this.setAngry(true); } } public void writeEntityToNBT(NBTTagCompound compound) { super.writeEntityToNBT(compound); compound.setBoolean("Angry", this.isAngry()); } /** * (abstract) Protected helper method to read subclass entity data from NBT. */ public void readEntityFromNBT(NBTTagCompound compound) { super.readEntityFromNBT(compound); this.setAngry(compound.getBoolean("Angry")); } public void onLivingUpdate() { super.onLivingUpdate(); if (!this.worldObj.isRemote && this.getAttackTarget() == null && this.isAngry()) { this.setAngry(false); } } } Loot table class: package com.Egietje.KokkieMod.mobs; import com.Egietje.KokkieMod.Reference; import net.minecraft.util.ResourceLocation; import net.minecraft.world.storage.loot.LootTableList; public class KokkieLoot extends LootTableList { public static final ResourceLocation ENTITIES_BOOM = register("boom"); public static final ResourceLocation ENTITIES_GROND = register("grond"); public static final ResourceLocation ENTITIES_GROT = register("grot"); public static final ResourceLocation ENTITIES_ROTS = register("rots"); public static final ResourceLocation ENTITIES_EGEL = register("egel"); private static ResourceLocation register(String id) { return register(new ResourceLocation(Reference.ID, id)); } } Loot table json: { "pools": [ { "name": "boom", "rolls": 1, "entries": [ { "type": "item", "name": "km:boom_stof", "weight": 1, "functions": [ { "function": "set_count", "count": { "min": 1, "max": 2 } }, { "function": "looting_enchant", "count": { "min": 0, "max": 1 } } ] } ] }, { "name": "boom", "rolls": 1, "entries": [ { "type": "item", "name": "km:rauw_kokkie_stof", "weight": 1, "functions": [ { "function": "set_count", "count": { "min": 1, "max": 3 } }, { "function": "furnace_smelt", "conditions": [ { "condition": "entity_properties", "entity": "this", "properties": { "on_fire": true } } ] }, { "function": "looting_enchant", "count": { "min": 0, "max": 1 } } ] } ] } ] } http://i.imgur.com/J4rrGt6.png[/img] Link to comment Share on other sites More sharing options...
Choonster Posted August 22, 2016 Share Posted August 22, 2016 Define "not working". Are there any errors? What actually happens? Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future. Link to comment Share on other sites More sharing options...
Egietje Posted August 22, 2016 Author Share Posted August 22, 2016 If I kill it it doesn't drop any items http://i.imgur.com/J4rrGt6.png[/img] Link to comment Share on other sites More sharing options...
Egietje Posted August 22, 2016 Author Share Posted August 22, 2016 Oh wait, I named 1 item wrong... Thanks http://i.imgur.com/J4rrGt6.png[/img] Link to comment Share on other sites More sharing options...
Recommended Posts