Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ public interface WorldViewExtension {

BlockEntity getBlockEntity(BlockPos pos);

BlockEntity getBlockEntity(int x, int y, int z);

static boolean isInsideWorldHeight(BlockPos pos) {
return isInsideWorldHeight(pos.y());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import net.ornithemc.osl.core.api.util.math.BlockPos;

@Mixin(World.class)
public class WorldMixin implements WorldExtension {
public abstract class WorldMixin implements WorldExtension {

@Shadow
private boolean isMultiplayer;
Expand All @@ -26,8 +26,6 @@ public class WorldMixin implements WorldExtension {
@Shadow
private void onBlockChanged(int x, int y, int z, int block) { }
@Shadow
private BlockEntity getBlockEntity(int x, int y, int z) { return null; }
@Shadow
private void setBlockEntity(int x, int y, int z, BlockEntity blockEntity) { }

@ModifyVariable(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;

import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;

import net.minecraft.block.entity.BlockEntity;
import net.minecraft.world.WorldRegion;
import net.minecraft.world.chunk.WorldChunk;
Expand All @@ -22,9 +25,6 @@ public class WorldRegionMixin implements WorldViewExtension {
@Shadow
private WorldChunk[][] chunks;

@Shadow
private BlockEntity getBlockEntity(int x, int y, int z) { return null; }

@Override
public BlockState getBlockState(BlockPos pos) {
return this.getBlockState(pos.x(), pos.y(), pos.z());
Expand Down Expand Up @@ -52,4 +52,13 @@ public BlockState getBlockState(int x, int y, int z) {
public BlockEntity getBlockEntity(BlockPos pos) {
return this.getBlockEntity(pos.x(), pos.y(), pos.z());
}

@Environment(EnvType.SERVER)
@Override
public BlockEntity getBlockEntity(int x, int y, int z) {
int indexX = (x >> 4) - this.chunkX;
int indexZ = (z >> 4) - this.chunkZ;

return this.chunks[indexX][indexZ].getBlockEntityAt(x & 15, y, z & 15);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,9 @@ default BlockState getBlockState(int x, int y, int z) {
default BlockEntity getBlockEntity(BlockPos pos) {
throw new AbstractMethodError();
}

@Override
default BlockEntity getBlockEntity(int x, int y, int z) {
throw new AbstractMethodError();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ public interface WorldViewExtension {

BlockEntity getBlockEntity(BlockPos pos);

BlockEntity getBlockEntity(int x, int y, int z);

static boolean isInsideWorldHeight(BlockPos pos) {
return isInsideWorldHeight(pos.y());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import net.ornithemc.osl.core.api.util.math.BlockPos;

@Mixin(World.class)
public class WorldMixin implements WorldExtension {
public abstract class WorldMixin implements WorldExtension {

@Shadow
private boolean isMultiplayer;
Expand All @@ -26,8 +26,6 @@ public class WorldMixin implements WorldExtension {
@Shadow
private void onBlockChanged(int x, int y, int z, int block) { }
@Shadow
private BlockEntity getBlockEntity(int x, int y, int z) { return null; }
@Shadow
private void setBlockEntity(int x, int y, int z, BlockEntity blockEntity) { }

@ModifyVariable(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;

import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;

import net.minecraft.block.entity.BlockEntity;
import net.minecraft.world.WorldRegion;
import net.minecraft.world.chunk.WorldChunk;
Expand All @@ -22,9 +25,6 @@ public class WorldRegionMixin implements WorldViewExtension {
@Shadow
private WorldChunk[][] chunks;

@Shadow
private BlockEntity getBlockEntity(int x, int y, int z) { return null; }

@Override
public BlockState getBlockState(BlockPos pos) {
return this.getBlockState(pos.x(), pos.y(), pos.z());
Expand Down Expand Up @@ -52,4 +52,13 @@ public BlockState getBlockState(int x, int y, int z) {
public BlockEntity getBlockEntity(BlockPos pos) {
return this.getBlockEntity(pos.x(), pos.y(), pos.z());
}

@Environment(EnvType.SERVER)
@Override
public BlockEntity getBlockEntity(int x, int y, int z) {
int indexX = (x >> 4) - this.chunkX;
int indexZ = (z >> 4) - this.chunkZ;

return this.chunks[indexX][indexZ].getBlockEntityAt(x & 15, y, z & 15);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,9 @@ default BlockState getBlockState(int x, int y, int z) {
default BlockEntity getBlockEntity(BlockPos pos) {
throw new AbstractMethodError();
}

@Override
default BlockEntity getBlockEntity(int x, int y, int z) {
throw new AbstractMethodError();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ public interface WorldViewExtension {

BlockEntity getBlockEntity(BlockPos pos);

BlockEntity getBlockEntity(int x, int y, int z);

static boolean isInsideWorldHeight(BlockPos pos) {
return isInsideWorldHeight(pos.y());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import net.ornithemc.osl.core.api.util.math.BlockPos;

@Mixin(World.class)
public class WorldMixin implements WorldExtension {
public abstract class WorldMixin implements WorldExtension {

@Shadow
private boolean isMultiplayer;
Expand All @@ -28,8 +28,6 @@ private void onBlockChanged(int x, int y, int z, int block) { }
@Shadow
private void updateNeighbors(int x, int y, int z, int block) { }
@Shadow
private BlockEntity getBlockEntity(int x, int y, int z) { return null; }
@Shadow
private void setBlockEntity(int x, int y, int z, BlockEntity blockEntity) { }

@ModifyVariable(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;

import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;

import net.minecraft.block.entity.BlockEntity;
import net.minecraft.world.WorldRegion;
import net.minecraft.world.chunk.WorldChunk;
Expand All @@ -22,9 +25,6 @@ public class WorldRegionMixin implements WorldViewExtension {
@Shadow
private WorldChunk[][] chunks;

@Shadow
private BlockEntity getBlockEntity(int x, int y, int z) { return null; }

@Override
public BlockState getBlockState(BlockPos pos) {
return this.getBlockState(pos.x(), pos.y(), pos.z());
Expand Down Expand Up @@ -52,4 +52,13 @@ public BlockState getBlockState(int x, int y, int z) {
public BlockEntity getBlockEntity(BlockPos pos) {
return this.getBlockEntity(pos.x(), pos.y(), pos.z());
}

@Environment(EnvType.SERVER)
@Override
public BlockEntity getBlockEntity(int x, int y, int z) {
int indexX = (x >> 4) - this.chunkX;
int indexZ = (z >> 4) - this.chunkZ;

return this.chunks[indexX][indexZ].getBlockEntityAt(x & 15, y, z & 15);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,9 @@ default BlockState getBlockState(int x, int y, int z) {
default BlockEntity getBlockEntity(BlockPos pos) {
throw new AbstractMethodError();
}

@Override
default BlockEntity getBlockEntity(int x, int y, int z) {
throw new AbstractMethodError();
}
}
Loading