mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-02-16 10:30:42 +00:00
implement ItemMixin
This commit is contained in:
@@ -18,7 +18,7 @@ public class FabricItemHandle implements ItemHandle {
|
||||
@Override
|
||||
public Item createItem(String data) {
|
||||
try {
|
||||
return FabricAdapter.adapt(new ItemStackArgumentType().parse(new StringReader(data)).getItem());
|
||||
return (Item) new ItemStackArgumentType().parse(new StringReader(data)).getItem();
|
||||
} catch(CommandSyntaxException e) {
|
||||
throw new IllegalArgumentException("Invalid item data \"" + data + "\"", e);
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ public class FabricItemStack implements ItemStack {
|
||||
|
||||
@Override
|
||||
public Item getType() {
|
||||
return new FabricItem(delegate.getItem());
|
||||
return (Item) delegate.getItem();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.dfsek.terra.fabric.mixin.inventory;
|
||||
|
||||
import com.dfsek.terra.api.platform.inventory.ItemStack;
|
||||
import com.dfsek.terra.fabric.inventory.FabricItemStack;
|
||||
import net.minecraft.item.Item;
|
||||
import org.spongepowered.asm.mixin.Implements;
|
||||
import org.spongepowered.asm.mixin.Interface;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
|
||||
@Mixin(Item.class)
|
||||
@Implements(@Interface(iface = com.dfsek.terra.api.platform.inventory.Item.class, prefix = "vw$"))
|
||||
public abstract class ItemMixin {
|
||||
@Shadow
|
||||
public abstract int getMaxDamage();
|
||||
|
||||
public Object vw$getHandle() {
|
||||
return this;
|
||||
}
|
||||
|
||||
public ItemStack vw$newItemStack(int amount) {
|
||||
return new FabricItemStack(new net.minecraft.item.ItemStack((Item) (Object) this, amount));
|
||||
}
|
||||
|
||||
public double vw$getMaxDurability() {
|
||||
return getMaxDamage();
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,6 @@ import com.dfsek.terra.api.platform.block.BlockType;
|
||||
import com.dfsek.terra.api.platform.entity.EntityType;
|
||||
import com.dfsek.terra.api.platform.inventory.item.Enchantment;
|
||||
import com.dfsek.terra.fabric.inventory.FabricEnchantment;
|
||||
import com.dfsek.terra.fabric.inventory.FabricItem;
|
||||
import com.dfsek.terra.fabric.inventory.FabricItemStack;
|
||||
import com.dfsek.terra.fabric.world.block.FabricBlockData;
|
||||
import com.dfsek.terra.fabric.world.block.FabricBlockType;
|
||||
@@ -22,7 +21,6 @@ import com.dfsek.terra.fabric.world.handles.world.FabricWorldHandle;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.state.property.Properties;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
@@ -99,10 +97,6 @@ public final class FabricAdapter {
|
||||
return new FabricItemStack(itemStack);
|
||||
}
|
||||
|
||||
public static com.dfsek.terra.api.platform.inventory.Item adapt(Item item) {
|
||||
return new FabricItem(item);
|
||||
}
|
||||
|
||||
public static Enchantment adapt(net.minecraft.enchantment.Enchantment enchantment) {
|
||||
return new FabricEnchantment(enchantment);
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
"entity.EntityMixin",
|
||||
"entity.PlayerEntityMixin",
|
||||
"entity.ServerCommandSourceMixin",
|
||||
"inventory.ItemMixin",
|
||||
"world.ChunkRegionMixin",
|
||||
"world.ProtoChunkMixin",
|
||||
"world.WorldChunkMixin"
|
||||
|
||||
Reference in New Issue
Block a user