diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/main/java/re/jag/parquet/mixin/FireWorkItemMixin.java | 33 | ||||
-rw-r--r-- | src/main/resources/parquet.mixins.json | 3 |
2 files changed, 35 insertions, 1 deletions
diff --git a/src/main/java/re/jag/parquet/mixin/FireWorkItemMixin.java b/src/main/java/re/jag/parquet/mixin/FireWorkItemMixin.java new file mode 100644 index 0000000..cc8023b --- /dev/null +++ b/src/main/java/re/jag/parquet/mixin/FireWorkItemMixin.java @@ -0,0 +1,33 @@ +package re.jag.parquet.mixin; + +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; +import org.spongepowered.asm.mixin.injection.At; + +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.item.FireworkItem; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.Hand; +import net.minecraft.util.TypedActionResult; +import net.minecraft.world.World; +import net.minecraft.stat.Stats; + + +@Mixin(FireworkItem.class) +public class FireWorkItemMixin extends Item{ + + public FireWorkItemMixin(Settings settings) { + super(settings); + } + + /* + * minecraft.used:minecraft.firework_rocket only counts rockets fired on ground, not the ones used during flight. + * GG Mojang! + */ + @Inject(method="use", at=@At(value = "INVOKE", target = "Lnet/minecraft/world/World;spawnEntity(Lnet/minecraft/entity/Entity;)Z")) + protected void onUse(World world, PlayerEntity user, Hand hand, CallbackInfoReturnable<TypedActionResult<ItemStack>> ci) { + user.incrementStat(Stats.USED.getOrCreateStat(this)); + } +} diff --git a/src/main/resources/parquet.mixins.json b/src/main/resources/parquet.mixins.json index 4626434..ef58fb1 100644 --- a/src/main/resources/parquet.mixins.json +++ b/src/main/resources/parquet.mixins.json @@ -9,7 +9,8 @@ "VanillaMixin", "CommandManagerMixin", "ServerPlayerEntityMixin", - "BootstrapMixin" + "BootstrapMixin", + "FireWorkItemMixin" ], "client": [ ], |