Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent Mob Eggs from Changing Spawners #507

Merged
merged 1 commit into from
Jul 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"]
}
Loading