Posted September 6, 20178 yr Hi, i am playing around with custom mobs. The beast will not drop what i want him to drop. I've copied the original loot table from a zombie, but nothing. Even no error on the console. My Entity class package thewizardmod.entity; import javax.annotation.Nullable; import thewizardmod.TheWizardMod; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.SharedMonsterAttributes; import net.minecraft.entity.ai.EntityAIHurtByTarget; import net.minecraft.entity.ai.EntityAILookIdle; import net.minecraft.entity.ai.EntityAIMoveThroughVillage; import net.minecraft.entity.ai.EntityAIMoveTowardsRestriction; import net.minecraft.entity.ai.EntityAINearestAttackableTarget; import net.minecraft.entity.ai.EntityAISwimming; import net.minecraft.entity.ai.EntityAIWander; import net.minecraft.entity.ai.EntityAIWatchClosest; import net.minecraft.entity.monster.EntityIronGolem; import net.minecraft.entity.monster.EntityMob; import net.minecraft.entity.monster.EntityPigZombie; import net.minecraft.entity.passive.EntityVillager; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.MobEffects; import net.minecraft.network.datasync.DataParameter; import net.minecraft.network.datasync.DataSerializers; import net.minecraft.network.datasync.EntityDataManager; import net.minecraft.potion.PotionEffect; import net.minecraft.util.ResourceLocation; import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; public class EntityWeirdZombie extends EntityMob { // We reuse the zombie model which has arms that need to be raised when the zombie is attacking: private static final DataParameter<Boolean> ARMS_RAISED = EntityDataManager.createKey(EntityWeirdZombie.class, DataSerializers.BOOLEAN); public static final ResourceLocation LOOT = new ResourceLocation("thewizardmod:loot_table/entities/weird_zombie.json"); public EntityWeirdZombie(World worldIn) { super(worldIn); setSize(0.6F, 1.95F); } @Override protected void entityInit() { super.entityInit(); this.getDataManager().register(ARMS_RAISED, Boolean.valueOf(false)); } @Override protected void applyEntityAttributes() { super.applyEntityAttributes(); // Here we set various attributes for our mob. Like maximum health, armor, speed, ... this.getEntityAttribute(SharedMonsterAttributes.FOLLOW_RANGE).setBaseValue(35.0D); this.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).setBaseValue(0.23D); this.getEntityAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).setBaseValue(3.0D); this.getEntityAttribute(SharedMonsterAttributes.ARMOR).setBaseValue(2.0D); } public void setArmsRaised(boolean armsRaised) { this.getDataManager().set(ARMS_RAISED, Boolean.valueOf(armsRaised)); } @SideOnly(Side.CLIENT) public boolean isArmsRaised() { return this.getDataManager().get(ARMS_RAISED).booleanValue(); } @Override protected void initEntityAI() { this.tasks.addTask(0, new EntityAISwimming(this)); this.tasks.addTask(2, new EntityAIWeirdZombieAttack(this, 1.0D, false)); this.tasks.addTask(5, new EntityAIMoveTowardsRestriction(this, 1.0D)); this.tasks.addTask(7, new EntityAIWander(this, 1.0D)); this.tasks.addTask(8, new EntityAIWatchClosest(this, EntityPlayer.class, 8.0F)); this.tasks.addTask(8, new EntityAILookIdle(this)); this.applyEntityAI(); } private void applyEntityAI() { this.tasks.addTask(6, new EntityAIMoveThroughVillage(this, 1.0D, false)); this.targetTasks.addTask(1, new EntityAIHurtByTarget(this, true, new Class[]{EntityPigZombie.class})); this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityPlayer.class, true)); this.targetTasks.addTask(3, new EntityAINearestAttackableTarget(this, EntityVillager.class, false)); this.targetTasks.addTask(3, new EntityAINearestAttackableTarget(this, EntityIronGolem.class, true)); } @Override public boolean attackEntityAsMob(Entity entityIn) { if (super.attackEntityAsMob(entityIn)) { if (entityIn instanceof EntityLivingBase) { // This zombie gives health boost and regeneration when it attacks ((EntityLivingBase)entityIn).addPotionEffect(new PotionEffect(MobEffects.HEALTH_BOOST, 200)); ((EntityLivingBase)entityIn).addPotionEffect(new PotionEffect(MobEffects.REGENERATION, 200)); } return true; } else { return false; } } @Override @Nullable public ResourceLocation getLootTable() { return LOOT; } @Override public boolean isValidLightLevel() { return true; } @Override public int getMaxSpawnedInChunk() { return 5; } } And the loot table { "pools": [ { "rolls": 1, "entries": [ { "type": "item", "name": "minecraft:rotten_flesh", "weight": 1, "functions": [ { "function": "set_count", "count": { "min": 0, "max": 2 } }, { "function": "looting_enchant", "count": { "min": 0, "max": 1 } } ] } ] }, { "conditions": [ { "condition": "killed_by_player" }, { "condition": "random_chance_with_looting", "chance": 0.025, "looting_multiplier": 0.01 } ], "rolls": 1, "entries": [ { "type": "item", "name": "minecraft:iron_ingot", "weight": 1 }, { "type": "item", "name": "minecraft:carrot", "weight": 1 }, { "type": "item", "name": "minecraft:potato", "weight": 1 } ] } ] } Edited September 6, 20178 yr by Dustpuppy
September 6, 20178 yr Create your loot-tables resource location like this: final ResourceLocation lootTable = new ResourceLocation(yourMODID, "loot_table_name_without_modid_folder_and_fileending"); Register your loot-tables resource location in preInit like this: LootTableList.register(yourLootTableResourceLocation); Then pass it along in your entity as before. Edited September 6, 20178 yr by Busti Clarification. PM's regarding modding questions should belong in the Modder Support sub-forum and won't be answered.
September 6, 20178 yr Author I did this way before. Was like public static final ResourceLocation deathLootTable = new ResourceLocation(TheWizardMod.MODID, "loot_table/entities/weird_zombie"); As result got a warning. With ending the warning will not come, but still no drops. [Server thread/WARN]: Couldn't find resource table thewizardmod:loot_table/entities/weird_zombie I've also change from EntityMob to EntityZombie. All that chances is that they now burning in sunlight.
September 6, 20178 yr Author Mean time i've registered an onEntityDrop event in my event handlers. That will do the job. But the loot table still not working.
September 6, 20178 yr You shouldn't have to handle the event for your own custom mob. Events are mostly for changing behavior of vanilla mobs. Your error is that the resource location is still not pointing to the proper file. I think that is because I don't think you need the loot_table/ in your resource location -- it already knows to look there. Instead maybe you should have: public static final ResourceLocation deathLootTable = new ResourceLocation(TheWizardMod.MODID, "entities/weird_zombie"); Check out my tutorials here: http://jabelarminecraft.blogspot.com/
September 6, 20178 yr Author Also not working. No warnings in the console, but still no droppings from the loot table. And i've got a second problem. How can i display the spawn egg in my own creative tab? Because it's not an item, as it's registered with RenderingRegistry.registerEntityRenderingHandler(EntityWeirdZombie.class, RenderWeirdZombie.FACTORY); Can't use setCreativeTab. It allways will be only in the misc tab. Edited September 6, 20178 yr by Dustpuppy
September 6, 20178 yr Author Oh wait. it's registered here like this : EntityRegistry.registerModEntity(EntityWeirdZombie.class, "WeirdZombie", id++, TheWizardMod.instance, 64, 3, true, 0x996600, 0x00ff00); Edited September 6, 20178 yr by Dustpuppy
September 6, 20178 yr Are you calling LootTable.register() in your pre-init event handler? Whatever Minecraft needs, it is most likely not yet another tool tier.
September 6, 20178 yr Author package thewizardmod.entity; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityList; import net.minecraft.entity.EnumCreatureType; import net.minecraft.init.Biomes; import net.minecraft.world.storage.loot.LootTableList; import net.minecraftforge.fml.common.registry.EntityRegistry; import thewizardmod.TheWizardMod; public class StartupCommon { private static int entityID = 0; public static void preInitCommon() { int id = 1; EntityRegistry.registerModEntity(EntityWeirdZombie.class, "WeirdZombie", id++, TheWizardMod.instance, 64, 3, true, 0x996600, 0xff00ff); // EntityRegistry.addSpawn(EntityWeirdZombie.class, 100, 3, 5, EnumCreatureType.MONSTER, Biomes.PLAINS, Biomes.ICE_PLAINS); LootTableList.register(EntityWeirdZombie.deathLootTable); } public static void initCommon() { } public static void postInitCommon() { } } It's registered. I've commend out the spawn, because i only spawn them in my custom dimension.
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.