Skip to content

Commit

Permalink
Add option to make stands and frames immutable by default
Browse files Browse the repository at this point in the history
  • Loading branch information
TheEpicBlock committed Nov 16, 2024
1 parent 2b8e888 commit b43e2aa
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 4 deletions.
4 changes: 4 additions & 0 deletions src/main/java/net/modfest/fireblanket/FireblanketMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ public boolean shouldApplyMixin(String targetClassName, String mixinClassName) {
return FireblanketConfig.get(ConfigSpecs.FLATTEN_CHUNK_PALETTES);
}

if (mixinClassName.contains("entity_immutability")) {
return FireblanketConfig.get(ConfigSpecs.ENTITY_IMMUTABILITY);
}

if (mixinClassName.contains("ai") || mixinClassName.contains("sounds")) {
return FireblanketConfig.get(ConfigSpecs.GAMEPLAY_CHANGES);
}
Expand Down
6 changes: 6 additions & 0 deletions src/main/java/net/modfest/fireblanket/config/ConfigSpecs.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ public final class ConfigSpecs {
Disables the usage of zstd to save world data and compress network connections.
""", "no", ConfigParsers.BOOLEAN);

public static final ConfigSpec<Boolean> ENTITY_IMMUTABILITY = new ConfigSpec<>("entity-immutability", "Entity Immutability by Default",
"""
Makes entities default to being immutable. For example, it will set frames to fixed by default.
""", "no", ConfigParsers.BOOLEAN);

public static final ConfigSpec<Boolean> GAMEPLAY_CHANGES = new ConfigSpec<>("gameplay-changes", "Gameplay Changes",
"""
Allow altering features in a way that impacts gameplay.
Expand All @@ -67,6 +72,7 @@ private static void buildMap() {
ALL_SPECS.add(FLATTEN_CHUNK_PALETTES);
ALL_SPECS.add(ALLOW_FOOTGUNS);
ALL_SPECS.add(AVOID_ZSTD);
ALL_SPECS.add(ENTITY_IMMUTABILITY);
ALL_SPECS.add(GAMEPLAY_CHANGES);

// We have registries at home:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package net.modfest.fireblanket.mixin.entity_immutability;

import net.minecraft.entity.EntityType;
import net.minecraft.entity.decoration.ArmorStandEntity;
import net.minecraft.world.World;
import net.modfest.fireblanket.mixinsupport.ImmmovableLivingEntity;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

@Mixin(ArmorStandEntity.class)
public class MixinArmorStand {
@Shadow
private int disabledSlots;

@Inject(method = "<init>(Lnet/minecraft/entity/EntityType;Lnet/minecraft/world/World;)V", at = @At("RETURN"))
private void onInit(EntityType entityType, World world, CallbackInfo ci) {
// Disable all slots by default
this.disabledSlots = 4144959;
// Disable movement (prevents abuse of fishing rods)
if (this instanceof ImmmovableLivingEntity im) {
im.setNoMovement(true);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package net.modfest.fireblanket.mixin.entity_immutability;

import net.minecraft.entity.EntityType;
import net.minecraft.entity.decoration.ItemFrameEntity;
import net.minecraft.world.World;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

@Mixin(ItemFrameEntity.class)
public class MixinItemFrame {
@Shadow
private boolean fixed;

@Inject(method = "<init>(Lnet/minecraft/entity/EntityType;Lnet/minecraft/world/World;)V", at = @At("RETURN"))
private void onInit(EntityType entityType, World world, CallbackInfo ci) {
this.fixed = true;
}
}
10 changes: 6 additions & 4 deletions src/main/resources/fireblanket.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,22 @@
"accessor.EntityTypeAccessor",
"accessor.ServerChunkManagerAccessor",
"accessor.ServerLoginNetworkHandlerAccessor",
"adventure_fix.MixinItemStack",
"adventure_fix.MixinItemStack",
"adventure_fix.MixinPlayerInteractEntityC2SPacketHandler",
"adventure_fix.MixinServerPlayerInteractionManager",
"ai.MixinTemptGoal",
"be_sync.MixinBlockEntity",
"be_sync.MixinChunkHolder",
"block.MixinCommandBlock",
"block_format.MixinChunkSection",
"entity_immutability.MixinArmorStand",
"entity_immutability.MixinItemFrame",
"entity_ticking.MixinDebugStickItem",
"entity_ticking.MixinEntity",
"entity_ticking.MixinItemGroups",
"entity_ticking.MixinLivingEntity",
"entity_ticking.MixinMinecraftServer",
"entity_ticking.MixinServerChunkLoadingManager",
"mods.create.MixinSuperGlueEntity",
"footgun.MixinEntitySelectorOptions",
"footgun.MixinEntitySelectorReader",
"fsc.MixinClientConnection",
Expand All @@ -32,6 +33,7 @@
"io_uring.MixinServerNetworkIo",
"mods.create.AccessorSmartBlockEntity",
"mods.create.MixinMechanicalBearingBlockEntity",
"mods.create.MixinSuperGlueEntity",
"mods.mythicmetals.MixinCarmotShield",
"mods.pehkui.MixinScaleUtils",
"mods.pswg.MixinComplexCollisionManager",
Expand Down Expand Up @@ -61,7 +63,6 @@
"client.adventure_fix.MixinClientPlayerInteractionManager",
"client.be_masking.MixinBlockEntityRenderDispatcher",
"client.be_masking.MixinRebuildTask",
"mods.masking.sodium.MixinChunkRenderRebuildTask",
"client.bufferbuilder_opto.MixinBufferBuilder",
"client.bufferbuilder_opto.MixinVertexFormat",
"client.entity_masking.MixinEntityRenderer",
Expand All @@ -79,6 +80,7 @@
"client.vbo_opto.MixinShaderProgram",
"client.vbo_opto.MixinVertexBuffer",
"gamemode_selection.MixinKeyboard",
"gamemode_selection.MixinSelectionScreen"
"gamemode_selection.MixinSelectionScreen",
"mods.masking.sodium.MixinChunkRenderRebuildTask"
]
}

0 comments on commit b43e2aa

Please sign in to comment.