fabric pass 2

This commit is contained in:
dfsek
2021-06-23 15:35:52 -07:00
parent d4d2b659dc
commit 2906a4f891
28 changed files with 96 additions and 68 deletions

View File

@@ -1,10 +1,11 @@
package com.dfsek.terra.fabric.mixin.implementations;
import com.dfsek.terra.vector.LocationImpl;
import com.dfsek.terra.api.world.Tree;
import com.dfsek.terra.api.util.collections.MaterialSet;
import com.dfsek.terra.fabric.TerraFabricPlugin;
import com.dfsek.terra.api.block.BlockType;
import com.dfsek.terra.api.profiler.ProfileFrame;
import com.dfsek.terra.api.util.collections.MaterialSet;
import com.dfsek.terra.api.vector.Location;
import com.dfsek.terra.api.world.Tree;
import com.dfsek.terra.fabric.TerraFabricPlugin;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.registry.BuiltinRegistries;
import net.minecraft.world.StructureWorldAccess;
@@ -17,6 +18,7 @@ import org.spongepowered.asm.mixin.Shadow;
import java.util.Locale;
import java.util.Random;
import java.util.Set;
@Mixin(ConfiguredFeature.class)
@Implements(@Interface(iface = Tree.class, prefix = "terra$", remap = Interface.Remap.NONE))
@@ -25,7 +27,7 @@ public abstract class ConfiguredFeatureMixin {
public abstract boolean generate(StructureWorldAccess world, ChunkGenerator chunkGenerator, Random random, BlockPos pos);
@SuppressWarnings({"ConstantConditions", "try"})
public boolean terra$plant(LocationImpl l, Random r) {
public boolean terra$plant(Location l, Random r) {
String id = BuiltinRegistries.CONFIGURED_FEATURE.getId((ConfiguredFeature<?, ?>) (Object) this).toString();
try(ProfileFrame ignore = TerraFabricPlugin.getInstance().getProfiler().profile("fabric_tree:" + id.toLowerCase(Locale.ROOT))) {
StructureWorldAccess fabricWorldAccess = ((StructureWorldAccess) l.getWorld());
@@ -34,7 +36,7 @@ public abstract class ConfiguredFeatureMixin {
}
}
public MaterialSet terra$getSpawnable() {
public Set<BlockType> terra$getSpawnable() {
return MaterialSet.get(TerraFabricPlugin.getInstance().getWorldHandle().createBlockData("minecraft:grass_block"),
TerraFabricPlugin.getInstance().getWorldHandle().createBlockData("minecraft:podzol"),
TerraFabricPlugin.getInstance().getWorldHandle().createBlockData("minecraft:mycelium"));

View File

@@ -1,5 +1,6 @@
package com.dfsek.terra.fabric.mixin.implementations.entity;
import com.dfsek.terra.api.vector.Location;
import com.dfsek.terra.vector.LocationImpl;
import com.dfsek.terra.api.world.World;
import com.dfsek.terra.fabric.util.FabricAdapter;
@@ -35,11 +36,11 @@ public abstract class EntityMixin {
return this;
}
public LocationImpl terra$getLocation() {
public Location terra$getLocation() {
return new LocationImpl((World) world, FabricAdapter.adapt(blockPos));
}
public void terra$setLocation(LocationImpl location) {
public void terra$setLocation(Location location) {
teleport(location.getX(), location.getY(), location.getZ());
}

View File

@@ -1,5 +1,6 @@
package com.dfsek.terra.fabric.mixin.implementations.world;
import com.dfsek.terra.api.vector.Location;
import com.dfsek.terra.vector.LocationImpl;
import com.dfsek.terra.api.block.Block;
import com.dfsek.terra.api.entity.Entity;
@@ -51,7 +52,7 @@ public abstract class ChunkRegionMixin {
}
@SuppressWarnings("deprecation")
public Entity terra$spawnEntity(LocationImpl location, EntityType entityType) {
public Entity terra$spawnEntity(Location location, EntityType entityType) {
net.minecraft.entity.Entity entity = ((net.minecraft.entity.EntityType<?>) entityType).create(((ChunkRegion) (Object) this).toServerWorld());
entity.setPos(location.getX(), location.getY(), location.getZ());
((ChunkRegion) (Object) this).spawnEntity(entity);

View File

@@ -1,5 +1,6 @@
package com.dfsek.terra.fabric.mixin.implementations.world;
import com.dfsek.terra.api.vector.Location;
import com.dfsek.terra.vector.LocationImpl;
import com.dfsek.terra.api.block.Block;
import com.dfsek.terra.api.entity.Entity;
@@ -42,7 +43,7 @@ public abstract class ServerWorldMixin {
return new FabricBlock(new BlockPos(x, y, z), ((ServerWorld) (Object) this));
}
public Entity terra$spawnEntity(LocationImpl 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));
entity.setPos(location.getX(), location.getY(), location.getZ());
((ServerWorld) (Object) this).spawnEntity(entity);