diff --git a/platforms/fabric/src/main/java/com/dfsek/terra/fabric/PlatformImpl.java b/platforms/fabric/src/main/java/com/dfsek/terra/fabric/PlatformImpl.java index fef99d2cd..2ba5701f0 100644 --- a/platforms/fabric/src/main/java/com/dfsek/terra/fabric/PlatformImpl.java +++ b/platforms/fabric/src/main/java/com/dfsek/terra/fabric/PlatformImpl.java @@ -49,14 +49,14 @@ import com.dfsek.terra.api.util.generic.Lazy; import com.dfsek.terra.api.world.biome.PlatformBiome; import com.dfsek.terra.fabric.generation.FabricChunkGeneratorWrapper; import com.dfsek.terra.fabric.handle.FabricItemHandle; -import com.dfsek.terra.fabric.handle.FabricWorldHandle; +import com.dfsek.terra.mod.handle.MinecraftWorldHandle; import com.dfsek.terra.fabric.util.ProtoPlatformBiome; public class PlatformImpl extends AbstractPlatform { private static final Logger LOGGER = LoggerFactory.getLogger(PlatformImpl.class); private final ItemHandle itemHandle = new FabricItemHandle(); - private final WorldHandle worldHandle = new FabricWorldHandle(); + private final WorldHandle worldHandle = new MinecraftWorldHandle(); private final Lazy dataFolder = Lazy.lazy(() -> new File(FabricLoader.getInstance().getConfigDir().toFile(), "Terra")); private MinecraftServer server; diff --git a/platforms/forge/src/main/java/com/dfsek/terra/forge/PlatformImpl.java b/platforms/forge/src/main/java/com/dfsek/terra/forge/PlatformImpl.java index 6426c5685..2b414715a 100644 --- a/platforms/forge/src/main/java/com/dfsek/terra/forge/PlatformImpl.java +++ b/platforms/forge/src/main/java/com/dfsek/terra/forge/PlatformImpl.java @@ -49,14 +49,14 @@ import com.dfsek.terra.api.util.generic.Lazy; import com.dfsek.terra.api.world.biome.PlatformBiome; import com.dfsek.terra.forge.generation.ForgeChunkGeneratorWrapper; import com.dfsek.terra.forge.handle.ForgeItemHandle; -import com.dfsek.terra.forge.handle.ForgeWorldHandle; import com.dfsek.terra.forge.util.ProtoPlatformBiome; +import com.dfsek.terra.mod.handle.MinecraftWorldHandle; public class PlatformImpl extends AbstractPlatform { private static final Logger LOGGER = LoggerFactory.getLogger(PlatformImpl.class); private final ItemHandle itemHandle = new ForgeItemHandle(); - private final WorldHandle worldHandle = new ForgeWorldHandle(); + private final WorldHandle worldHandle = new MinecraftWorldHandle(); private final Lazy dataFolder = Lazy.lazy(() -> new File("./config/Terra")); public PlatformImpl() { diff --git a/platforms/forge/src/main/java/com/dfsek/terra/forge/handle/ForgeWorldHandle.java b/platforms/forge/src/main/java/com/dfsek/terra/forge/handle/ForgeWorldHandle.java deleted file mode 100644 index b139af0e8..000000000 --- a/platforms/forge/src/main/java/com/dfsek/terra/forge/handle/ForgeWorldHandle.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * This file is part of Terra. - * - * Terra is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Terra is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Terra. If not, see . - */ - -package com.dfsek.terra.forge.handle; - -import com.mojang.brigadier.exceptions.CommandSyntaxException; -import net.minecraft.block.Blocks; -import net.minecraft.command.argument.BlockArgumentParser; -import net.minecraft.util.Identifier; -import net.minecraft.util.registry.Registry; -import net.minecraftforge.registries.ForgeRegistries; -import org.jetbrains.annotations.NotNull; - -import com.dfsek.terra.api.block.state.BlockState; -import com.dfsek.terra.api.entity.EntityType; -import com.dfsek.terra.api.handle.WorldHandle; - - -public class ForgeWorldHandle implements WorldHandle { - - private static final BlockState AIR = (BlockState) Blocks.AIR.getDefaultState(); - - @Override - public @NotNull BlockState createBlockState(@NotNull String data) { - try { - net.minecraft.block.BlockState state = BlockArgumentParser.block(Registry.BLOCK, data, true).blockState(); - if(state == null) throw new IllegalArgumentException("Invalid data: " + data); - return (BlockState) state; - } catch(CommandSyntaxException e) { - throw new IllegalArgumentException(e); - } - } - - @Override - public @NotNull BlockState air() { - return AIR; - } - - @Override - public @NotNull EntityType getEntity(@NotNull String id) { - Identifier identifier = Identifier.tryParse(id); - if(identifier == null) identifier = Identifier.tryParse(id); - return (EntityType) ForgeRegistries.ENTITIES.getHolder(identifier).orElseThrow().value(); - } -} diff --git a/platforms/fabric/src/main/java/com/dfsek/terra/fabric/handle/FabricWorldHandle.java b/platforms/mod-common/src/main/java/com/dfsek/terra/mod/handle/MinecraftWorldHandle.java similarity index 89% rename from platforms/fabric/src/main/java/com/dfsek/terra/fabric/handle/FabricWorldHandle.java rename to platforms/mod-common/src/main/java/com/dfsek/terra/mod/handle/MinecraftWorldHandle.java index ac7a0e248..13eef4b2d 100644 --- a/platforms/fabric/src/main/java/com/dfsek/terra/fabric/handle/FabricWorldHandle.java +++ b/platforms/mod-common/src/main/java/com/dfsek/terra/mod/handle/MinecraftWorldHandle.java @@ -15,16 +15,12 @@ * along with Terra. If not, see . */ -package com.dfsek.terra.fabric.handle; +package com.dfsek.terra.mod.handle; -import com.dfsek.terra.fabric.FabricEntryPoint; - -import com.mojang.brigadier.StringReader; import com.mojang.brigadier.exceptions.CommandSyntaxException; import net.minecraft.block.Blocks; import net.minecraft.command.argument.BlockArgumentParser; import net.minecraft.util.Identifier; -import net.minecraft.util.registry.BuiltinRegistries; import net.minecraft.util.registry.Registry; import org.jetbrains.annotations.NotNull; @@ -33,7 +29,7 @@ import com.dfsek.terra.api.entity.EntityType; import com.dfsek.terra.api.handle.WorldHandle; -public class FabricWorldHandle implements WorldHandle { +public class MinecraftWorldHandle implements WorldHandle { private static final BlockState AIR = (BlockState) Blocks.AIR.getDefaultState();