mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2025-07-04 00:45:57 +00:00
implement EntityTypeMixin
This commit is contained in:
parent
e71df936ab
commit
061d2b6493
@ -0,0 +1,14 @@
|
||||
package com.dfsek.terra.fabric.mixin.entity;
|
||||
|
||||
import net.minecraft.entity.EntityType;
|
||||
import org.spongepowered.asm.mixin.Implements;
|
||||
import org.spongepowered.asm.mixin.Interface;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
|
||||
@Mixin(EntityType.class)
|
||||
@Implements(@Interface(iface = com.dfsek.terra.api.platform.entity.EntityType.class, prefix = "vw$"))
|
||||
public abstract class EntityTypeMixin {
|
||||
public Object vw$getHandle() {
|
||||
return this;
|
||||
}
|
||||
}
|
@ -13,7 +13,6 @@ import com.dfsek.terra.fabric.world.block.data.FabricRotatable;
|
||||
import com.dfsek.terra.fabric.world.block.data.FabricSlab;
|
||||
import com.dfsek.terra.fabric.world.block.data.FabricStairs;
|
||||
import com.dfsek.terra.fabric.world.block.data.FabricWaterlogged;
|
||||
import com.dfsek.terra.fabric.world.entity.FabricEntityType;
|
||||
import com.dfsek.terra.fabric.world.handles.world.FabricWorldHandle;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
@ -77,14 +76,6 @@ public final class FabricAdapter {
|
||||
return new FabricBlockType(block);
|
||||
}
|
||||
|
||||
public static EntityType adapt(net.minecraft.entity.EntityType<?> entityType) {
|
||||
return new FabricEntityType(entityType);
|
||||
}
|
||||
|
||||
public static net.minecraft.entity.EntityType<? extends Entity> adapt(EntityType entityType) {
|
||||
return ((FabricEntityType) entityType).getHandle();
|
||||
}
|
||||
|
||||
public WorldAccess adapt(FabricWorldHandle worldHandle) {
|
||||
return worldHandle.getWorld();
|
||||
}
|
||||
|
@ -30,6 +30,6 @@ public class FabricWorldHandle implements WorldHandle {
|
||||
public EntityType getEntity(String id) {
|
||||
Identifier identifier = Identifier.tryParse(id);
|
||||
if(identifier == null) identifier = Identifier.tryParse("minecraft:" + id.toLowerCase(Locale.ROOT));
|
||||
return FabricAdapter.adapt(Registry.ENTITY_TYPE.get(identifier));
|
||||
return (EntityType) Registry.ENTITY_TYPE.get(identifier);
|
||||
}
|
||||
}
|
||||
|
@ -19,12 +19,12 @@ public class FabricMobSpawner extends FabricBlockState implements MobSpawner { /
|
||||
|
||||
@Override
|
||||
public EntityType getSpawnedType() {
|
||||
return FabricAdapter.adapt(Registry.ENTITY_TYPE.get(((MobSpawnerBlockEntity) blockEntity).getLogic().getEntityId()));
|
||||
return (EntityType) Registry.ENTITY_TYPE.get(((MobSpawnerBlockEntity) blockEntity).getLogic().getEntityId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSpawnedType(@NotNull EntityType creatureType) {
|
||||
((MobSpawnerBlockEntity) blockEntity).getLogic().setEntityId(FabricAdapter.adapt(creatureType));
|
||||
((MobSpawnerBlockEntity) blockEntity).getLogic().setEntityId((net.minecraft.entity.EntityType<?>) creatureType);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,16 +0,0 @@
|
||||
package com.dfsek.terra.fabric.world.entity;
|
||||
|
||||
import com.dfsek.terra.api.platform.entity.EntityType;
|
||||
|
||||
public class FabricEntityType implements EntityType {
|
||||
private final net.minecraft.entity.EntityType<?> type;
|
||||
|
||||
public FabricEntityType(net.minecraft.entity.EntityType<?> type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public net.minecraft.entity.EntityType<?> getHandle() {
|
||||
return type;
|
||||
}
|
||||
}
|
@ -68,7 +68,7 @@ public class FabricWorld implements World, FabricWorldHandle {
|
||||
|
||||
@Override
|
||||
public Entity spawnEntity(Location location, EntityType entityType) {
|
||||
net.minecraft.entity.Entity entity = FabricAdapter.adapt(entityType).create(delegate.world);
|
||||
net.minecraft.entity.Entity entity = ((net.minecraft.entity.EntityType<?>) entityType).create(delegate.world);
|
||||
entity.setPos(location.getX(), location.getY(), location.getZ());
|
||||
delegate.world.spawnEntity(entity);
|
||||
return (Entity) entity;
|
||||
|
@ -56,7 +56,7 @@ public class FabricSeededWorldAccess implements World, FabricWorldHandle {
|
||||
|
||||
@Override
|
||||
public Entity spawnEntity(Location location, EntityType entityType) {
|
||||
net.minecraft.entity.Entity entity = FabricAdapter.adapt(entityType).create((ServerWorld) handle.worldAccess);
|
||||
net.minecraft.entity.Entity entity = ((net.minecraft.entity.EntityType<?>) entityType).create((ServerWorld) handle.worldAccess);
|
||||
entity.setPos(location.getX(), location.getY(), location.getZ());
|
||||
handle.worldAccess.spawnEntity(entity);
|
||||
return (Entity) entity;
|
||||
|
@ -55,7 +55,7 @@ public class FabricWorldAccess implements World, FabricWorldHandle {
|
||||
|
||||
@Override
|
||||
public Entity spawnEntity(Location location, EntityType entityType) {
|
||||
net.minecraft.entity.Entity entity = FabricAdapter.adapt(entityType).create(((ServerWorldAccess) delegate).toServerWorld());
|
||||
net.minecraft.entity.Entity entity = ((net.minecraft.entity.EntityType<?>) entityType).create(((ServerWorldAccess) delegate).toServerWorld());
|
||||
entity.setPos(location.getX(), location.getY(), location.getZ());
|
||||
delegate.spawnEntity(entity);
|
||||
return (Entity) entity;
|
||||
|
@ -6,6 +6,7 @@
|
||||
"mixins": [
|
||||
"MixinGeneratorOptions",
|
||||
"entity.EntityMixin",
|
||||
"entity.EntityTypeMixin",
|
||||
"entity.PlayerEntityMixin",
|
||||
"entity.ServerCommandSourceMixin",
|
||||
"inventory.EnchantmentMixin",
|
||||
|
Loading…
x
Reference in New Issue
Block a user