Skip to content

Commit

Permalink
Prevent egg throws in adventure
Browse files Browse the repository at this point in the history
  • Loading branch information
jaskarth authored and unascribed committed Aug 29, 2023
1 parent 1b5819f commit e3fca55
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ yarn_mappings=1.20.1+build.9
loader_version=0.14.21

# Mod Properties
mod_version=0.3.8
mod_version=0.3.9
maven_group=net.modfest
archives_base_name=fireblanket

Expand Down
23 changes: 23 additions & 0 deletions src/main/java/net/modfest/fireblanket/mixin/MixinEggItem.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package net.modfest.fireblanket.mixin;

import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.EggItem;
import net.minecraft.item.ItemStack;
import net.minecraft.util.Hand;
import net.minecraft.util.TypedActionResult;
import net.minecraft.world.World;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

@Mixin(EggItem.class)
public class MixinEggItem {
@Inject(method = "use", at = @At("HEAD"), cancellable = true)
private void fireblanket$spamPrevention(World world, PlayerEntity user, Hand hand, CallbackInfoReturnable<TypedActionResult<ItemStack>> cir) {
if (!user.getAbilities().allowModifyWorld) {
cir.setReturnValue(TypedActionResult.pass(user.getStackInHand(hand)));
}
}
}
1 change: 1 addition & 0 deletions src/main/resources/fireblanket.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
"ServerLoginNetworkHandlerAccessor",
"ServerChunkManagerAccessor",
"MixinNbtCompound",
"MixinEggItem",
"ai.MixinTemptGoal",
"ai.terracotta_knights.MixinItemPickupGoal",
"zstd.MixinChunkStreamVersion",
Expand Down

0 comments on commit e3fca55

Please sign in to comment.