Skip to content

Commit ac59cfa

Browse files
committed
Update Neo and adjust for the breaking changes
1 parent 42ea4d1 commit ac59cfa

File tree

12 files changed

+107
-134
lines changed

12 files changed

+107
-134
lines changed

gradle.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ minecraft_version=1.20.5
88
previous_minecraft_version=1.20.1
99
previous_minor_minecraft_version=1.20.4
1010
loader_version_range=[2,)
11-
forge_version=20.5.3-beta
11+
forge_version=20.5.16-beta
1212
mod_version=10.5.20
1313
#This determines the minimum version of forge required to use Mekanism
1414
# Only bump it whenever we need access to a feature in forge that is not available in earlier versions
15-
forge_version_range=[20.5.1-beta,)
15+
forge_version_range=[20.5.14-beta,)
1616
minecraft_version_range=[1.20.5]
1717
#This specifies what type of release it will be uploaded to CurseForge and Modrinth as
1818
# options are: alpha, beta, release

src/additions/java/mekanism/additions/common/block/plastic/BlockPlasticStairs.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public class BlockPlasticStairs extends StairBlock implements IColoredBlock, ISt
2929
private final EnumColor color;
3030

3131
public BlockPlasticStairs(IBlockProvider blockProvider, EnumColor color, UnaryOperator<Properties> propertyModifier) {
32-
super(blockProvider::defaultState, BlockStateHelper.applyLightLevelAdjustments(propertyModifier.apply(BlockBehaviour.Properties.of()
32+
super(blockProvider.defaultState(), BlockStateHelper.applyLightLevelAdjustments(propertyModifier.apply(BlockBehaviour.Properties.of()
3333
.mapColor(color.getMapColor()).strength(5, 6))));
3434
this.color = color;
3535
//Uses getDefaultState as starting state to take into account the stuff from super

src/datagen/main/java/mekanism/client/state/BaseBlockStateProvider.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import mekanism.api.providers.IBlockProvider;
66
import mekanism.client.model.BaseBlockModelProvider;
77
import mekanism.common.DataGenJsonConstants;
8+
import mekanism.common.lib.FieldReflectionHelper;
89
import mekanism.common.registration.impl.FluidDeferredRegister;
910
import mekanism.common.registration.impl.FluidDeferredRegister.MekanismFluidType;
1011
import mekanism.common.util.RegistryUtils;
@@ -16,6 +17,7 @@
1617
import net.minecraft.world.level.block.state.BlockState;
1718
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
1819
import net.minecraft.world.level.block.state.properties.Property;
20+
import net.minecraft.world.level.material.FlowingFluid;
1921
import net.neoforged.neoforge.client.model.generators.BlockStateProvider;
2022
import net.neoforged.neoforge.client.model.generators.ConfiguredModel;
2123
import net.neoforged.neoforge.client.model.generators.ModelFile;
@@ -25,6 +27,9 @@
2527

2628
public abstract class BaseBlockStateProvider<PROVIDER extends BaseBlockModelProvider> extends BlockStateProvider {
2729

30+
//Note: We use reflection rather than an AT to help prevent accidentally using the field outside datagen
31+
private static final FieldReflectionHelper<LiquidBlock, FlowingFluid> FLUID = new FieldReflectionHelper<>(LiquidBlock.class, "fluid", () -> null);
32+
2833
private final String modid;
2934
private final PROVIDER modelProvider;
3035

@@ -53,7 +58,7 @@ protected VariantBlockStateBuilder getVariantBuilder(IBlockProvider blockProvide
5358
protected void registerFluidBlockStates(FluidDeferredRegister register) {
5459
for (Holder<Block> blockEntry : register.getBlockEntries()) {
5560
//Note: We expect this to always be the case
56-
if (blockEntry.value() instanceof LiquidBlock block && block.getFluid().getFluidType() instanceof MekanismFluidType fluidType) {
61+
if (blockEntry.value() instanceof LiquidBlock block && FLUID.getValue(block).getFluidType() instanceof MekanismFluidType fluidType) {
5762
simpleBlock(block, models().getBuilder(RegistryUtils.getPath(block)).texture(DataGenJsonConstants.PARTICLE, fluidType.stillTexture));
5863
}
5964
}

src/main/java/mekanism/client/ClientTickHandler.java

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,11 @@
5757
import net.minecraft.world.item.ItemStack;
5858
import net.minecraft.world.level.material.FogType;
5959
import net.neoforged.bus.api.SubscribeEvent;
60+
import net.neoforged.neoforge.client.event.ClientTickEvent;
6061
import net.neoforged.neoforge.client.event.InputEvent.MouseScrollingEvent;
6162
import net.neoforged.neoforge.client.event.RecipesUpdatedEvent;
6263
import net.neoforged.neoforge.client.event.RenderLivingEvent;
6364
import net.neoforged.neoforge.client.event.ViewportEvent;
64-
import net.neoforged.neoforge.event.TickEvent.ClientTickEvent;
65-
import net.neoforged.neoforge.event.TickEvent.Phase;
6665
import net.neoforged.neoforge.event.entity.EntityJoinLevelEvent;
6766

6867
/**
@@ -141,13 +140,7 @@ public void onStartTracking(EntityJoinLevelEvent event) {
141140
}
142141

143142
@SubscribeEvent
144-
public void onTick(ClientTickEvent event) {
145-
if (event.phase == Phase.START) {
146-
tickStart();
147-
}
148-
}
149-
150-
public void tickStart() {
143+
public void onTick(ClientTickEvent.Pre event) {
151144
if (firstTick && minecraft.level != null) {
152145
MekanismClient.launchClient();
153146
firstTick = false;

src/main/java/mekanism/client/gui/item/GuiSeismicReader.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,10 @@ public GuiSeismicReader(SeismicReaderContainer container, Inventory inv, Compone
6161
ItemStack stack = state.getCloneItemStack(new BlockHitResult(p.getCenter().relative(Direction.UP, 0.5), Direction.UP, p, false), level, p, player);
6262
if (stack.isEmpty()) {
6363
Fluid fluid = Fluids.EMPTY;
64-
if (state.getBlock() instanceof LiquidBlock liquidBlock) {
65-
fluid = liquidBlock.getFluid();
64+
if (state.getBlock() instanceof LiquidBlock || state.getBlock() instanceof BubbleColumnBlock) {
65+
fluid = level.getFluidState(p).getType();
6666
} else if (state.getBlock() instanceof IFluidBlock fluidBlock) {
6767
fluid = fluidBlock.getFluid();
68-
} else if (state.getBlock() instanceof BubbleColumnBlock) {
69-
fluid = level.getFluidState(p).getType();
7068
}
7169
if (fluid == Fluids.EMPTY) {
7270
blockList.add(new BlockInfo<>(state, state, null));

src/main/java/mekanism/client/render/RenderTickHandler.java

Lines changed: 67 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@
8181
import net.minecraft.world.phys.Vec3;
8282
import net.neoforged.bus.api.SubscribeEvent;
8383
import net.neoforged.neoforge.client.ClientHooks;
84+
import net.neoforged.neoforge.client.event.ClientTickEvent;
8485
import net.neoforged.neoforge.client.event.RenderArmEvent;
8586
import net.neoforged.neoforge.client.event.RenderGuiLayerEvent;
8687
import net.neoforged.neoforge.client.event.RenderHighlightEvent;
@@ -90,8 +91,6 @@
9091
import net.neoforged.neoforge.client.gui.VanillaGuiLayers;
9192
import net.neoforged.neoforge.client.model.data.ModelData;
9293
import net.neoforged.neoforge.common.util.Lazy;
93-
import net.neoforged.neoforge.event.TickEvent.ClientTickEvent;
94-
import net.neoforged.neoforge.event.TickEvent.Phase;
9594
import org.jetbrains.annotations.NotNull;
9695
import org.jetbrains.annotations.Nullable;
9796
import org.joml.Matrix3f;
@@ -223,81 +222,79 @@ public void renderArm(RenderArmEvent event) {
223222
}
224223

225224
@SubscribeEvent
226-
public void tickEnd(ClientTickEvent event) {
227-
if (event.phase == Phase.END) {
228-
//Note: We check that the game mode is not null as if it is that means the world is unloading, and we don't actually want to be rendering
229-
// as our data may be out of date or invalid. For example configs could unload while it is still unloading
230-
if (minecraft.player != null && minecraft.player.level() != null && !minecraft.isPaused() && minecraft.gameMode != null) {
231-
Player player = minecraft.player;
232-
Level world = minecraft.player.level();
233-
//Traverse active jetpacks and do animations
234-
for (UUID uuid : Mekanism.playerState.getActiveJetpacks()) {
235-
Player p = world.getPlayerByUUID(uuid);
236-
if (p != null) {
237-
Pos3D playerPos = new Pos3D(p).translate(0, p.getEyeHeight(), 0);
238-
Vec3 playerMotion = p.getDeltaMovement();
239-
float random = (world.random.nextFloat() - 0.5F) * 0.1F;
240-
//This positioning code is somewhat cursed, but it seems to be mostly working and entity pose code seems cursed in general
241-
float xRot;
242-
if (p.isCrouching()) {
243-
xRot = 20;
244-
playerPos = playerPos.translate(0, 0.125, 0);
225+
public void tickEnd(ClientTickEvent.Post event) {
226+
//Note: We check that the game mode is not null as if it is that means the world is unloading, and we don't actually want to be rendering
227+
// as our data may be out of date or invalid. For example configs could unload while it is still unloading
228+
if (minecraft.player != null && minecraft.player.level() != null && !minecraft.isPaused() && minecraft.gameMode != null) {
229+
Player player = minecraft.player;
230+
Level world = minecraft.player.level();
231+
//Traverse active jetpacks and do animations
232+
for (UUID uuid : Mekanism.playerState.getActiveJetpacks()) {
233+
Player p = world.getPlayerByUUID(uuid);
234+
if (p != null) {
235+
Pos3D playerPos = new Pos3D(p).translate(0, p.getEyeHeight(), 0);
236+
Vec3 playerMotion = p.getDeltaMovement();
237+
float random = (world.random.nextFloat() - 0.5F) * 0.1F;
238+
//This positioning code is somewhat cursed, but it seems to be mostly working and entity pose code seems cursed in general
239+
float xRot;
240+
if (p.isCrouching()) {
241+
xRot = 20;
242+
playerPos = playerPos.translate(0, 0.125, 0);
243+
} else {
244+
float f = p.getSwimAmount(minecraft.getPartialTick());
245+
if (p.isFallFlying()) {
246+
float f1 = (float) p.getFallFlyingTicks() + minecraft.getPartialTick();
247+
float f2 = Mth.clamp(f1 * f1 / 100.0F, 0.0F, 1.0F);
248+
xRot = f2 * (-90.0F - p.getXRot());
245249
} else {
246-
float f = p.getSwimAmount(minecraft.getPartialTick());
247-
if (p.isFallFlying()) {
248-
float f1 = (float) p.getFallFlyingTicks() + minecraft.getPartialTick();
249-
float f2 = Mth.clamp(f1 * f1 / 100.0F, 0.0F, 1.0F);
250-
xRot = f2 * (-90.0F - p.getXRot());
251-
} else {
252-
float f3 = p.isInWater() ? -90.0F - p.getXRot() : -90.0F;
253-
xRot = Mth.lerp(f, 0.0F, f3);
254-
}
255-
xRot = -xRot;
256-
Pos3D eyeAdjustments;
257-
if (p.isFallFlying() && (p != player || !minecraft.options.getCameraType().isFirstPerson())) {
258-
eyeAdjustments = new Pos3D(0, p.getEyeHeight(Pose.STANDING), 0).xRot(xRot).yRot(p.yBodyRot);
259-
} else if (p.isVisuallySwimming()) {
260-
eyeAdjustments = new Pos3D(0, p.getEyeHeight(), 0).xRot(xRot).yRot(p.yBodyRot).translate(0, 0.5, 0);
261-
} else {
262-
eyeAdjustments = new Pos3D(0, p.getEyeHeight(), 0).xRot(xRot).yRot(p.yBodyRot);
263-
}
264-
playerPos = new Pos3D(p.getX() + eyeAdjustments.x, p.getY() + eyeAdjustments.y, p.getZ() + eyeAdjustments.z);
250+
float f3 = p.isInWater() ? -90.0F - p.getXRot() : -90.0F;
251+
xRot = Mth.lerp(f, 0.0F, f3);
252+
}
253+
xRot = -xRot;
254+
Pos3D eyeAdjustments;
255+
if (p.isFallFlying() && (p != player || !minecraft.options.getCameraType().isFirstPerson())) {
256+
eyeAdjustments = new Pos3D(0, p.getEyeHeight(Pose.STANDING), 0).xRot(xRot).yRot(p.yBodyRot);
257+
} else if (p.isVisuallySwimming()) {
258+
eyeAdjustments = new Pos3D(0, p.getEyeHeight(), 0).xRot(xRot).yRot(p.yBodyRot).translate(0, 0.5, 0);
259+
} else {
260+
eyeAdjustments = new Pos3D(0, p.getEyeHeight(), 0).xRot(xRot).yRot(p.yBodyRot);
265261
}
266-
Pos3D vLeft = new Pos3D(-0.43, -0.55, -0.54).xRot(xRot).yRot(p.yBodyRot);
267-
renderJetpackSmoke(world, playerPos.translate(vLeft, playerMotion), vLeft.scale(0.2).translate(playerMotion, vLeft.scale(random)));
268-
Pos3D vRight = new Pos3D(0.43, -0.55, -0.54).xRot(xRot).yRot(p.yBodyRot);
269-
renderJetpackSmoke(world, playerPos.translate(vRight, playerMotion), vRight.scale(0.2).translate(playerMotion, vRight.scale(random)));
270-
Pos3D vCenter = new Pos3D((world.random.nextFloat() - 0.5) * 0.4, -0.86, -0.30).xRot(xRot).yRot(p.yBodyRot);
271-
renderJetpackSmoke(world, playerPos.translate(vCenter, playerMotion), vCenter.scale(0.2).translate(playerMotion));
262+
playerPos = new Pos3D(p.getX() + eyeAdjustments.x, p.getY() + eyeAdjustments.y, p.getZ() + eyeAdjustments.z);
272263
}
264+
Pos3D vLeft = new Pos3D(-0.43, -0.55, -0.54).xRot(xRot).yRot(p.yBodyRot);
265+
renderJetpackSmoke(world, playerPos.translate(vLeft, playerMotion), vLeft.scale(0.2).translate(playerMotion, vLeft.scale(random)));
266+
Pos3D vRight = new Pos3D(0.43, -0.55, -0.54).xRot(xRot).yRot(p.yBodyRot);
267+
renderJetpackSmoke(world, playerPos.translate(vRight, playerMotion), vRight.scale(0.2).translate(playerMotion, vRight.scale(random)));
268+
Pos3D vCenter = new Pos3D((world.random.nextFloat() - 0.5) * 0.4, -0.86, -0.30).xRot(xRot).yRot(p.yBodyRot);
269+
renderJetpackSmoke(world, playerPos.translate(vCenter, playerMotion), vCenter.scale(0.2).translate(playerMotion));
273270
}
271+
}
274272

275-
if (world.getGameTime() % 4 == 0) {
276-
//Traverse active scuba masks and do animations
277-
for (UUID uuid : Mekanism.playerState.getActiveScubaMasks()) {
278-
Player p = world.getPlayerByUUID(uuid);
279-
if (p != null && p.isInWater()) {
280-
Pos3D vec = new Pos3D(0.4, 0.4, 0.4).multiply(p.getViewVector(1)).translate(0, -0.2, 0);
281-
Pos3D motion = vec.scale(0.2).translate(p.getDeltaMovement());
282-
Pos3D v = new Pos3D(p).translate(0, p.getEyeHeight(), 0).translate(vec);
283-
world.addParticle(MekanismParticleTypes.SCUBA_BUBBLE.get(), v.x, v.y, v.z, motion.x, motion.y + 0.2, motion.z);
284-
}
273+
if (world.getGameTime() % 4 == 0) {
274+
//Traverse active scuba masks and do animations
275+
for (UUID uuid : Mekanism.playerState.getActiveScubaMasks()) {
276+
Player p = world.getPlayerByUUID(uuid);
277+
if (p != null && p.isInWater()) {
278+
Pos3D vec = new Pos3D(0.4, 0.4, 0.4).multiply(p.getViewVector(1)).translate(0, -0.2, 0);
279+
Pos3D motion = vec.scale(0.2).translate(p.getDeltaMovement());
280+
Pos3D v = new Pos3D(p).translate(0, p.getEyeHeight(), 0).translate(vec);
281+
world.addParticle(MekanismParticleTypes.SCUBA_BUBBLE.get(), v.x, v.y, v.z, motion.x, motion.y + 0.2, motion.z);
285282
}
286-
//Traverse players and do animations for idle flamethrowers
287-
for (Player p : world.players()) {
288-
if (!p.swinging) {
289-
if (player.isUsingItem()) {
290-
InteractionHand usedHand = player.getUsedItemHand();
291-
if (!(player.getItemInHand(usedHand).getItem() instanceof ItemFlamethrower)) {
292-
//If we the used item isn't a flamethrower, grab the other hand's item for checks
293-
// if it was an active flamethrower we just skip adding the idle particles
294-
tryAddIdleFlamethrowerParticles(minecraft, p, usedHand == InteractionHand.MAIN_HAND ? InteractionHand.OFF_HAND : InteractionHand.MAIN_HAND);
295-
}
296-
} else if (!tryAddIdleFlamethrowerParticles(minecraft, p, InteractionHand.MAIN_HAND)) {
297-
//If the player isn't using an item, try to first add particles for a flamethrower in the main hand
298-
// and then add particles for a flamethrower in the offhand if we failed
299-
tryAddIdleFlamethrowerParticles(minecraft, p, InteractionHand.OFF_HAND);
283+
}
284+
//Traverse players and do animations for idle flamethrowers
285+
for (Player p : world.players()) {
286+
if (!p.swinging) {
287+
if (player.isUsingItem()) {
288+
InteractionHand usedHand = player.getUsedItemHand();
289+
if (!(player.getItemInHand(usedHand).getItem() instanceof ItemFlamethrower)) {
290+
//If we the used item isn't a flamethrower, grab the other hand's item for checks
291+
// if it was an active flamethrower we just skip adding the idle particles
292+
tryAddIdleFlamethrowerParticles(minecraft, p, usedHand == InteractionHand.MAIN_HAND ? InteractionHand.OFF_HAND : InteractionHand.MAIN_HAND);
300293
}
294+
} else if (!tryAddIdleFlamethrowerParticles(minecraft, p, InteractionHand.MAIN_HAND)) {
295+
//If the player isn't using an item, try to first add particles for a flamethrower in the main hand
296+
// and then add particles for a flamethrower in the offhand if we failed
297+
tryAddIdleFlamethrowerParticles(minecraft, p, InteractionHand.OFF_HAND);
301298
}
302299
}
303300
}

src/main/java/mekanism/common/CommonPlayerTickHandler.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,12 @@
4646
import net.minecraft.world.phys.Vec3;
4747
import net.neoforged.bus.api.SubscribeEvent;
4848
import net.neoforged.neoforge.common.NeoForgeMod;
49-
import net.neoforged.neoforge.event.TickEvent.Phase;
50-
import net.neoforged.neoforge.event.TickEvent.PlayerTickEvent;
5149
import net.neoforged.neoforge.event.entity.living.LivingAttackEvent;
5250
import net.neoforged.neoforge.event.entity.living.LivingEvent.LivingJumpEvent;
5351
import net.neoforged.neoforge.event.entity.living.LivingFallEvent;
5452
import net.neoforged.neoforge.event.entity.living.LivingHurtEvent;
5553
import net.neoforged.neoforge.event.entity.player.PlayerEvent.BreakSpeed;
54+
import net.neoforged.neoforge.event.tick.PlayerTickEvent;
5655
import org.jetbrains.annotations.Nullable;
5756

5857
public class CommonPlayerTickHandler {
@@ -92,9 +91,9 @@ public static float getSwimBoost(Player player) {
9291
}
9392

9493
@SubscribeEvent
95-
public void onTick(PlayerTickEvent event) {
96-
if (event.phase == Phase.END && event.side.isServer()) {
97-
tickEnd(event.player);
94+
public void onTick(PlayerTickEvent.Post event) {
95+
if (!event.getEntity().level().isClientSide()) {
96+
tickEnd(event.getEntity());
9897
}
9998
}
10099

0 commit comments

Comments
 (0)