• Recently Browsing

    No registered users viewing this page.

  • Posts

    • I cannot for the love of me figure out how the new objectregister system works. Been scratching my head at this for a week.   The above error hi-lites: JemPickaxe::new in the 3rd method.   public class JemPickaxes {     public static final JemRegistry<Item> PICKAXE = new JemRegistry<>(ForgeRegistries.ITEMS, JemCore.MOD_ID);          public static void init()     {         PICKAXE.register(FMLJavaModLoadingContext.get().getModEventBus());     }          public static RegistryObject<Item> OBSIDIAN = PICKAXE.register("obsidian_pickaxe", JemPickaxe::new);;      /**public static <OBSIDIAN extends PickaxeItem> OBSIDIAN PickaxeProperties(String item, IItemTier tier, int damage, float speed, Properties properties)     *{     *    PickaxeProperties("obsidian_pickaxe", ItemTier.NETHERITE, 1, -2.8F, new Item.Properties().group(JemPickaxe.TOOLS));     *     *    return JemPickaxes.OBSIDIAN = PickaxeProperties("obsidian_pickaxe", ItemTier.NETHERITE, 1, -2.8F, properties);     *}     *     *public static RegistryObject<Item> TEST()     *{     *    return PICKAXE.register("test_pickaxe", JemPickaxe::new);     *}     */ }   This is what my JemPickaxe class looks like:   public class JemPickaxes { public static final JemRegistry<Item> PICKAXE = new JemRegistry<>(ForgeRegistries.ITEMS, JemCore.MOD_ID); public static void init() { PICKAXE.register(FMLJavaModLoadingContext.get().getModEventBus()); } public static RegistryObject<Item> OBSIDIAN = PICKAXE.register("obsidian_pickaxe", JemPickaxe::new);; /**public static <OBSIDIAN extends PickaxeItem> OBSIDIAN PickaxeProperties(String item, IItemTier tier, int damage, float speed, Properties properties) *{ * PickaxeProperties("obsidian_pickaxe", ItemTier.NETHERITE, 1, -2.8F, new Item.Properties().group(JemPickaxe.TOOLS)); * * return JemPickaxes.OBSIDIAN = PickaxeProperties("obsidian_pickaxe", ItemTier.NETHERITE, 1, -2.8F, properties); *} * *public static RegistryObject<Item> TEST() *{ * return PICKAXE.register("test_pickaxe", JemPickaxe::new); *} */ }  
    • Okay so it is a normal capability. Then why are you not just making normal fields in it that you put values in?
    • Got it. Moved it to the client event class. Everything seems to be working.   It is a Forge capability, with an interface, class, provider, and storage, along with a AttachCapabilitiesEvent<Entity> called in a class to attach it to PlayerEntity's. Sorry if that wasn't clear in my last post. Unless you're talking about a capability that is already in Forge?
    • That is still reaching across logical sides. You don't need this "capability" stuff... If you do need to store data on players, use actual Forge capabilities.   You need to check in RightClickBlock if you are on the client.
    • Alright, put this in a class that's only for client events.   private static final Field field = ObfuscationReflectionHelper.findField(Minecraft.class, "field_71467_ac"); @SubscribeEvent public static void onClientTickEvent(TickEvent.ClientTickEvent event) throws IllegalAccessException { if(event.phase == TickEvent.Phase.START) { try { if(CustomCapabilities.getPlayer(Minecraft.getInstance().player).getVariable("string", "HasBrokenMyBlock").equals("true")){ field.setInt(Minecraft.getInstance(), 0); CustomCapabilities.getPlayer(Minecraft.getInstance().player).setVariable("HasBrokenMyBlock", "false"); } } catch (NullPointerException e) {} } }   I removed here is the new code that stayed in that class:   @SubscribeEvent public void farmBlock(PlayerInteractEvent.RightClickBlock event) { if(event.getPlayer().getHeldItem(event.getHand()).getItem().equals(Items.SHEARS) && event.getWorld().getBlockState(event.getPos()).equals(RegistryHandler.MY_BLOCK.get().getDefaultState())){ CustomCapabilities.getPlayer(event.getPlayer()).setVariable("HasBrokenMyBlock", "true"); } }   And is the custom capability system of mine that I was talking about. You can think of it as setting a value on a capability that is attached to PlayerEntitys. The real variable-setting stuff is buried under a bunch of static methods for convenience.   This seems to be the only way to put a boolean value on my player that really just functions to link the functions of the RightClickBlock event to the ClientTickEvent. I suppose if there was a better way to link them, I wouldn't have to do this.   Everything works, even when the client logged into the server.
  • Topics

  • Who's Online (See full list)