mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-02-16 10:30:42 +00:00
implement Handle interface in single mixin
This commit is contained in:
@@ -29,8 +29,4 @@ import com.dfsek.terra.api.world.biome.PlatformBiome;
|
||||
@Mixin(Biome.class)
|
||||
@Implements(@Interface(iface = PlatformBiome.class, prefix = "terra$", remap = Interface.Remap.NONE))
|
||||
public abstract class BiomeMixin {
|
||||
@Intrinsic
|
||||
public Object terra$getHandle() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
package com.dfsek.terra.fabric.mixin.implementations;
|
||||
|
||||
import com.dfsek.terra.api.Handle;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.entity.BlockEntity;
|
||||
import net.minecraft.block.entity.LockableContainerBlockEntity;
|
||||
import net.minecraft.block.entity.LootableContainerBlockEntity;
|
||||
import net.minecraft.enchantment.Enchantment;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityType;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.server.command.ServerCommandSource;
|
||||
import net.minecraft.server.world.ServerWorld;
|
||||
import net.minecraft.world.ChunkRegion;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
import net.minecraft.world.chunk.ProtoChunk;
|
||||
import net.minecraft.world.chunk.WorldChunk;
|
||||
import org.spongepowered.asm.mixin.Implements;
|
||||
import org.spongepowered.asm.mixin.Interface;
|
||||
import org.spongepowered.asm.mixin.Intrinsic;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
|
||||
|
||||
/**
|
||||
* A ton of Minecraft classes must implement Handle identically, we can just take care of it here
|
||||
*/
|
||||
@Mixin({
|
||||
ServerWorld.class,
|
||||
ChunkRegion.class,
|
||||
|
||||
Block.class,
|
||||
|
||||
BlockEntity.class,
|
||||
LootableContainerBlockEntity.class,
|
||||
LockableContainerBlockEntity.class,
|
||||
|
||||
ProtoChunk.class,
|
||||
WorldChunk.class,
|
||||
|
||||
Entity.class,
|
||||
EntityType.class,
|
||||
|
||||
ServerCommandSource.class,
|
||||
|
||||
Item.class,
|
||||
ItemStack.class,
|
||||
Enchantment.class,
|
||||
|
||||
Biome.class
|
||||
})
|
||||
@Implements(@Interface(iface = Handle.class, prefix = "terra$", remap = Interface.Remap.NONE))
|
||||
public class HandleImplementationMixin {
|
||||
@Intrinsic
|
||||
public Object terra$getHandle() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -35,11 +35,6 @@ import com.dfsek.terra.fabric.util.FabricAdapter;
|
||||
@Mixin(net.minecraft.block.entity.BlockEntity.class)
|
||||
@Implements(@Interface(iface = BlockEntity.class, prefix = "terra$", remap = Interface.Remap.NONE))
|
||||
public abstract class BlockEntityMixin {
|
||||
@Intrinsic
|
||||
public Object terra$getHandle() {
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean terra$update(boolean applyPhysics) {
|
||||
if(((net.minecraft.block.entity.BlockEntity) (Object) this).hasWorld()) //noinspection ConstantConditions
|
||||
((net.minecraft.block.entity.BlockEntity) (Object) this).getWorld().getChunk(((net.minecraft.block.entity.BlockEntity) (Object) this).getPos()).setBlockEntity((net.minecraft.block.entity.BlockEntity) (Object) this);
|
||||
|
||||
@@ -33,11 +33,6 @@ import com.dfsek.terra.fabric.util.FabricAdapter;
|
||||
@Mixin(Block.class)
|
||||
@Implements(@Interface(iface = BlockType.class, prefix = "terra$", remap = Interface.Remap.NONE))
|
||||
public abstract class BlockMixin {
|
||||
@Intrinsic
|
||||
public Object terra$getHandle() {
|
||||
return this;
|
||||
}
|
||||
|
||||
public com.dfsek.terra.api.block.state.BlockState terra$getDefaultState() {
|
||||
return FabricAdapter.adapt(((Block) (Object) this).getDefaultState());
|
||||
}
|
||||
|
||||
@@ -34,9 +34,4 @@ public abstract class LootableContainerBlockEntityMixin extends BlockEntityMixin
|
||||
public Inventory terra$getInventory() {
|
||||
return (Inventory) this;
|
||||
}
|
||||
|
||||
@Intrinsic
|
||||
public Object terra$getHandle() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,8 +57,4 @@ public abstract class ChunkRegionMixin {
|
||||
public int terraChunk$getZ() {
|
||||
return centerPos.getPos().z;
|
||||
}
|
||||
|
||||
// getWorld already added in world/ChunkRegionMixin
|
||||
|
||||
// getHandle already added in world/ChunkRegionMixin.
|
||||
}
|
||||
|
||||
@@ -72,9 +72,4 @@ public abstract class WorldChunkMixin {
|
||||
public ServerWorld terra$getWorld() {
|
||||
return (ServerWorld) world;
|
||||
}
|
||||
|
||||
@Intrinsic
|
||||
public Object terra$getHandle() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,11 +45,6 @@ public abstract class ProtoChunkMixin {
|
||||
return new FabricBlockState(getBlockState(new BlockPos(x, y, z)));
|
||||
}
|
||||
|
||||
@Intrinsic
|
||||
public Object terra$getHandle() {
|
||||
return this;
|
||||
}
|
||||
|
||||
public int terra$getMaxHeight() {
|
||||
return 255; // TODO: 1.17 - Implement dynamic height.
|
||||
}
|
||||
|
||||
@@ -49,11 +49,6 @@ public abstract class EntityMixin {
|
||||
@Shadow
|
||||
public abstract void sendSystemMessage(Text message, UUID senderUuid);
|
||||
|
||||
@Intrinsic
|
||||
public Object terra$getHandle() {
|
||||
return this;
|
||||
}
|
||||
|
||||
public Vector3 terra$position() {
|
||||
return FabricAdapter.adapt(blockPos);
|
||||
}
|
||||
|
||||
@@ -27,8 +27,4 @@ import org.spongepowered.asm.mixin.Mixin;
|
||||
@Mixin(EntityType.class)
|
||||
@Implements(@Interface(iface = com.dfsek.terra.api.entity.EntityType.class, prefix = "terra$", remap = Interface.Remap.NONE))
|
||||
public abstract class EntityTypeMixin {
|
||||
@Intrinsic
|
||||
public Object terra$getHandle() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,5 +28,4 @@ import com.dfsek.terra.api.entity.Player;
|
||||
@Mixin(PlayerEntity.class)
|
||||
@Implements(@Interface(iface = Player.class, prefix = "terra$", remap = Interface.Remap.NONE))
|
||||
public abstract class PlayerEntityMixin extends EntityMixin {
|
||||
|
||||
}
|
||||
|
||||
@@ -38,9 +38,4 @@ public abstract class ServerCommandSourceMixin {
|
||||
public void terra$sendMessage(String message) {
|
||||
sendFeedback(new LiteralText(message), true);
|
||||
}
|
||||
|
||||
@Intrinsic
|
||||
public Object terra$getHandle() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,11 +31,6 @@ import com.dfsek.terra.api.inventory.ItemStack;
|
||||
@Mixin(LockableContainerBlockEntity.class)
|
||||
@Implements(@Interface(iface = Inventory.class, prefix = "terra$", remap = Interface.Remap.NONE))
|
||||
public class LockableContainerBlockEntityMixin {
|
||||
@Intrinsic
|
||||
public Object terra$getHandle() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@SuppressWarnings("ConstantConditions")
|
||||
public void terra$setItem(int slot, ItemStack newStack) {
|
||||
((LockableContainerBlockEntity) (Object) this).setStack(slot, (net.minecraft.item.ItemStack) (Object) newStack);
|
||||
|
||||
@@ -32,12 +32,7 @@ import com.dfsek.terra.api.inventory.ItemStack;
|
||||
public abstract class ItemMixin {
|
||||
@Shadow
|
||||
public abstract int getMaxDamage();
|
||||
|
||||
@Intrinsic
|
||||
public Object terra$getHandle() {
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings("ConstantConditions")
|
||||
public ItemStack terra$newItemStack(int amount) {
|
||||
return (ItemStack) (Object) new net.minecraft.item.ItemStack((Item) (Object) this, amount);
|
||||
|
||||
@@ -73,9 +73,4 @@ public abstract class ItemStackMixin {
|
||||
public boolean terra$isDamageable() {
|
||||
return isDamageable();
|
||||
}
|
||||
|
||||
@Intrinsic
|
||||
public Object terra$getHandle() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,12 +38,6 @@ public abstract class EnchantmentMixin {
|
||||
|
||||
@Shadow
|
||||
public abstract boolean canCombine(Enchantment other);
|
||||
|
||||
@Intrinsic
|
||||
public Object terra$getHandle() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@SuppressWarnings("ConstantConditions")
|
||||
public boolean terra$canEnchantItem(ItemStack itemStack) {
|
||||
return isAcceptableItem((net.minecraft.item.ItemStack) (Object) itemStack);
|
||||
|
||||
@@ -152,9 +152,4 @@ public abstract class ChunkRegionMixin {
|
||||
public ConfigPack terraWorld$getPack() {
|
||||
return config;
|
||||
}
|
||||
|
||||
@Intrinsic
|
||||
public Object terraWorld$getHandle() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -137,9 +137,4 @@ public abstract class ServerWorldMixin {
|
||||
public ConfigPack terra$getPack() {
|
||||
return config;
|
||||
}
|
||||
|
||||
@Intrinsic
|
||||
public Object terra$getHandle() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
"access.StateAccessor",
|
||||
"access.StructureAccessorAccessor",
|
||||
"implementations.BiomeMixin",
|
||||
"implementations.HandleImplementationMixin",
|
||||
"implementations.block.BlockEntityMixin",
|
||||
"implementations.block.BlockMixin",
|
||||
"implementations.block.state.LootableContainerBlockEntityMixin",
|
||||
|
||||
Reference in New Issue
Block a user