refactor mixins

This commit is contained in:
dfsek 2021-05-02 22:48:21 -07:00
parent 146f71f704
commit 20a5762d2e
17 changed files with 95 additions and 85 deletions

View File

@ -17,7 +17,7 @@ import org.spongepowered.asm.mixin.Shadow;
import java.util.UUID; import java.util.UUID;
@Mixin(Entity.class) @Mixin(Entity.class)
@Implements(@Interface(iface = com.dfsek.terra.api.platform.entity.Entity.class, prefix = "vw$")) @Implements(@Interface(iface = com.dfsek.terra.api.platform.entity.Entity.class, prefix = "terra$"))
public abstract class EntityMixin { public abstract class EntityMixin {
@Shadow @Shadow
public net.minecraft.world.World world; public net.minecraft.world.World world;
@ -35,15 +35,15 @@ public abstract class EntityMixin {
@Shadow @Shadow
public abstract void sendSystemMessage(Text message, UUID senderUuid); public abstract void sendSystemMessage(Text message, UUID senderUuid);
public Object vw$getHandle() { public Object terra$getHandle() {
return this; return this;
} }
public Location vw$getLocation() { public Location terra$getLocation() {
return new Location((World) world, FabricAdapter.adapt(blockPos)); return new Location((World) world, FabricAdapter.adapt(blockPos));
} }
public void vw$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()); moveToWorld((ServerWorld) location.getWorld());
} }
@ -52,7 +52,7 @@ public abstract class EntityMixin {
return (World) world; return (World) world;
} }
public void vw$sendMessage(String message) { public void terra$sendMessage(String message) {
sendSystemMessage(new LiteralText(message), UUID.randomUUID()); // TODO: look into how this actually works and make it less jank sendSystemMessage(new LiteralText(message), UUID.randomUUID()); // TODO: look into how this actually works and make it less jank
} }
} }

View File

@ -6,9 +6,9 @@ import org.spongepowered.asm.mixin.Interface;
import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mixin;
@Mixin(EntityType.class) @Mixin(EntityType.class)
@Implements(@Interface(iface = com.dfsek.terra.api.platform.entity.EntityType.class, prefix = "vw$")) @Implements(@Interface(iface = com.dfsek.terra.api.platform.entity.EntityType.class, prefix = "terra$"))
public abstract class EntityTypeMixin { public abstract class EntityTypeMixin {
public Object vw$getHandle() { public Object terra$getHandle() {
return this; return this;
} }
} }

View File

@ -7,7 +7,7 @@ import org.spongepowered.asm.mixin.Interface;
import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mixin;
@Mixin(PlayerEntity.class) @Mixin(PlayerEntity.class)
@Implements(@Interface(iface = Player.class, prefix = "vw$")) @Implements(@Interface(iface = Player.class, prefix = "terra$"))
public abstract class PlayerEntityMixin extends EntityMixin { public abstract class PlayerEntityMixin extends EntityMixin {
} }

View File

@ -10,16 +10,16 @@ import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.Shadow;
@Mixin(ServerCommandSource.class) @Mixin(ServerCommandSource.class)
@Implements(@Interface(iface = CommandSender.class, prefix = "vw$")) @Implements(@Interface(iface = CommandSender.class, prefix = "terra$"))
public abstract class ServerCommandSourceMixin { public abstract class ServerCommandSourceMixin {
@Shadow @Shadow
public abstract void sendFeedback(Text message, boolean broadcastToOps); public abstract void sendFeedback(Text message, boolean broadcastToOps);
public void vw$sendMessage(String message) { public void terra$sendMessage(String message) {
sendFeedback(new LiteralText(message), true); sendFeedback(new LiteralText(message), true);
} }
public Object vw$getHandle() { public Object terra$getHandle() {
return this; return this;
} }
} }

View File

