Skip to content

Commit

Permalink
Merge pull request #507 from WaitingIdly/spawner-egg
Browse files Browse the repository at this point in the history
Prevent Mob Eggs from Changing Spawners
  • Loading branch information
ACGaming authored Jul 5, 2024
2 parents 945a3c3 + fb73b20 commit 6afa6c2
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ All changes are toggleable via config files.
* **Particle Limit:** Limits particles to a set amount. Should not be set too low, as it will cause particles to appear for a single tick before vanishing
* **Pickup Notification:** Displays highly configurable notifications when the player obtains or loses items
* **Player Speed:** Enables the modification of base and maximum player speeds along with fixing 'Player moved too quickly' messages
* **Prevent Mob Eggs from Changing Spawners:** Prevents using Mob Spawner Eggs to change what a Spawner is spawning
* **Prevent Observer Activating on Placement:** Controls if the observer activates itself on the first tick when it is placed
* **Prevent Placing Buckets in Portals:** Prevents placing of liquid source blocks overriding portal blocks
* **Pumpkin Placing:** Allows placing Pumpkins and Jack'O'Lanterns without a supporting block
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1134,6 +1134,11 @@ public static class ItemsCategory
})
public int utXPBottleAmount = -1;

@Config.RequiresMcRestart
@Config.Name("Prevent Mob Eggs from Changing Spawners")
@Config.Comment("Prevents using Mob Spawner Eggs to change what a Spawner is spawning")
public boolean utPreventMobEggsFromChangingSpawner = false;

public static class AttackCooldownCategory
{
@Config.RequiresMcRestart
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ public class UTLoadingPlugin implements IFMLLoadingPlugin, IEarlyMixinLoader
put("mixins.tweaks.items.infinityallarrows.json", () -> UTConfigTweaks.ITEMS.INFINITY.utAllArrowsAreInfinite);
put("mixins.tweaks.items.infinitymending.json", () -> UTConfigTweaks.ITEMS.INFINITY.utInfinityEnchantmentConflicts);
put("mixins.tweaks.items.itementities.server.json", () -> UTConfigTweaks.ITEMS.ITEM_ENTITIES.utItemEntitiesToggle);
put("mixins.tweaks.items.mobegg.json", () -> UTConfigTweaks.ITEMS.utPreventMobEggsFromChangingSpawner);
put("mixins.tweaks.items.repairing.json", () -> UTConfigTweaks.ITEMS.utCraftingRepairToggle);
put("mixins.tweaks.items.xpbottle.json", () -> UTConfigTweaks.ITEMS.utXPBottleAmount != -1);
put("mixins.tweaks.misc.advancements.json", () -> UTConfigTweaks.MISC.utDisableAdvancementsToggle);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package mod.acgaming.universaltweaks.tweaks.items.mobegg.mixin;

import net.minecraft.item.ItemMonsterPlacer;
import net.minecraft.tileentity.TileEntityMobSpawner;

import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.Constant;

import mod.acgaming.universaltweaks.config.UTConfigTweaks;

// Courtesy of WaitingIdly
@Mixin(ItemMonsterPlacer.class)
public abstract class UTItemMonsterPlacerMixin
{
// @Inject(method = "onPlaceItemIntoWorld", target = @At(value = "INVOKE", target = "Lnet/minecraft/item/Item;onItemUse(Lnet/minecraft/entity/player/EntityPlayer;Lnet/minecraft/world/World;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/util/EnumHand;Lnet/minecraft/util/EnumFacing;FFF)Lnet/minecraft/util/EnumActionResult;"))
// private boolean utPreventReplacingMobSpawnerEntity(Object instance, Operation<Boolean> original)
// {
// if (!UTConfigTweaks.ITEMS.utPreventMobEggsFromChangingSpawner) return original.call(instance);
// return false;
// }
@WrapOperation(method = "onItemUse", constant = @Constant(classValue = TileEntityMobSpawner.class, ordinal = 0))
private boolean utPreventReplacingMobSpawnerEntity(Object instance, Operation<Boolean> original)
{
if (!UTConfigTweaks.ITEMS.utPreventMobEggsFromChangingSpawner) return original.call(instance);
return false;
}
}
7 changes: 7 additions & 0 deletions src/main/resources/mixins.tweaks.items.mobegg.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"package": "mod.acgaming.universaltweaks.tweaks.items.mobegg.mixin",
"refmap": "universaltweaks.refmap.json",
"minVersion": "0.8",
"compatibilityLevel": "JAVA_8",
"mixins": ["UTItemMonsterPlacerMixin"]
}

0 comments on commit 6afa6c2

Please sign in to comment.