Skip to content

Commit 4d308f3

Browse files
committed
Fix possible crash related to forcefields - patch 1
- Probably broken blocks improperly in mffs Re: https://discord.com/channels/569969909380153345/569970124203753707/1457629423820996660
1 parent 61dc6ee commit 4d308f3

4 files changed

Lines changed: 62 additions & 65 deletions

File tree

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ org.gradle.jvmargs=-Xmx3G
44
org.gradle.daemon=false
55

66
# Electrodynamics parameters
7-
mod_version=1.0.0-4
7+
mod_version=1.0.1
88
mod_id=electrodynamics
99
mod_group_id=electrodynamics
1010
mod_name=Electrodynamics

libs.versions.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[versions]
2-
mod = "1.0.0-4"
2+
mod = "1.0.1"
33
minecraft = "1.21.1"
44
minecraftRange = "[1.21,1.21.1)"
55
# forge deps

src/main/java/electrodynamics/common/block/connect/BlockGasPipe.java

Lines changed: 55 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -28,96 +28,93 @@ public class BlockGasPipe extends AbstractRefreshingConnectBlock<GenericTileGasP
2828
public final IGasPipe pipe;
2929

3030
public BlockGasPipe(IGasPipe pipe) {
31-
super(pipe.getProperties().sound(pipe.getSoundType()).strength(0.15f).dynamicShape().noOcclusion(), pipe.getRadius());
31+
super(pipe.getProperties().sound(pipe.getSoundType()).strength(0.15f).dynamicShape().noOcclusion(),
32+
pipe.getRadius());
3233

33-
this.pipe = pipe;
34+
this.pipe = pipe;
3435

35-
PIPESET.add(this);
36+
PIPESET.add(this);
3637

3738
}
3839

3940
/*
40-
@Override
41-
public boolean isFlammable(BlockState state, BlockGetter world, BlockPos pos, Direction face) {
42-
return pipe.insulationMaterial.canCombust;
43-
}
44-
45-
@Override
46-
public int getFlammability(BlockState state, BlockGetter world, BlockPos pos, Direction face) {
47-
if (!pipe.insulationMaterial.canCombust) {
48-
return 0;
49-
}
50-
51-
return state.hasProperty(ElectrodynamicsBlockStates.WATERLOGGED) && state.getValue(ElectrodynamicsBlockStates.WATERLOGGED) ? 0 : 150;
52-
}
53-
54-
@Override
55-
public int getFireSpreadSpeed(BlockState state, BlockGetter world, BlockPos pos, Direction face) {
56-
if (!pipe.insulationMaterial.canCombust) {
57-
return 0;
58-
}
59-
60-
return state.hasProperty(ElectrodynamicsBlockStates.WATERLOGGED) && state.getValue(ElectrodynamicsBlockStates.WATERLOGGED) ? 0 : 400;
61-
}
62-
63-
@Override
64-
public void onCaughtFire(BlockState state, Level world, BlockPos pos, Direction face, LivingEntity igniter) {
65-
super.onCaughtFire(state, world, pos, face, igniter);
66-
Scheduler.schedule(5, () -> world.setBlockAndUpdate(pos, ElectrodynamicsBlocks.BLOCKS_GASPIPE.getValue(SubtypeGasPipe.getPipeForType(pipe.pipeMaterial, InsulationMaterial.NONE)).defaultBlockState()));
67-
}
68-
41+
* @Override public boolean isFlammable(BlockState state, BlockGetter world,
42+
* BlockPos pos, Direction face) { return pipe.insulationMaterial.canCombust; }
43+
*
44+
* @Override public int getFlammability(BlockState state, BlockGetter world,
45+
* BlockPos pos, Direction face) { if (!pipe.insulationMaterial.canCombust) {
46+
* return 0; }
47+
*
48+
* return state.hasProperty(ElectrodynamicsBlockStates.WATERLOGGED) &&
49+
* state.getValue(ElectrodynamicsBlockStates.WATERLOGGED) ? 0 : 150; }
50+
*
51+
* @Override public int getFireSpreadSpeed(BlockState state, BlockGetter world,
52+
* BlockPos pos, Direction face) { if (!pipe.insulationMaterial.canCombust) {
53+
* return 0; }
54+
*
55+
* return state.hasProperty(ElectrodynamicsBlockStates.WATERLOGGED) &&
56+
* state.getValue(ElectrodynamicsBlockStates.WATERLOGGED) ? 0 : 400; }
57+
*
58+
* @Override public void onCaughtFire(BlockState state, Level world, BlockPos
59+
* pos, Direction face, LivingEntity igniter) { super.onCaughtFire(state, world,
60+
* pos, face, igniter); Scheduler.schedule(5, () -> world.setBlockAndUpdate(pos,
61+
* ElectrodynamicsBlocks.BLOCKS_GASPIPE.getValue(SubtypeGasPipe.getPipeForType(
62+
* pipe.pipeMaterial, InsulationMaterial.NONE)).defaultBlockState())); }
63+
*
6964
*/
7065

