Jump to content

treebranch

Members
  • Posts

    40
  • Joined

  • Last visited

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

treebranch's Achievements

Tree Puncher

Tree Puncher (2/8)

6

Reputation

  1. I don't have any other ideas, but I'm sure there's a better way. Hopefully somebody here knows. Waiting for a pull request to get approved only sounds the way to go if you're patient.
  2. I "fixed" this by overriding the hitEntity, onBlockDestroyed, and onItemUse methods to call my own copy/paste of ItemStack.damageItem, which passes a stack of Items.WOODEN_AXE to EntityLivingBase.renderBrokenItemStack instead of my axe's stack. It's extremely hard to look at, but it works. If anybody has a better solution please let me know still. public class ItemImprovisedAxe extends ItemAxe { public ItemImprovisedAxe() { super(ItemTier.WOOD, 7.0f, -3.0f, new Item.Properties().addToolType(ToolType.AXE, 1).defaultMaxDamage(33).group(ItemGroup.TOOLS)); this.setRegistryName(ModInfo.MODID, "improvised_axe"); } private final ItemStack WOODEN_AXE_STACK = new ItemStack(Items.WOODEN_AXE); // from ItemStack private void damageItem(ItemStack stack, int amount, EntityLivingBase entityIn) { if (!(entityIn instanceof EntityPlayer) || !((EntityPlayer)entityIn).abilities.isCreativeMode) { if (/*this*/stack.isDamageable()) { if (/*this*/stack.attemptDamageItem(amount, entityIn.getRNG(), entityIn instanceof EntityPlayerMP ? (EntityPlayerMP)entityIn : null)) { //entityIn.renderBrokenItemStack(/*this*/stack); entityIn.renderBrokenItemStack(WOODEN_AXE_STACK); Item item = /*this*/stack.getItem(); /*this*/stack.shrink(1); if (entityIn instanceof EntityPlayer) { ((EntityPlayer)entityIn).addStat(StatList.ITEM_BROKEN.get(item)); } /*this*/stack.setDamage(0); } } } } @Override public boolean hitEntity(ItemStack stack, EntityLivingBase target, EntityLivingBase attacker) { //stack.damageItem(2, attacker); damageItem(stack, 2, attacker); return true; } @Override public boolean onBlockDestroyed(ItemStack stack, World worldIn, IBlockState state, BlockPos pos, EntityLivingBase entityLiving) { if (!worldIn.isRemote && state.getBlockHardness(worldIn, pos) != 0.0F) { //stack.damageItem(1, entityLiving); damageItem(stack, 1, entityLiving); } return true; } @Override public EnumActionResult onItemUse(ItemUseContext p_195939_1_) { World world = p_195939_1_.getWorld(); BlockPos blockpos = p_195939_1_.getPos(); IBlockState iblockstate = world.getBlockState(blockpos); Block block = BLOCK_STRIPPING_MAP.get(iblockstate.getBlock()); if (block != null) { EntityPlayer entityplayer = p_195939_1_.getPlayer(); world.playSound(entityplayer, blockpos, SoundEvents.ITEM_AXE_STRIP, SoundCategory.BLOCKS, 1.0F, 1.0F); if (!world.isRemote) { world.setBlockState(blockpos, block.getDefaultState().with(BlockRotatedPillar.AXIS, iblockstate.get(BlockRotatedPillar.AXIS)), 11); if (entityplayer != null) { //p_195939_1_.getItem().damageItem(1, entityplayer); damageItem(p_195939_1_.getItem(), 1, entityplayer); } } return EnumActionResult.SUCCESS; } else { return EnumActionResult.PASS; } } }
  3. My item class extends ItemAxe. It has a texture and behaves the same way as normal axes. When it's destroyed due to having 0 durability, the particles that appear are the purple missing texture image. I can't figure out why this happens. Here's the item class: public class ItemImprovisedAxe extends ItemAxe { public ItemImprovisedAxe() { super(ItemTier.WOOD, 7.0f, -3.0f, new Item.Properties().addToolType(ToolType.AXE, 1).defaultMaxDamage(33).group(ItemGroup.TOOLS)); this.setRegistryName(ModInfo.MODID, "improvised_axe"); } } Here's src/main/resources/assets/[modid]/models/item/improvised_axe.json: { "parent": "item/handheld", "textures": { "layer0": "modid:item/improvised_axe" } } The 16x16 texture is src/main/resources/assets/[modid]/textures.item/improvised_axe.png
  4. 1.13.x documentation is lacking. I don't think you'll find what you're looking for. In general I'd say just do what works for you, unless there's documentation explaining to do something else, with adequate examples, in which case do that instead.
  5. You could use ObfuscationReflectionHelper. All you need is to get your hands on the GuiIngameForge instance. I looked and it seems like they're setting a field called rayTraceBlock and rayTraceFluid. A grep in ~/.gradle/caches/forge_gradle reveals that the names of those fields are "field_211537_g" and "field_211538_h" respectively. An example of setting one of the fields: ObfuscationReflectionHelper.setPrivateValue(GuiIngameForge.class, guiIngameForge, entity.rayTrace(20.0D, 0.0F, RayTraceFluidMode.NEVER), "field_211537_g"); I'm not sure how you can get an instance of GuiIngameForge, but Minecraft.getInstance().ingameGUI gives you an instance of GuiIngame, which GuiIngameForge extends.
  6. Thanks for your help. I've probably viewed over half the 1.13.x related threads on this forum in an attempt to learn, and not everything is helpful. I'm new to Java and Forge so sometimes the smallest details are invaluable to me. While we're at it, there's a few events that never fired for me on MinecraftForge.EVENT_BUS and I had to find workarounds. Namely ChunkDataEvent.Load and PlayerEvent.NameFormat. I assumed these were Forge bugs or things that hadn't been implemented yet, but maybe it's another case of wrong bus? EDIT: They're on the right bus, it's just Forge's fault I guess. Anyways thanks.
  7. The more you know. I'll mark this as solved. Where can I find detailed documentation for this so I don't run into similar confusions later?
  8. Thank you for this info. Is the event bus provided by `FMLJavaModLoadingContext.get()` the only one in which RegistryEvent.Register will fire?
  9. Yes, using EVENT_BUS.register(this) in the main mod class. That's how I did all of my events, until I hit the register event. Simply it doesn't work, but I wish it did so I could have consistency in my code. This is event in its own class alone with the EventBusSubscriber annotation (this works perfectly): @Mod.EventBusSubscriber(modid = ModInfo.MODID, bus = Mod.EventBusSubscriber.Bus.MOD) public class RegisterItems { @SubscribeEvent public static void onRegisterItems(RegistryEvent.Register<Item> event) { event.getRegistry().registerAll( // item registration stuff here ); } } This is the same class, but rewritten without the @Mod.EventBusSubscriber annotation, and instead registered to the event bus from the main mod class (this never fires): public class RegisterItems { @SubscribeEvent public void onRegisterItems(RegistryEvent.Register<Item> event) { event.getRegistry().registerAll( // item registration stuff here ); } } (And the main mod class): @Mod(ModInfo.MODID) public class ExampleMod { public ExampleMod() { MinecraftForge.EVENT_BUS.register(this); MinecraftForge.EVENT_BUS.register(new RegisterItems()); } // more events down here } And finally, this is how I was doing it originally, where I ended up hitting the dead end with the register event (this never fires, despite every other event in my mod working this way): @Mod(ModInfo.MODID) public class ExampleMod { public ExampleMod() { MinecraftForge.EVENT_BUS.register(this); } @SubscribeEvent public void onRegisterItems(RegistryEvent.Register<Item> event) { event.getRegistry().registerAll( // item registration stuff here ); } // tons of other events down here which work perfectly }
  10. I'm just trying to understand why this happens. My mod is very large now, and all my events fire by simply calling MinecraftForge.EVENT_BUS.register(this) in the constructor of the main mod class, which houses all of said events. Everything fires except the RegistryEvent.Register<T> event. I got stuck on this and couldn't figure out why it was the only event that wasn't firing, and it was only until I put it as a static method in its own separate class, annotated with @Mod.EventBusSubscriber, that it finally began to work. I even tried registering that class using EVENT_BUS.register and it's the same problem. It's the only event that has to be in a class annotated with @Mod.EventBusSubscriber. Am I doing something wrong or is this on Forge's side?
  11. They also still have to finish the 1.13.2 update, since it doesn't have everything ported over yet.
  12. Well I'm new to forge, but if I were you, the first thing I'd do is look into the generation for the main End island, since it's a single structure surrounded by void.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.