@ -1,7 +1,6 @@
package com.dfsek.terra.fabric.mixin.inventory; package com.dfsek.terra.fabric.mixin.inventory;
import com.dfsek.terra.api.platform.inventory.ItemStack; import com.dfsek.terra.api.platform.inventory.ItemStack;
import com.dfsek.terra.fabric.world.FabricAdapter;
import net.minecraft.enchantment.Enchantment; import net.minecraft.enchantment.Enchantment;
import net.minecraft.util.registry.Registry; import net.minecraft.util.registry.Registry;
import org.spongepowered.asm.mixin.Implements; import org.spongepowered.asm.mixin.Implements;
@ -12,7 +11,7 @@ import org.spongepowered.asm.mixin.Shadow;
import java.util.Objects; import java.util.Objects;
@Mixin(Enchantment.class) @Mixin(Enchantment.class)
@Implements(@Interface(iface = com.dfsek.terra.api.platform.inventory.item.Enchantment.class, prefix = "vw$")) @Implements(@Interface(iface = com.dfsek.terra.api.platform.inventory.item.Enchantment.class, prefix = "terra$"))
public abstract class EnchantmentMixin { public abstract class EnchantmentMixin {
@Shadow @Shadow
public abstract boolean isAcceptableItem(net.minecraft.item.ItemStack stack); public abstract boolean isAcceptableItem(net.minecraft.item.ItemStack stack);
@ -20,20 +19,20 @@ public abstract class EnchantmentMixin {
@Shadow @Shadow
public abstract boolean canCombine(Enchantment other); public abstract boolean canCombine(Enchantment other);
public Object vw$getHandle() { public Object terra$getHandle() {
return this; return this;
} }
@SuppressWarnings("ConstantConditions") @SuppressWarnings("ConstantConditions")
public boolean vw$canEnchantItem(ItemStack itemStack) { public boolean terra$canEnchantItem(ItemStack itemStack) {
return isAcceptableItem((net.minecraft.item.ItemStack) (Object) itemStack); return isAcceptableItem((net.minecraft.item.ItemStack) (Object) itemStack);
} }
public String vw$getID() { public String terra$getID() {
return Objects.requireNonNull(Registry.ENCHANTMENT.getId((Enchantment) (Object) this)).toString(); return Objects.requireNonNull(Registry.ENCHANTMENT.getId((Enchantment) (Object) this)).toString();
} }
public boolean vw$conflictsWith(com.dfsek.terra.api.platform.inventory.item.Enchantment other) { public boolean terra$conflictsWith(com.dfsek.terra.api.platform.inventory.item.Enchantment other) {
return !canCombine((Enchantment) other); return !canCombine((Enchantment) other);
} }
} }

View File

@ -8,21 +8,21 @@ import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.Shadow;
@Mixin(Item.class) @Mixin(Item.class)
@Implements(@Interface(iface = com.dfsek.terra.api.platform.inventory.Item.class, prefix = "vw$")) @Implements(@Interface(iface = com.dfsek.terra.api.platform.inventory.Item.class, prefix = "terra$"))
public abstract class ItemMixin { public abstract class ItemMixin {
@Shadow @Shadow
public abstract int getMaxDamage(); public abstract int getMaxDamage();
public Object vw$getHandle() { public Object terra$getHandle() {
return this; return this;
} }
@SuppressWarnings("ConstantConditions") @SuppressWarnings("ConstantConditions")
public ItemStack vw$newItemStack(int amount) { public ItemStack terra$newItemStack(int amount) {
return (ItemStack) (Object) new net.minecraft.item.ItemStack((Item) (Object) this, amount); return (ItemStack) (Object) new net.minecraft.item.ItemStack((Item) (Object) this, amount);
} }
public double vw$getMaxDurability() { public double terra$getMaxDurability() {
return getMaxDamage(); return getMaxDamage();
} }
} }

View File

@ -8,12 +8,12 @@ import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.Shadow;
@Mixin(ItemStack.class) @Mixin(ItemStack.class)
@Implements(@Interface(iface = Damageable.class, prefix = "vw$")) @Implements(@Interface(iface = Damageable.class, prefix = "terra$"))
public abstract class ItemStackDamageableMixin { public abstract class ItemStackDamageableMixin {
@Shadow @Shadow
public abstract boolean isDamaged(); public abstract boolean isDamaged();
public boolean vw$hasDamage() { public boolean terra$hasDamage() {
return isDamaged(); return isDamaged();
} }
} }

View File

@ -2,7 +2,6 @@ package com.dfsek.terra.fabric.mixin.inventory;
import com.dfsek.terra.api.platform.inventory.item.Enchantment; import com.dfsek.terra.api.platform.inventory.item.Enchantment;
import com.dfsek.terra.api.platform.inventory.item.ItemMeta; import com.dfsek.terra.api.platform.inventory.item.ItemMeta;
import com.dfsek.terra.fabric.world.FabricAdapter;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.ListTag; import net.minecraft.nbt.ListTag;
@ -17,7 +16,7 @@ import java.util.HashMap;
import java.util.Map; import java.util.Map;
@Mixin(ItemStack.class) @Mixin(ItemStack.class)
@Implements(@Interface(iface = ItemMeta.class, prefix = "vw$")) @Implements(@Interface(iface = ItemMeta.class, prefix = "terra$"))
public abstract class ItemStackMetaMixin { public abstract class ItemStackMetaMixin {
@Shadow @Shadow
public abstract boolean hasEnchantments(); public abstract boolean hasEnchantments();
@ -28,11 +27,11 @@ public abstract class ItemStackMetaMixin {
@Shadow @Shadow
public abstract void addEnchantment(net.minecraft.enchantment.Enchantment enchantment, int level); public abstract void addEnchantment(net.minecraft.enchantment.Enchantment enchantment, int level);
public Object vw$getHandle() { public Object terra$getHandle() {
return this; return this;
} }
public Map<Enchantment, Integer> vw$getEnchantments() { public Map<Enchantment, Integer> terra$getEnchantments() {
if(!hasEnchantments()) return Collections.emptyMap(); if(!hasEnchantments()) return Collections.emptyMap();
Map<Enchantment, Integer> map = new HashMap<>(); Map<Enchantment, Integer> map = new HashMap<>();
@ -43,7 +42,7 @@ public abstract class ItemStackMetaMixin {
return map; return map;
} }
public void vw$addEnchantment(Enchantment enchantment, int level) { public void terra$addEnchantment(Enchantment enchantment, int level) {
addEnchantment((net.minecraft.enchantment.Enchantment) enchantment, level); addEnchantment((net.minecraft.enchantment.Enchantment) enchantment, level);
} }
} }

View File

@ -9,7 +9,7 @@ import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.Shadow;
@Mixin(ItemStack.class) @Mixin(ItemStack.class)
@Implements(@Interface(iface = com.dfsek.terra.api.platform.inventory.ItemStack.class, prefix = "vw$")) @Implements(@Interface(iface = com.dfsek.terra.api.platform.inventory.ItemStack.class, prefix = "terra$"))
public abstract class ItemStackMixin { public abstract class ItemStackMixin {
@Shadow @Shadow
public abstract int getCount(); public abstract int getCount();
@ -26,11 +26,11 @@ public abstract class ItemStackMixin {
@Shadow @Shadow
public abstract ItemStack copy(); public abstract ItemStack copy();
public int vw$getAmount() { public int terra$getAmount() {
return getCount(); return getCount();
} }
public void vw$setAmount(int i) { public void terra$setAmount(int i) {
setCount(i); setCount(i);
} }
@ -38,15 +38,15 @@ public abstract class ItemStackMixin {
return (Item) getItem(); return (Item) getItem();
} }
public ItemMeta vw$getItemMeta() { public ItemMeta terra$getItemMeta() {
return (ItemMeta) this; return (ItemMeta) this;
} }
public void vw$setItemMeta(ItemMeta meta) { public void terra$setItemMeta(ItemMeta meta) {
} }
public Object vw$getHandle() { public Object terra$getHandle() {
return this; return this;
} }
} }

View File

@ -0,0 +1,12 @@
package com.dfsek.terra.fabric.mixin.world;
import net.minecraft.world.biome.Biome;
import org.spongepowered.asm.mixin.Implements;
import org.spongepowered.asm.mixin.Interface;
import org.spongepowered.asm.mixin.Mixin;
@Mixin(Biome.class)
@Implements(@Interface(iface = com.dfsek.terra.api.platform.world.Biome.class, prefix = "terra$"))
public class BiomeMixin {
}

View File

@ -6,9 +6,9 @@ import org.spongepowered.asm.mixin.Interface;
import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mixin;
@Mixin(ChunkGenerator.class) @Mixin(ChunkGenerator.class)
@Implements(@Interface(iface = com.dfsek.terra.api.platform.world.generator.ChunkGenerator.class, prefix = "vw$")) @Implements(@Interface(iface = com.dfsek.terra.api.platform.world.generator.ChunkGenerator.class, prefix = "terra$"))
public abstract class ChunkGeneratorMixin { public abstract class ChunkGeneratorMixin {
public Object vw$getHandle() { public Object terra$getHandle() {
return this; return this;
} }
} }

View File

@ -16,7 +16,7 @@ import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.Shadow;
@Mixin(ChunkRegion.class) @Mixin(ChunkRegion.class)
@Implements(@Interface(iface = Chunk.class, prefix = "vw$")) @Implements(@Interface(iface = Chunk.class, prefix = "terra$"))
public abstract class ChunkRegionMixin { public abstract class ChunkRegionMixin {
@Final @Final
@Shadow @Shadow
@ -26,32 +26,32 @@ public abstract class ChunkRegionMixin {
@Shadow @Shadow
private int centerChunkZ; private int centerChunkZ;
public int vw$getX() { public int terra$getX() {
return centerChunkX; return centerChunkX;
} }
public int vw$getZ() { public int terra$getZ() {
return centerChunkZ; return centerChunkZ;
} }
public World vw$getWorld() { public World terra$getWorld() {
return (World) this; return (World) this;
} }
public Block vw$getBlock(int x, int y, int z) { public Block terra$getBlock(int x, int y, int z) {
BlockPos pos = new BlockPos(x + (centerChunkX << 4), y, z + (centerChunkZ << 4)); BlockPos pos = new BlockPos(x + (centerChunkX << 4), y, z + (centerChunkZ << 4));
return new FabricBlock(pos, (ChunkRegion) (Object) this); return new FabricBlock(pos, (ChunkRegion) (Object) this);
} }
public @NotNull BlockData vw$getBlockData(int x, int y, int z) { public @NotNull BlockData terra$getBlockData(int x, int y, int z) {
return vw$getBlock(x, y, z).getBlockData(); return terra$getBlock(x, y, z).getBlockData();
} }
public void vw$setBlock(int x, int y, int z, @NotNull BlockData blockData) { public void terra$setBlock(int x, int y, int z, @NotNull BlockData blockData) {
((ChunkRegion) (Object) this).setBlockState(new BlockPos(x + (centerChunkX << 4), y, z + (centerChunkZ << 4)), ((FabricBlockData) blockData).getHandle(), 0); ((ChunkRegion) (Object) this).setBlockState(new BlockPos(x + (centerChunkX << 4), y, z + (centerChunkZ << 4)), ((FabricBlockData) blockData).getHandle(), 0);
} }
public Object vw$getHandle() { public Object terra$getHandle() {
return this; return this;
} }
} }

View File

@ -11,7 +11,6 @@ import com.dfsek.terra.api.platform.world.generator.GeneratorWrapper;
import com.dfsek.terra.api.world.generation.TerraChunkGenerator; import com.dfsek.terra.api.world.generation.TerraChunkGenerator;
import com.dfsek.terra.fabric.world.block.FabricBlock; import com.dfsek.terra.fabric.world.block.FabricBlock;
import com.dfsek.terra.fabric.world.generator.FabricChunkGeneratorWrapper; import com.dfsek.terra.fabric.world.generator.FabricChunkGeneratorWrapper;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.world.ChunkRegion; import net.minecraft.world.ChunkRegion;
import org.spongepowered.asm.mixin.Implements; import org.spongepowered.asm.mixin.Implements;
@ -19,41 +18,41 @@ import org.spongepowered.asm.mixin.Interface;
import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mixin;
@Mixin(ChunkRegion.class) @Mixin(ChunkRegion.class)
@Implements(@Interface(iface = World.class, prefix = "vw$")) @Implements(@Interface(iface = World.class, prefix = "terra$"))
public abstract class ChunkRegionWorldMixin { public abstract class ChunkRegionWorldMixin {
public int vw$getMaxHeight() { public int terra$getMaxHeight() {
return ((ChunkRegion) (Object) this).getDimensionHeight(); return ((ChunkRegion) (Object) this).getDimensionHeight();
} }
public ChunkGenerator vw$getGenerator() { public ChunkGenerator terra$getGenerator() {
return (ChunkGenerator) ((ChunkRegion) (Object) this).toServerWorld().getChunkManager().getChunkGenerator(); return (ChunkGenerator) ((ChunkRegion) (Object) this).toServerWorld().getChunkManager().getChunkGenerator();
} }
public Chunk vw$getChunkAt(int x, int z) { public Chunk terra$getChunkAt(int x, int z) {
return (Chunk) ((ChunkRegion) (Object) this).getChunk(x, z); return (Chunk) ((ChunkRegion) (Object) this).getChunk(x, z);
} }
public Block vw$getBlockAt(int x, int y, int z) { public Block terra$getBlockAt(int x, int y, int z) {
return new FabricBlock(new BlockPos(x, y, z), ((ChunkRegion) (Object) this)); return new FabricBlock(new BlockPos(x, y, z), ((ChunkRegion) (Object) this));
} }
public Entity vw$spawnEntity(Location location, EntityType entityType) { public Entity terra$spawnEntity(Location location, EntityType entityType) {
throw new UnsupportedOperationException(); throw new UnsupportedOperationException();
} }
public int vw$getMinHeight() { public int terra$getMinHeight() {
return 0; return 0;
} }
public Object vw$getHandle() { public Object terra$getHandle() {
return this; return this;
} }
public boolean vw$isTerraWorld() { public boolean terra$isTerraWorld() {
return vw$getGenerator() instanceof GeneratorWrapper; return terra$getGenerator() instanceof GeneratorWrapper;
} }
public TerraChunkGenerator vw$getTerraGenerator() { public TerraChunkGenerator terra$getTerraGenerator() {
return ((FabricChunkGeneratorWrapper) vw$getGenerator()).getHandle(); return ((FabricChunkGeneratorWrapper) terra$getGenerator()).getHandle();
} }
} }

View File

@ -13,24 +13,24 @@ import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.Shadow;
@Mixin(ProtoChunk.class) @Mixin(ProtoChunk.class)
@Implements(@Interface(iface = ChunkData.class, prefix = "vw$")) @Implements(@Interface(iface = ChunkData.class, prefix = "terra$"))
public abstract class ProtoChunkMixin { public abstract class ProtoChunkMixin {
@Shadow @Shadow
public abstract BlockState getBlockState(BlockPos pos); public abstract BlockState getBlockState(BlockPos pos);
public @NotNull BlockData vw$getBlockData(int x, int y, int z) { public @NotNull BlockData terra$getBlockData(int x, int y, int z) {
return new FabricBlockData(getBlockState(new BlockPos(x, y, z))); return new FabricBlockData(getBlockState(new BlockPos(x, y, z)));
} }
public void vw$setBlock(int x, int y, int z, @NotNull BlockData blockData) { public void terra$setBlock(int x, int y, int z, @NotNull BlockData blockData) {
((net.minecraft.world.chunk.Chunk) this).setBlockState(new BlockPos(x, y, z), ((FabricBlockData) blockData).getHandle(), false); ((net.minecraft.world.chunk.Chunk) this).setBlockState(new BlockPos(x, y, z), ((FabricBlockData) blockData).getHandle(), false);
} }
public Object vw$getHandle() { public Object terra$getHandle() {
return this; return this;
} }
public int vw$getMaxHeight() { public int terra$getMaxHeight() {
return 255; // TODO: 1.17 - Implement dynamic height. return 255; // TODO: 1.17 - Implement dynamic height.
} }
} }

View File

@ -18,44 +18,44 @@ import org.spongepowered.asm.mixin.Interface;
import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mixin;
@Mixin(ServerWorld.class) @Mixin(ServerWorld.class)
@Implements(@Interface(iface = World.class, prefix = "vw$")) @Implements(@Interface(iface = World.class, prefix = "terra$"))
public abstract class ServerWorldMixin { public abstract class ServerWorldMixin {
public int vw$getMaxHeight() { public int terra$getMaxHeight() {
return ((ServerWorld) (Object) this).getDimensionHeight(); return ((ServerWorld) (Object) this).getDimensionHeight();
} }
public ChunkGenerator vw$getGenerator() { public ChunkGenerator terra$getGenerator() {
return (ChunkGenerator) ((ServerWorld) (Object) this).getChunkManager().getChunkGenerator(); return (ChunkGenerator) ((ServerWorld) (Object) this).getChunkManager().getChunkGenerator();
} }
public Chunk vw$getChunkAt(int x, int z) { public Chunk terra$getChunkAt(int x, int z) {
return (Chunk) ((ServerWorld) (Object) this).getChunk(x, z); return (Chunk) ((ServerWorld) (Object) this).getChunk(x, z);
} }
public Block vw$getBlockAt(int x, int y, int z) { public Block terra$getBlockAt(int x, int y, int z) {
return new FabricBlock(new BlockPos(x, y, z), ((ServerWorld) (Object) this)); return new FabricBlock(new BlockPos(x, y, z), ((ServerWorld) (Object) this));
} }
public Entity vw$spawnEntity(Location location, EntityType entityType) { public Entity terra$spawnEntity(Location location, EntityType entityType) {
net.minecraft.entity.Entity entity = ((net.minecraft.entity.EntityType<?>) entityType).create(((ServerWorld) (Object) this)); net.minecraft.entity.Entity entity = ((net.minecraft.entity.EntityType<?>) entityType).create(((ServerWorld) (Object) this));
entity.setPos(location.getX(), location.getY(), location.getZ()); entity.setPos(location.getX(), location.getY(), location.getZ());
((ServerWorld) (Object) this).spawnEntity(entity); ((ServerWorld) (Object) this).spawnEntity(entity);
return (Entity) entity; return (Entity) entity;
} }
public int vw$getMinHeight() { public int terra$getMinHeight() {
return 0; return 0;
} }
public Object vw$getHandle() { public Object terra$getHandle() {
return this; return this;
} }
public boolean vw$isTerraWorld() { public boolean terra$isTerraWorld() {
return vw$getGenerator() instanceof GeneratorWrapper; return terra$getGenerator() instanceof GeneratorWrapper;
} }
public TerraChunkGenerator vw$getTerraGenerator() { public TerraChunkGenerator terra$getTerraGenerator() {
return ((FabricChunkGeneratorWrapper) vw$getGenerator()).getHandle(); return ((FabricChunkGeneratorWrapper) terra$getGenerator()).getHandle();
} }
} }

View File

@ -16,38 +16,38 @@ import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.Shadow;
@Mixin(WorldChunk.class) @Mixin(WorldChunk.class)
@Implements(@Interface(iface = Chunk.class, prefix = "vw$")) @Implements(@Interface(iface = Chunk.class, prefix = "terra$"))
public abstract class WorldChunkMixin { public abstract class WorldChunkMixin {
@Final @Final
@Shadow @Shadow
private net.minecraft.world.World world; private net.minecraft.world.World world;
public int vw$getX() { public int terra$getX() {
return ((net.minecraft.world.chunk.Chunk) this).getPos().x; return ((net.minecraft.world.chunk.Chunk) this).getPos().x;
} }
public int vw$getZ() { public int terra$getZ() {
return ((net.minecraft.world.chunk.Chunk) this).getPos().z; return ((net.minecraft.world.chunk.Chunk) this).getPos().z;
} }
public World vw$getWorld() { public World terra$getWorld() {
return (World) world; return (World) world;
} }
public Block vw$getBlock(int x, int y, int z) { public Block terra$getBlock(int x, int y, int z) {
BlockPos pos = new BlockPos(x + (vw$getX() << 4), y, z + (vw$getZ() << 4)); BlockPos pos = new BlockPos(x + (terra$getX() << 4), y, z + (terra$getZ() << 4));
return new FabricBlock(pos, world); return new FabricBlock(pos, world);
} }
public @NotNull BlockData vw$getBlockData(int x, int y, int z) { public @NotNull BlockData terra$getBlockData(int x, int y, int z) {
return vw$getBlock(x, y, z).getBlockData(); return terra$getBlock(x, y, z).getBlockData();
} }
public void vw$setBlock(int x, int y, int z, @NotNull BlockData blockData) { public void terra$setBlock(int x, int y, int z, @NotNull BlockData blockData) {
((net.minecraft.world.chunk.Chunk) this).setBlockState(new BlockPos(x, y, z), ((FabricBlockData) blockData).getHandle(), false); ((net.minecraft.world.chunk.Chunk) this).setBlockState(new BlockPos(x, y, z), ((FabricBlockData) blockData).getHandle(), false);
} }
public Object vw$getHandle() { public Object terra$getHandle() {
return this; return this;
} }
} }

View File

@ -14,6 +14,7 @@
"inventory.ItemStackDamageableMixin", "inventory.ItemStackDamageableMixin",
"inventory.ItemStackMetaMixin", "inventory.ItemStackMetaMixin",
"inventory.ItemStackMixin", "inventory.ItemStackMixin",
"world.BiomeMixin",
"world.ChunkGeneratorMixin", "world.ChunkGeneratorMixin",
"world.ChunkRegionMixin", "world.ChunkRegionMixin",
"world.ChunkRegionWorldMixin", "world.ChunkRegionWorldMixin",