Skip to content

Commit

Permalink
Fix shield property breaking when someone registers item property get…
Browse files Browse the repository at this point in the history
…ters before Forge events fire (#184)
  • Loading branch information
KnightMiner committed Oct 21, 2020
1 parent 48ba8a6 commit acf7c09
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ public class InspirationsTools extends ModuleBase {
public static Item barometer;
public static Item photometer;
public static ArrowItem redstoneArrow;
// only used in client proxy, should use Items.SHIELD normally
static Item shield;

// The "undyed" compass is White.
public static EnumObject<DyeColor, WaypointCompassItem> waypointCompasses = EnumObject.empty();
Expand Down Expand Up @@ -115,7 +117,7 @@ public void registerItems(Register<Item> event) {
() -> false), DyeColor.values(), "waypoint_compass");

if (Config.shieldEnchantmentTable.get()) {
registry.register(new EnchantableShieldItem(new Item.Properties().maxDamage(Items.SHIELD.getMaxDamage()).group(ItemGroup.COMBAT)), Items.SHIELD);
shield = registry.register(new EnchantableShieldItem(new Item.Properties().maxDamage(Items.SHIELD.getMaxDamage()).group(ItemGroup.COMBAT)), Items.SHIELD);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ static void clientSetup(FMLClientSetupEvent event) {
registerModelProperty(InspirationsTools.photometer, "light", new PhotometerPropertyGetter());
IItemPropertyGetter waypointCompass = new WaypointCompassPropertyGetter();
InspirationsTools.waypointCompasses.forEach(compass -> registerModelProperty(compass, "angle", waypointCompass));
// re-register shield blocking with registry sub shield, not strictly needed unless certain mods decide to register their properties before regsitry events
registerModelProperty(InspirationsTools.shield, "blocking",
(stack, world, entity) -> entity != null && entity.isHandActive() && entity.getActiveItemStack() == stack ? 1.0F : 0.0F);
}

@SubscribeEvent
Expand Down

0 comments on commit acf7c09

Please sign in to comment.