![](https://forums.minecraftforge.net/uploads/set_resources_2/84c1e40ea0e759e3f1505eb1788ddf3c_pattern.png)
Dustpuppy
Members-
Posts
120 -
Joined
-
Last visited
Everything posted by Dustpuppy
-
Custom Mob not dropping with loot table (1.10.2)
Dustpuppy replied to Dustpuppy's topic in Modder Support
I did -
Custom Mob not dropping with loot table (1.10.2)
Dustpuppy replied to Dustpuppy's topic in Modder Support
Oh wait. it's registered here like this : EntityRegistry.registerModEntity(EntityWeirdZombie.class, "WeirdZombie", id++, TheWizardMod.instance, 64, 3, true, 0x996600, 0x00ff00); -
Custom Mob not dropping with loot table (1.10.2)
Dustpuppy replied to Dustpuppy's topic in Modder Support
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. -
Custom Mob not dropping with loot table (1.10.2)
Dustpuppy replied to Dustpuppy's topic in Modder Support
Mean time i've registered an onEntityDrop event in my event handlers. That will do the job. But the loot table still not working. -
Custom Mob not dropping with loot table (1.10.2)
Dustpuppy replied to Dustpuppy's topic in Modder Support
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. -
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 } ] } ] }
-
Localize Name Problem in Creative Tab (1.10.2)
Dustpuppy replied to Dustpuppy's topic in Modder Support
What can i do? @SideOnly on top of the @Override? I am new in minecraft and java coding and have no clue. -
Localize Name Problem in Creative Tab (1.10.2)
Dustpuppy replied to Dustpuppy's topic in Modder Support
Thanks for telling me. I catched it with if(!worldIn.isRemote) -
Localize Name Problem in Creative Tab (1.10.2)
Dustpuppy replied to Dustpuppy's topic in Modder Support
It's ok, found it -
Hi, i have a book for my mod. Class looks like this package thewizardmod.books; import net.minecraft.client.Minecraft; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemBook; import net.minecraft.item.ItemStack; import net.minecraft.util.ActionResult; import net.minecraft.util.EnumHand; import net.minecraft.world.World; public class BookWizardsGuide extends ItemBook { public BookWizardsGuide() { this.setCreativeTab(CreativeTabs.MISC); } @Override public ActionResult<ItemStack> onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn, EnumHand hand) { Minecraft.getMinecraft().displayGuiScreen(new GuiWizardsGuide()); return super.onItemRightClick(itemStackIn, worldIn, playerIn, hand); } } I register it this way package thewizardmod.books; import thewizardmod.books.BookWizardsGuide; import net.minecraft.inventory.EntityEquipmentSlot; import net.minecraftforge.fml.common.registry.GameRegistry; public class StartupCommon { public static BookWizardsGuide book; public static void preInitCommon() { book = (BookWizardsGuide)(new BookWizardsGuide().setUnlocalizedName("wizard_guide_twm")); book.setRegistryName("wizard_guide_registry_name_twm"); GameRegistry.register(book); } public static void initCommon() { } public static void postInitCommon() { } } My Creative Tab looks like this package thewizardmod.creative_tab; import java.util.List; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; import thewizardmod.books.StartupCommon; public class BooksTab extends CreativeTabs { public BooksTab(String label) { super(label); } @Override @SideOnly(Side.CLIENT) public Item getTabIconItem() { return StartupCommon.book; } @Override @SideOnly(Side.CLIENT) public void displayAllRelevantItems(List<ItemStack> itemsToShowOnTab) { for (Item item : Item.REGISTRY) { if (item != null) { if (item.getUnlocalizedName().contains("_twm")) { item.getSubItems(item, this, itemsToShowOnTab); // add all sub items to the list } } } } } The Language file # Books item.wizard_guide_twm=Wizards Guide Where the hack comes the .name from, that apears at the back of the name i set in the language file? It's only happening since i've made a new tab for books. When i had the book in the main tab of the mod, it was ok.
-
Moved into randomDisplayTick. Now it works. Thank you Herr 7
-
Hi again, i have a problem with spawning particles on top of a block. I allready set the position 2 up and nothing is blocking. The block is in free position. Just to be sure. Checked it several times. The console print out is telling me, that it works and gives the right coordinated, but no particles. Here's the part, where i try it. The block is a pedestral with tile entity, special renderer and a rotating item on top. @Override public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand) { if(!worldIn.isRemote) { System.out.println("spawn " + pos.getX() + " " + (pos.getY() + 2) + " " + pos.getZ()); worldIn.spawnParticle(EnumParticleTypes.DRAGON_BREATH, pos.getX(), pos.getY() + 2, pos.getZ(), 0, 1F, 0); } worldIn.scheduleBlockUpdate(pos, state.getBlock(), 1, 0); super.updateTick(worldIn, pos, state, rand); }
-
Problem with Tileentity and Special Renderer
Dustpuppy replied to Dustpuppy's topic in Modder Support
Found it by my self The saved tag need to have the key "BlockEntityTag". Then minecraft restores the data it self and i don't need onBlockPlacedBy anymore. Haaaa!!!! ..... 2 Weeks on java and i get better every day. -
Problem with Tileentity and Special Renderer
Dustpuppy replied to Dustpuppy's topic in Modder Support
Ups...the new code @Override public final ArrayList<ItemStack> getDrops(IBlockAccess world, BlockPos pos, IBlockState state, int fortune) { int meta = state.getBlock().getMetaFromState(state); ItemStack ret = new ItemStack(this, 1, meta); NBTTagCompound compound = new NBTTagCompound(); TileEntity tileEntity = world.getTileEntity(pos); NBTTagCompound tileEntityTag = new NBTTagCompound(); tileEntity.writeToNBT(tileEntityTag); compound.setTag("TileEntityData", tileEntityTag); ret.setTagCompound(compound); return Lists.newArrayList(ret); } @Override public boolean removedByPlayer(IBlockState state, World world, BlockPos pos, EntityPlayer player, boolean willHarvest) { if (willHarvest) return true; return super.removedByPlayer(state, world, pos, player, willHarvest); } @Override public void harvestBlock(World world, EntityPlayer player, BlockPos pos, IBlockState state, TileEntity tileEntity, ItemStack tool) { super.harvestBlock(world, player, pos, state, tileEntity, tool); world.setBlockToAir(pos); } @Override public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack) { super.onBlockPlacedBy(worldIn, pos, state, placer, stack); if (stack.hasTagCompound() && stack.getTagCompound().hasKey("TileEntityData")) { NBTTagCompound tag = stack.getTagCompound().getCompoundTag("TileEntityData"); worldIn.getTileEntity(pos).readFromNBT(tag); } } -
Problem with Tileentity and Special Renderer
Dustpuppy replied to Dustpuppy's topic in Modder Support
Saving the data works, but when i replace the jar, the items will be rendered at the old position. No idea, why. -
Problem with Tileentity and Special Renderer
Dustpuppy replied to Dustpuppy's topic in Modder Support
Then i have another question on top of this. How can i make it, that i don't drop all items in the jar and destroy it, but take the full jar into my inventory? -
Problem with Tileentity and Special Renderer
Dustpuppy replied to Dustpuppy's topic in Modder Support
That was the problem. Thank's for open my eyes. -
Problem with Tileentity and Special Renderer
Dustpuppy replied to Dustpuppy's topic in Modder Support
That's how it look like. First picture, one jar placed, all ok. Second picture, another jar placed, same amount of items in. If i took out an item of one of them, both sync to the same amount. -
Problem with Tileentity and Special Renderer
Dustpuppy replied to Dustpuppy's topic in Modder Support
Oh, i forgot...it's MC 1.10.2 :-) -
Hi, i have a funny problem with my tile entity. It's a jar, like in one of the tutorials from MrCrayfish. It work's ok, but if i place a second one in the world, both jars running synced. If i put an item in one jar, it also spawns in the second jar. If i destroy one of the jars, i got my items back and the other jar will become empty. It's like i have a clone of it, but not a seperate one. Here's my Block class package thewizardmod.jars; import java.util.List; import javax.annotation.Nullable; import net.minecraft.block.Block; import net.minecraft.block.ITileEntityProvider; import net.minecraft.block.material.Material; import net.minecraft.block.state.IBlockState; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.BlockRenderLayer; import net.minecraft.util.EnumBlockRenderType; import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumHand; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; import thewizardmod.items.StartupCommon; public class BlockJar extends Block implements ITileEntityProvider { private static final AxisAlignedBB BOUNCING_BOX = new AxisAlignedBB(0.0625 * 3, 0, 0.0625 * 3, 0.0625 * 13, 0.0625 * 15, 0.0625 * 13); private static final AxisAlignedBB COLLISION_BOX = new AxisAlignedBB(0.0625 * 4, 0, 0.0625 * 4, 0.0625 * 12, 0.0625 * 14, 0.0625 * 12); public BlockJar() { super(Material.GLASS); this.setCreativeTab(CreativeTabs.MISC); // the block will appear on the Blocks tab in creative setHardness(0.3F); } @SideOnly(Side.CLIENT) public BlockRenderLayer getBlockLayer() { return BlockRenderLayer.TRANSLUCENT; } @Override public boolean isOpaqueCube(IBlockState iBlockState) { return false; } @Override public boolean isFullCube(IBlockState iBlockState) { return false; } @Override @Deprecated public boolean hasTileEntity() { return true; } @Override public EnumBlockRenderType getRenderType(IBlockState iBlockState) { return EnumBlockRenderType.MODEL; } @Override @Deprecated public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) { return BOUNCING_BOX; } @Override @Deprecated public void addCollisionBoxToList(IBlockState state, World worldIn, BlockPos pos, AxisAlignedBB entityBox, List<AxisAlignedBB> collidingBoxes, @Nullable Entity entityIn) { super.addCollisionBoxToList(pos, entityBox, collidingBoxes, COLLISION_BOX); } @Override public TileEntity createNewTileEntity(World worldIn, int meta) { return new TileEntityJar(); } @Override public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, @Nullable ItemStack heldItem, EnumFacing side, float hitX, float hitY, float hitZ) { if(!worldIn.isRemote) { TileEntity tileEntity = worldIn.getTileEntity(pos); if(tileEntity instanceof TileEntityJar) { TileEntityJar jar = (TileEntityJar) tileEntity; if(heldItem != null) { if(heldItem.getItem() == StartupCommon.magicGem); { if(jar.addItem()) { heldItem.stackSize--; return true; } } } jar.removeItem(); } } return true; } @Override public void breakBlock(World worldIn, BlockPos pos, IBlockState state) { if (!worldIn.isRemote) { TileEntity tileEntity = worldIn.getTileEntity(pos); if (tileEntity instanceof TileEntityJar) { TileEntityJar jar = (TileEntityJar) tileEntity; while (jar.counter > 0) { jar.removeItem(); } } } super.breakBlock(worldIn, pos, state); } } My Tile Entity package thewizardmod.jars; import javax.annotation.Nullable; import thewizardmod.items.StartupCommon; import net.minecraft.block.state.IBlockState; import net.minecraft.entity.item.EntityItem; import net.minecraft.init.Items; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.network.NetworkManager; import net.minecraft.network.Packet; import net.minecraft.network.play.server.SPacketUpdateTileEntity; import net.minecraft.tileentity.TileEntity; public class TileEntityJar extends TileEntity{ public static int counter = 0; private int MAX = 14; public boolean addItem() { if(counter < MAX) { counter++; markDirty(); IBlockState state = worldObj.getBlockState(pos); worldObj.notifyBlockUpdate(pos, state, state, 3); return true; } return false; } public void removeItem() { if(counter > 0) { worldObj.spawnEntityInWorld(new EntityItem(worldObj, pos.getX() + 0.5F, pos.getY() + 1, pos.getZ() + 0.5F, new ItemStack(StartupCommon.magicGem))); counter --; markDirty(); IBlockState state = worldObj.getBlockState(pos); worldObj.notifyBlockUpdate(pos, state, state, 3); } } @Override public NBTTagCompound writeToNBT(NBTTagCompound compound) { super.writeToNBT(compound); compound.setInteger("counter", counter); return compound; } @Override public void readFromNBT(NBTTagCompound compound) { super.readFromNBT(compound); this.counter = compound.getInteger("counter"); } @Override public void onDataPacket(NetworkManager net, SPacketUpdateTileEntity pkt) { NBTTagCompound tag = pkt.getNbtCompound(); this.counter = tag.getInteger("counter"); } @Override @Nullable public SPacketUpdateTileEntity getUpdatePacket() { NBTTagCompound tag = new NBTTagCompound(); tag.setInteger("counter", counter); return new SPacketUpdateTileEntity(pos, getBlockMetadata(), tag); } @Override public NBTTagCompound getUpdateTag() { NBTTagCompound tag = super.getUpdateTag(); tag.setInteger("counter", counter); return tag; } } My Special Renderer package thewizardmod.jars; import thewizardmod.items.StartupCommon; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.entity.item.EntityItem; import net.minecraft.item.ItemStack; public class RendererJar extends TileEntitySpecialRenderer<TileEntityJar>{ private static final EntityItem ITEM = new EntityItem(Minecraft.getMinecraft().theWorld, 0, 0, 0, new ItemStack(StartupCommon.magicGem)); @Override public void renderTileEntityAt(TileEntityJar te, double x, double y, double z, float partialTicks, int destroyStage) { super.renderTileEntityAt(te, x, y, z, partialTicks, destroyStage); // For items that hover around ITEM.hoverStart = 0F; float pt = 0F; // float pt = partialTicks; GlStateManager.pushMatrix(); { GlStateManager.translate(x, y, z); GlStateManager.rotate(90F, 1, 0, 0); GlStateManager.translate(0.5F, 0.1F, -0.1F); GlStateManager.scale(0.7F, 0.7F, 0.7F); for(int i = 0; i < te.counter; i++) { Minecraft.getMinecraft().getRenderManager().doRenderEntity(ITEM, 0, 0, 0, 0F, pt, false); GlStateManager.translate(0, 0, -0.0625F); } } GlStateManager.popMatrix(); } } I register the block in my common proxy package thewizardmod.jars; import thewizardmod.TheWizardMod; import net.minecraft.item.ItemBlock; import net.minecraftforge.fml.common.registry.GameRegistry; public class StartupCommon { public static BlockJar jar; public static ItemBlock itemJar; public static void preInitCommon() { jar = (BlockJar)(new BlockJar().setUnlocalizedName("twm_jar_unlocalised_name")); jar.setRegistryName("jar"); GameRegistry.register(jar); itemJar = new ItemBlock(jar); itemJar.setRegistryName(jar.getRegistryName()); GameRegistry.register(itemJar); GameRegistry.registerTileEntity(TileEntityJar.class, TheWizardMod.MODID + "TileEntityJar"); } public static void initCommon() { } public static void postInitCommon() { } } and the model and renderer in my Client proxy package thewizardmod.jars; import net.minecraft.client.renderer.block.model.ModelResourceLocation; import net.minecraftforge.client.model.ModelLoader; import net.minecraftforge.fml.client.registry.ClientRegistry; public class StartupClientOnly { public static void preInitClientOnly() { final int DEFAULT_ITEM_SUBTYPE = 0; ModelResourceLocation itemModelResourceLocation = new ModelResourceLocation("thewizardmod:jar", "inventory"); ModelLoader.setCustomModelResourceLocation(StartupCommon.itemJar, DEFAULT_ITEM_SUBTYPE, itemModelResourceLocation); ClientRegistry.bindTileEntitySpecialRenderer(TileEntityJar.class, new RendererJar()); } public static void initClientOnly() { } public static void postInitClientOnly() { } } I've started learning Java just 2 weeks ago. If you see crap in files, please don't blame me. Still learning.