7166
@Override
7267
public void entityInside(BlockState state, Level worldIn, BlockPos pos, Entity entityIn) {
73-
TileGasPipe tile = (TileGasPipe) worldIn.getBlockEntity(pos);
74-
if (worldIn.isClientSide() || tile == null || tile.getNetwork() == null && tile.getNetwork().transmittedThisTick <= 0) {
75-
return;
76-
}
77-
GasNetwork network = tile.getNetwork();
68+
if (worldIn.getBlockEntity(pos) instanceof TileGasPipe pipe) {
69+
if (worldIn.isClientSide() || pipe.getNetwork() == null && pipe.getNetwork().transmittedThisTick <= 0) {
70+
return;
71+
}
72+
GasNetwork network = pipe.getNetwork();
7873

79-
double multipler = 1.0;//pipe.insulationMaterial == InsulationMaterial.NONE ? 1.0 : 1.2;
74+
double multipler = 1.0;// pipe.insulationMaterial == InsulationMaterial.NONE ? 1.0 : 1.2;
8075

81-
if (network.temperatureOfTransmitted >= Gas.MINIMUM_HEAT_BURN_TEMP * multipler) {
76+
if (network.temperatureOfTransmitted >= Gas.MINIMUM_HEAT_BURN_TEMP * multipler) {
8277

83-
entityIn.hurt(entityIn.damageSources().inFire(), 1.0F);
78+
entityIn.hurt(entityIn.damageSources().inFire(), 1.0F);
8479

85-
} else if (network.temperatureOfTransmitted > 0 && network.temperatureOfTransmitted <= Gas.MINIMUM_FREEZE_TEMP / multipler) {
80+
} else if (network.temperatureOfTransmitted > 0
81+
&& network.temperatureOfTransmitted <= Gas.MINIMUM_FREEZE_TEMP / multipler) {
8682

87-
entityIn.hurt(entityIn.damageSources().freeze(), 1.0F);
83+
entityIn.hurt(entityIn.damageSources().freeze(), 1.0F);
8884

89-
}
85+
}
9086

87+
}
9188
}
9289

9390
@Override
94-
public EnumConnectType getConnection(BlockState otherState, BlockEntity otherTile, GenericTileGasPipe thisConductor, Direction dir) {
95-
EnumConnectType connection = EnumConnectType.NONE;
96-
if (otherTile instanceof GenericTileGasPipe) {
97-
connection = EnumConnectType.WIRE;
98-
} else if (GasUtilities.isGasReciever(otherTile, dir.getOpposite())) {
99-
connection = EnumConnectType.INVENTORY;
100-
}
101-
return connection;
91+
public EnumConnectType getConnection(BlockState otherState, BlockEntity otherTile, GenericTileGasPipe thisConductor,
92+
Direction dir) {
93+
EnumConnectType connection = EnumConnectType.NONE;
94+
if (otherTile instanceof GenericTileGasPipe) {
95+
connection = EnumConnectType.WIRE;
96+
} else if (GasUtilities.isGasReciever(otherTile, dir.getOpposite())) {
97+
connection = EnumConnectType.INVENTORY;
98+
}
99+
return connection;
102100
}
103101

104102
@Override
105103
public GenericTileGasPipe getCableIfValid(BlockEntity tile) {
106-
if (tile instanceof GenericTileGasPipe pipe) {
107-
return pipe;
108-
}
109-
return null;
104+
if (tile instanceof GenericTileGasPipe pipe) {
105+
return pipe;
106+
}
107+
return null;
110108
}
111109

112-
113110
@Override
114111
public BlockEntity newBlockEntity(BlockPos pos, BlockState state) {
115-
return new TileGasPipe(pos, state);
112+
return new TileGasPipe(pos, state);
116113
}
117114

118115
@Override
119116
protected MapCodec<? extends BaseEntityBlock> codec() {
120-
throw new UnsupportedOperationException("Need to implement CODEC");
117+
throw new UnsupportedOperationException("Need to implement CODEC");
121118
}
122119

123120
}

src/main/java/electrodynamics/common/block/connect/BlockWire.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,12 +79,12 @@ public boolean isFlammable(BlockState state, BlockGetter world, BlockPos pos, Di
7979

8080
@Override
8181
public void entityInside(BlockState state, Level worldIn, BlockPos pos, Entity entityIn) {
82-
TileWire tile = (TileWire) worldIn.getBlockEntity(pos);
83-
if (tile != null && tile.getNetwork() != null && tile.getNetwork().getActiveTransmitted() > 0) {
84-
int shockVoltage = tile.wire.getInsulation().shockVoltage();
85-
if (shockVoltage == 0 || tile.getNetwork().getActiveVoltage() > shockVoltage) {
82+
if (worldIn.getBlockEntity(pos) instanceof TileWire wire && wire.getNetwork() != null
83+
&& wire.getNetwork().getActiveTransmitted() > 0) {
84+
int shockVoltage = wire.wire.getInsulation().shockVoltage();
85+
if (shockVoltage == 0 || wire.getNetwork().getActiveVoltage() > shockVoltage) {
8686
ElectricityUtils.electrecuteEntity(entityIn, TransferPack
87-
.joulesVoltage(tile.getNetwork().getActiveTransmitted(), tile.getNetwork().getActiveVoltage()));
87+
.joulesVoltage(wire.getNetwork().getActiveTransmitted(), wire.getNetwork().getActiveVoltage()));
8888
}
8989
}
9090
}

0 commit comments

Comments
 (0)