Skip to content

Commit 30db1be

Browse files
committed
Don't allow adventure to trigger blocks via wind charges
1 parent 0dfb898 commit 30db1be

4 files changed

Lines changed: 37 additions & 4 deletions

File tree

src/main/java/net/modfest/fireblanket/Fireblanket.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,11 @@ public class Fireblanket implements ModInitializer {
9494
.category(GameRuleCategory.UPDATES)
9595
.buildAndRegister(FireblanketConstants.id("lightning_broadcast_radius"));
9696

97+
public static final GameRule<Boolean> ADVENTURE_WIND_CHARGE_INTERACTION =
98+
GameRuleBuilder.forBoolean(false)
99+
.category(GameRuleCategory.PLAYER)
100+
.buildAndRegister(FireblanketConstants.id("adventure_wind_charge_interaction"));
101+
97102
public static final Logger LOGGER = LoggerFactory.getLogger("Fireblanket");
98103

99104
public record QueuedPacket(Connection conn, Packet<?> packet, ChannelFutureListener listener) {
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package net.modfest.fireblanket.mixin.adventure_fix;
2+
3+
import com.llamalad7.mixinextras.injector.ModifyReturnValue;
4+
import net.minecraft.server.level.ServerPlayer;
5+
import net.minecraft.world.level.Explosion;
6+
import net.minecraft.world.level.GameType;
7+
import net.minecraft.world.level.ServerExplosion;
8+
import net.modfest.fireblanket.Fireblanket;
9+
import org.spongepowered.asm.mixin.Mixin;
10+
import org.spongepowered.asm.mixin.injection.At;
11+
12+
/**
13+
* @author Ampflower
14+
**/
15+
@Mixin(ServerExplosion.class)
16+
public abstract class MixinServerExplosion implements Explosion {
17+
@ModifyReturnValue(method = "canTriggerBlocks", at = @At("RETURN"))
18+
private boolean modifyReturn(final boolean original) {
19+
if (original && this.getIndirectSourceEntity() instanceof ServerPlayer player) {
20+
return player.gameMode() != GameType.ADVENTURE
21+
|| this.level().getGameRules().get(Fireblanket.ADVENTURE_WIND_CHARGE_INTERACTION);
22+
}
23+
return original;
24+
}
25+
}

src/main/resources/assets/fireblanket/lang/en_us.json

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
{
22
"argument.entity.selector.limit.unforced": "Targeting too many entities with no distance filter; add `force=true` to the selector to bypass",
33
"argument.entity.options.force.description": "Force-allow more than 50 entities targeted with no distance filter",
4-
"gamerule.newEntitiesImmutable": "Immutable creative-spawned entities",
5-
"gamerule.newEntitiesImmutable.description": "Whether newly spawned entities from creative players should be invulnerable and immutable. Item frames and armor stands won't be modifiable in adventure, for example.",
6-
"gamerule.fireblanket:lightningBroadcastRadius": "Lightning broadcast radius",
7-
"gamerule.fireblanket:lightningBroadcastRadius.description": "How far in blocks players will receive lightning strikes from in-game. Set to 0 to effectively disable broadcasting.",
4+
"gamerule.fireblanket.new_entities_immutable": "Immutable creative-spawned entities",
5+
"gamerule.fireblanket.new_entities_immutable.description": "Whether newly spawned entities from creative players should be invulnerable and immutable. Item frames and armor stands won't be modifiable in adventure, for example.",
6+
"gamerule.fireblanket.lightning_broadcast_radius": "Lightning broadcast radius",
7+
"gamerule.fireblanket.lightning_broadcast_radius.description": "How far in blocks players will receive lightning strikes from in-game. Set to 0 to effectively disable broadcasting.",
8+
"gamerule.fireblanket.adventure_wind_charge_interaction": "Wind charges interaction in Adventure",
9+
"gamerule.fireblanket.adventure_wind_charge_interaction.description": "Whether wind charges interact with blocks in adventure.",
810
"commands.gamerule.locked": "You do not have permission to modify this gamerule",
911
"commandsBlock.commandSetByPlayer": "%s set the command at (%s) to: %s",
1012
"fireblanket.fsc.broken": "[Fireblanket] Despite relevant mixins being disabled or broken, we're still requesting FSC?",

src/main/resources/fireblanket.mixins.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
"adventure_fix.MixinFarmlandBlock",
2626
"adventure_fix.MixinItemStack",
2727
"adventure_fix.MixinPlayerInteractEntityC2SPacketHandler",
28+
"adventure_fix.MixinServerExplosion",
2829
"adventure_fix.MixinServerPlayerInteractionManager",
2930
"adventure_fix.MixinSmallFireballEntity",
3031
"ai.MixinTemptGoal",

0 commit comments

Comments
 (0)