Remove Entity#level AT

Use an invoker for Entity#setLevel() instead
This commit is contained in:
PepperCode1 2023-08-25 16:15:12 -07:00
parent 78cf451f6d
commit 7021a17226
5 changed files with 20 additions and 3 deletions

View File

@ -0,0 +1,13 @@
package com.simibubi.create.foundation.mixin.accessor;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Invoker;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.level.Level;
@Mixin(Entity.class)
public interface EntityAccessor {
@Invoker("setLevel")
void create$callSetLevel(Level level);
}

View File

@ -5,6 +5,8 @@ import java.util.List;
import javax.annotation.ParametersAreNonnullByDefault;
import com.simibubi.create.foundation.mixin.accessor.EntityAccessor;
import net.minecraft.MethodsReturnNonnullByDefault;
import net.minecraft.Util;
import net.minecraft.core.BlockPos;
@ -93,7 +95,7 @@ public class WrappedServerWorld extends ServerLevel {
@Override
public boolean addFreshEntity(Entity entityIn) {
entityIn.level = world;
((EntityAccessor) entityIn).create$callSetLevel(world);
return world.addFreshEntity(entityIn);
}

View File

@ -6,6 +6,8 @@ import java.util.function.Predicate;
import javax.annotation.Nullable;
import com.simibubi.create.foundation.mixin.accessor.EntityAccessor;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.core.Holder;
@ -146,7 +148,7 @@ public class WrappedWorld extends Level {
@Override
public boolean addFreshEntity(Entity entityIn) {
entityIn.level = world;
((EntityAccessor) entityIn).create$callSetLevel(world);
return world.addFreshEntity(entityIn);
}

View File

@ -14,7 +14,6 @@ public net.minecraft.server.network.ServerGamePacketListenerImpl f_9737_ # above
public net.minecraft.server.network.ServerGamePacketListenerImpl f_9739_ # aboveGroundVehicleTickCount
public net.minecraft.world.entity.Entity f_146795_ # removalReason
public net.minecraft.world.entity.Entity f_19853_ # level
protected net.minecraft.world.entity.Entity m_19956_(Lnet/minecraft/world/entity/Entity;Lnet/minecraft/world/entity/Entity$MoveFunction;)V # positionRider
public net.minecraft.world.entity.LivingEntity f_20899_ # jumping

View File

@ -16,6 +16,7 @@
"TestCommandMixin",
"accessor.AbstractProjectileDispenseBehaviorAccessor",
"accessor.DispenserBlockAccessor",
"accessor.EntityAccessor",
"accessor.FallingBlockEntityAccessor",
"accessor.GameTestHelperAccessor",
"accessor.LivingEntityAccessor",