fix loot NPE

This commit is contained in:
dfsek 2021-05-02 23:08:54 -07:00
parent 3b9280b19c
commit 4cd4720101
5 changed files with 10 additions and 11 deletions

View File

@ -40,7 +40,7 @@ public class BufferedLootApplication implements BufferedItem {
data.update(false); data.update(false);
} catch(Exception e) { } catch(Exception e) {
main.logger().warning("Could not apply loot at " + origin + ": " + e.getMessage()); main.logger().warning("Could not apply loot at " + origin + ": " + e.getMessage());
main.getDebugLogger().stack(e); e.printStackTrace();
} }
} }
} }

View File

@ -21,7 +21,7 @@ public class BufferedStateManipulator implements BufferedItem {
state.update(false); state.update(false);
} catch(Exception e) { } catch(Exception e) {
main.logger().warning("Could not apply BlockState at " + origin + ": " + e.getMessage()); main.logger().warning("Could not apply BlockState at " + origin + ": " + e.getMessage());
main.getDebugLogger().stack(e); e.printStackTrace();
} }
} }
} }

View File

@ -26,6 +26,9 @@ public abstract class BlockEntityMixin {
@Shadow @Shadow
public abstract net.minecraft.block.BlockState getCachedState(); public abstract net.minecraft.block.BlockState getCachedState();
@Shadow
public abstract boolean hasWorld();
public Object terra$getHandle() { public Object terra$getHandle() {
return this; return this;
} }
@ -51,7 +54,7 @@ public abstract class BlockEntityMixin {
} }
public boolean terra$update(boolean applyPhysics) { public boolean terra$update(boolean applyPhysics) {
world.getChunk(pos).setBlockEntity(pos, (BlockEntity) (Object) this); if(hasWorld()) world.getChunk(pos).setBlockEntity(pos, (BlockEntity) (Object) this);
return true; return true;
} }
} }

View File

@ -4,11 +4,9 @@ import com.dfsek.terra.api.math.vector.Location;
import com.dfsek.terra.api.platform.world.World; import com.dfsek.terra.api.platform.world.World;
import com.dfsek.terra.fabric.world.FabricAdapter; import com.dfsek.terra.fabric.world.FabricAdapter;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.text.LiteralText; import net.minecraft.text.LiteralText;
import net.minecraft.text.Text; import net.minecraft.text.Text;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import org.jetbrains.annotations.Nullable;
import org.spongepowered.asm.mixin.Implements; import org.spongepowered.asm.mixin.Implements;
import org.spongepowered.asm.mixin.Interface; import org.spongepowered.asm.mixin.Interface;
import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mixin;
@ -28,10 +26,6 @@ public abstract class EntityMixin {
@Shadow @Shadow
public abstract void teleport(double destX, double destY, double destZ); public abstract void teleport(double destX, double destY, double destZ);
@Shadow
@Nullable
public abstract Entity moveToWorld(ServerWorld destination);
@Shadow @Shadow
public abstract void sendSystemMessage(Text message, UUID senderUuid); public abstract void sendSystemMessage(Text message, UUID senderUuid);
@ -45,7 +39,6 @@ public abstract class EntityMixin {
public void terra$setLocation(Location location) { public void terra$setLocation(Location location) {
teleport(location.getX(), location.getY(), location.getZ()); teleport(location.getX(), location.getY(), location.getZ());
moveToWorld((ServerWorld) location.getWorld());
} }
public World getWorld() { public World getWorld() {

View File

@ -37,7 +37,10 @@ public abstract class ChunkRegionWorldMixin {
} }
public Entity terra$spawnEntity(Location location, EntityType entityType) { public Entity terra$spawnEntity(Location location, EntityType entityType) {
throw new UnsupportedOperationException(); net.minecraft.entity.Entity entity = ((net.minecraft.entity.EntityType<?>) entityType).create(((ChunkRegion) (Object) this).toServerWorld());
entity.setPos(location.getX(), location.getY(), location.getZ());
((ChunkRegion) (Object) this).spawnEntity(entity);
return (Entity) entity;
} }
public int terra$getMinHeight() { public int terra$getMinHeight() {