Skip to content

Commit 8abecfc

Browse files
committed
Fix fixed item frame not working
1 parent 0b6c413 commit 8abecfc

File tree

3 files changed

+13
-13
lines changed

3 files changed

+13
-13
lines changed

CONFIG.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,11 @@ This section enforces the hunger range for all players, at a scale from 0 to 20.
3333
### vanilla_mechanics
3434
This section contains configurations that overrides Vanilla Minecraft mechanics.
3535

36-
| Key | Description |
37-
|-----------------------------|------------------------------------------------------------------------------------------------------------|
38-
| fixedItemFrame | Whether all item frame in the world should be treated as fixed. (Same effect as {Fixed:1b} Entity NBT Tag) |
39-
| minItemFrameInteractOpLevel | The minimum OP Level required to be able to interact with item frame. |
40-
| fallingBlockDelay | How much tick it should take for falling block (i.e. Sand & Gravel) to start falling after placing. |
36+
| Key | Description |
37+
|-----------------------------|-----------------------------------------------------------------------------------------------------|
38+
| immutableItemFrame | Whether all item frame in the world should be non-destructible by nature except by players. |
39+
| minItemFrameInteractOpLevel | The minimum OP Level required to be able to interact with item frame. |
40+
| fallingBlockDelay | How much tick it should take for falling block (i.e. Sand & Gravel) to start falling after placing. |
4141

4242
### Welcome Message Object
4343
| Key | Description |

src/main/java/com/lx862/svrutil/feature/VanillaMechanicsFeature.java

+5-5
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
public class VanillaMechanicsFeature extends Feature {
66
private int fallingBlockDelay = 2;
7-
private boolean fixedItemFrame = false;
7+
private boolean immutableItemFrame = false;
88
private int minItemFrameInteractOpLevel = 0;
99

1010
public VanillaMechanicsFeature() {
@@ -15,15 +15,15 @@ public VanillaMechanicsFeature() {
1515
public void readConfig(JsonObject jsonObject) {
1616
super.readConfig(jsonObject);
1717
this.fallingBlockDelay = jsonObject.get("fallingBlockDelay").getAsInt();
18-
this.fixedItemFrame = jsonObject.get("fixedItemFrame").getAsBoolean();
18+
this.immutableItemFrame = jsonObject.get("immutableItemFrame").getAsBoolean();
1919
this.minItemFrameInteractOpLevel = jsonObject.get("minItemFrameInteractOpLevel").getAsInt();
2020
}
2121

2222
@Override
2323
public JsonObject writeConfig() {
2424
JsonObject jsonObject = super.writeConfig();
2525
jsonObject.addProperty("fallingBlockDelay", fallingBlockDelay);
26-
jsonObject.addProperty("fixedItemFrame", fixedItemFrame);
26+
jsonObject.addProperty("immutableItemFrame", immutableItemFrame);
2727
jsonObject.addProperty("minItemFrameInteractOpLevel", minItemFrameInteractOpLevel);
2828
return jsonObject;
2929
}
@@ -32,8 +32,8 @@ public int getFallingBlockDelay() {
3232
return fallingBlockDelay;
3333
}
3434

35-
public boolean getFixedItemFrame() {
36-
return fixedItemFrame;
35+
public boolean getImmutableItemFrame() {
36+
return immutableItemFrame;
3737
}
3838
public int getMinItemFrameInteractOpLevel() {
3939
return minItemFrameInteractOpLevel;

src/main/java/com/lx862/svrutil/mixin/ItemFrameMixin.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,14 @@ protected ItemFrameMixin(EntityType<? extends AbstractDecorationEntity> entityTy
2424

2525
@Inject(method = "canStayAttached", at = @At("HEAD"), cancellable = true)
2626
public void canStayAttached(CallbackInfoReturnable<Boolean> cir) {
27-
if(FeatureSet.VANILLA_MECHANICS.feature.enabled && ((VanillaMechanicsFeature) FeatureSet.VANILLA_MECHANICS.feature).getFixedItemFrame()) {
27+
if(FeatureSet.VANILLA_MECHANICS.feature.enabled && ((VanillaMechanicsFeature) FeatureSet.VANILLA_MECHANICS.feature).getImmutableItemFrame()) {
2828
cir.setReturnValue(true);
2929
}
3030
}
3131

3232
@Inject(method = "damage", at = @At("HEAD"), cancellable = true)
3333
public void damage(DamageSource source, float amount, CallbackInfoReturnable<Boolean> cir) {
34-
if(FeatureSet.VANILLA_MECHANICS.feature.enabled && ((VanillaMechanicsFeature) FeatureSet.VANILLA_MECHANICS.feature).getFixedItemFrame()) {
34+
if(FeatureSet.VANILLA_MECHANICS.feature.enabled && ((VanillaMechanicsFeature) FeatureSet.VANILLA_MECHANICS.feature).getImmutableItemFrame()) {
3535
if(source.isExplosive() || source.isProjectile()) {
3636
cir.setReturnValue(false);
3737
}
@@ -41,7 +41,7 @@ public void damage(DamageSource source, float amount, CallbackInfoReturnable<Boo
4141
@Inject(method = "interact", at = @At("HEAD"), cancellable = true)
4242
public void interact(PlayerEntity player, Hand hand, CallbackInfoReturnable<ActionResult> cir) {
4343
if(!player.getWorld().isClient() && FeatureSet.VANILLA_MECHANICS.feature.enabled) {
44-
if(player.hasPermissionLevel(((VanillaMechanicsFeature) FeatureSet.VANILLA_MECHANICS.feature).getMinItemFrameInteractOpLevel())) {
44+
if(!player.hasPermissionLevel(((VanillaMechanicsFeature) FeatureSet.VANILLA_MECHANICS.feature).getMinItemFrameInteractOpLevel())) {
4545
cir.setReturnValue(ActionResult.PASS);
4646
}
4747
}

0 commit comments

Comments
 (0)