mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2025-07-03 16:35:50 +00:00
fabric cleanup
This commit is contained in:
parent
ac09e059fc
commit
415df211ed
@ -22,8 +22,6 @@ import java.util.logging.Logger;
|
||||
public interface TerraPlugin extends LoaderRegistrar {
|
||||
WorldHandle getWorldHandle();
|
||||
|
||||
boolean isEnabled();
|
||||
|
||||
TerraWorld getWorld(World world);
|
||||
|
||||
Logger getLogger();
|
||||
|
@ -64,11 +64,6 @@ public class DistributionTest {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TerraWorld getWorld(World world) {
|
||||
return null;
|
||||
|
@ -6,6 +6,7 @@ import com.dfsek.terra.api.platform.world.World;
|
||||
import com.dfsek.terra.api.util.FastRandom;
|
||||
import com.dfsek.terra.api.util.GlueList;
|
||||
import com.dfsek.terra.api.world.generation.TerraBlockPopulator;
|
||||
import com.dfsek.terra.bukkit.TerraBukkitPlugin;
|
||||
import com.dfsek.terra.profiler.ProfileFuture;
|
||||
import com.dfsek.terra.profiler.WorldProfiler;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@ -40,7 +41,7 @@ public class PopulationManager implements TerraBlockPopulator {
|
||||
needsPop.add(new ChunkCoordinate(chunk));
|
||||
int x = chunk.getX();
|
||||
int z = chunk.getZ();
|
||||
if(main.isEnabled()) {
|
||||
if(((TerraBukkitPlugin) main).isEnabled()) {
|
||||
for(int xi = -1; xi <= 1; xi++) {
|
||||
for(int zi = -1; zi <= 1; zi++) {
|
||||
if(xi == 0 && zi == 0) continue;
|
||||
|
@ -76,6 +76,7 @@ import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.LogManager;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public class TerraFabricPlugin implements TerraPlugin, ModInitializer {
|
||||
@ -85,6 +86,7 @@ public class TerraFabricPlugin implements TerraPlugin, ModInitializer {
|
||||
|
||||
private final EventManager eventManager = new TerraEventManager(this);
|
||||
|
||||
|
||||
public static TerraFabricPlugin getInstance() {
|
||||
return instance;
|
||||
}
|
||||
@ -93,8 +95,16 @@ public class TerraFabricPlugin implements TerraPlugin, ModInitializer {
|
||||
public static final ConfiguredFeature<?, ?> POPULATOR_CONFIGURED_FEATURE = POPULATOR_FEATURE.configure(FeatureConfig.DEFAULT).decorate(Decorator.NOPE.configure(NopeDecoratorConfig.INSTANCE));
|
||||
|
||||
private final GenericLoaders genericLoaders = new GenericLoaders(this);
|
||||
private final Logger logger = Logger.getLogger("Terra");
|
||||
private final DebugLogger debugLogger = new DebugLogger(logger);
|
||||
private final Logger logger;
|
||||
private final DebugLogger debugLogger;
|
||||
|
||||
{
|
||||
Logger logger = Logger.getLogger("Terra");
|
||||
LogManager.getLogManager().addLogger(logger);
|
||||
this.logger = logger;
|
||||
debugLogger = new DebugLogger(logger);
|
||||
}
|
||||
|
||||
private final ItemHandle itemHandle = new FabricItemHandle();
|
||||
private final WorldHandle worldHandle = new FabricWorldHandle();
|
||||
private final ConfigRegistry registry = new ConfigRegistry();
|
||||
@ -113,11 +123,6 @@ public class TerraFabricPlugin implements TerraPlugin, ModInitializer {
|
||||
return worldHandle;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TerraWorld getWorld(World world) {
|
||||
return worldMap.computeIfAbsent(world.getSeed(), w -> {
|
||||
@ -252,10 +257,6 @@ public class TerraFabricPlugin implements TerraPlugin, ModInitializer {
|
||||
public void onInitialize() {
|
||||
logger.setLevel(Level.INFO);
|
||||
MaterialSet set = MaterialSet.get(FabricAdapter.adapt(Blocks.GRASS_BLOCK), FabricAdapter.adapt(Blocks.STONE));
|
||||
logger.info("thing: " + set.contains(FabricAdapter.adapt(Blocks.STONE)));
|
||||
logger.info("thing2: " + set.contains(FabricAdapter.adapt(Blocks.OAK_BUTTON)));
|
||||
logger.info("thing3: " + Blocks.ACACIA_FENCE.getDefaultState().toString());
|
||||
logger.info("thing4: " + Blocks.ACACIA_FENCE.toString());
|
||||
|
||||
instance = this;
|
||||
|
||||
|
@ -0,0 +1,50 @@
|
||||
package com.dfsek.terra.fabric.world.block.state;
|
||||
|
||||
import com.dfsek.terra.api.platform.block.Block;
|
||||
import com.dfsek.terra.api.platform.block.BlockData;
|
||||
import com.dfsek.terra.api.platform.block.state.BlockState;
|
||||
import com.dfsek.terra.fabric.world.block.FabricBlock;
|
||||
|
||||
public class FabricBlankBlockState implements BlockState {
|
||||
private final FabricBlock delegate;
|
||||
|
||||
public FabricBlankBlockState(FabricBlock delegate) {
|
||||
this.delegate = delegate;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Block getHandle() {
|
||||
return delegate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Block getBlock() {
|
||||
return delegate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getX() {
|
||||
return delegate.getX();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getY() {
|
||||
return delegate.getY();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getZ() {
|
||||
return delegate.getZ();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockData getBlockData() {
|
||||
return delegate.getBlockData();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean update(boolean applyPhysics) {
|
||||
return true;
|
||||
}
|
||||
}
|
@ -0,0 +1,67 @@
|
||||
package com.dfsek.terra.fabric.world.block.state;
|
||||
|
||||
import com.dfsek.terra.api.platform.block.Block;
|
||||
import com.dfsek.terra.api.platform.block.BlockData;
|
||||
import com.dfsek.terra.api.platform.block.state.BlockState;
|
||||
import com.dfsek.terra.fabric.world.FabricAdapter;
|
||||
import com.dfsek.terra.fabric.world.block.FabricBlock;
|
||||
import com.dfsek.terra.fabric.world.block.FabricBlockData;
|
||||
import com.dfsek.terra.fabric.world.handles.FabricWorld;
|
||||
import net.minecraft.block.ChestBlock;
|
||||
import net.minecraft.block.SignBlock;
|
||||
import net.minecraft.block.entity.BlockEntity;
|
||||
import net.minecraft.block.entity.SignBlockEntity;
|
||||
|
||||
public class FabricBlockState implements BlockState {
|
||||
protected final BlockEntity blockEntity;
|
||||
|
||||
public FabricBlockState(BlockEntity blockEntity) {
|
||||
this.blockEntity = blockEntity;
|
||||
}
|
||||
|
||||
public static FabricBlockState newInstance(Block block) {
|
||||
net.minecraft.block.Block block1 = ((FabricBlockData) block.getBlockData()).getHandle().getBlock();
|
||||
if(block1 instanceof SignBlock) {
|
||||
return new FabricSign((SignBlockEntity) ((SignBlock) block1).createBlockEntity(((FabricWorld) block.getLocation().getWorld()).getHandle().getWorld()));
|
||||
}
|
||||
if(block1 instanceof ChestBlock) {
|
||||
return new FabricSign((SignBlockEntity) ((SignBlock) block1).createBlockEntity(((FabricWorld) block.getLocation().getWorld()).getHandle().getWorld()));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockEntity getHandle() {
|
||||
return blockEntity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Block getBlock() {
|
||||
return new FabricBlock(blockEntity.getPos(), blockEntity.getWorld());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getX() {
|
||||
return blockEntity.getPos().getX();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getY() {
|
||||
return blockEntity.getPos().getY();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getZ() {
|
||||
return blockEntity.getPos().getZ();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockData getBlockData() {
|
||||
return FabricAdapter.adapt(blockEntity.getCachedState());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean update(boolean applyPhysics) {
|
||||
return true;
|
||||
}
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
package com.dfsek.terra.fabric.world.block.state;
|
||||
|
||||
import com.dfsek.terra.api.platform.block.state.Sign;
|
||||
import net.minecraft.block.entity.SignBlockEntity;
|
||||
import net.minecraft.text.LiteralText;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class FabricSign extends FabricBlockState implements Sign {
|
||||
public FabricSign(SignBlockEntity blockEntity) {
|
||||
super(blockEntity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull String[] getLines() {
|
||||
return new String[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull String getLine(int index) throws IndexOutOfBoundsException {
|
||||
return ((SignBlockEntity) blockEntity).getTextOnRow(index).asString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLine(int index, @NotNull String line) throws IndexOutOfBoundsException {
|
||||
((SignBlockEntity) blockEntity).setTextOnRow(index, new LiteralText(line));
|
||||
}
|
||||
}
|
@ -95,7 +95,7 @@ public class FabricWorld implements World {
|
||||
return null;
|
||||
}
|
||||
|
||||
private static final class Handle {
|
||||
public static final class Handle {
|
||||
private final ServerWorld world;
|
||||
private final ChunkGenerator generator;
|
||||
|
||||
@ -103,5 +103,13 @@ public class FabricWorld implements World {
|
||||
this.world = world;
|
||||
this.generator = generator;
|
||||
}
|
||||
|
||||
public ChunkGenerator getGenerator() {
|
||||
return generator;
|
||||
}
|
||||
|
||||
public ServerWorld getWorld() {
|
||||
return world;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -43,11 +43,6 @@ public class StandalonePlugin implements TerraPlugin {
|
||||
return worldHandle;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TerraWorld getWorld(World world) {
|
||||
return new TerraWorld(world, registry.get("DEFAULT"), this);
|
||||
|
Loading…
x
Reference in New Issue
Block a user