Remove some old stuff
This commit is contained in:
parent
61b6d30262
commit
f51222ac3e
13 changed files with 25 additions and 662 deletions
|
@ -24,33 +24,22 @@
|
|||
|
||||
package techreborn;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockDispenser;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemGroup;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.common.registry.GameRegistry;
|
||||
import net.minecraftforge.fml.common.registry.VillagerRegistry;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import reborncore.RebornCore;
|
||||
import reborncore.api.recipe.RecipeHandler;
|
||||
import reborncore.common.multiblock.MultiblockEventHandler;
|
||||
import reborncore.common.multiblock.MultiblockServerTickHandler;
|
||||
import reborncore.common.util.StringUtils;
|
||||
import reborncore.common.util.Torus;
|
||||
import techreborn.api.TechRebornAPI;
|
||||
import techreborn.client.GuiHandler;
|
||||
import techreborn.config.ConfigTechReborn;
|
||||
import techreborn.entities.EntityNukePrimed;
|
||||
import techreborn.events.BlockBreakHandler;
|
||||
import techreborn.events.TRRecipeHandler;
|
||||
import techreborn.events.TRTickHandler;
|
||||
|
@ -60,10 +49,7 @@ import techreborn.proxies.CommonProxy;
|
|||
import techreborn.tiles.fusionReactor.TileFusionControlComputer;
|
||||
import techreborn.utils.BehaviorDispenseScrapbox;
|
||||
import techreborn.utils.StackWIPHandler;
|
||||
import techreborn.world.OilLakeGenerator;
|
||||
import techreborn.world.TechRebornWorldGen;
|
||||
import techreborn.world.village.ModLootTables;
|
||||
import techreborn.world.village.VillageComponentRubberPlantaion;
|
||||
import techreborn.world.village.VillagePlantaionHandler;
|
||||
|
||||
import java.io.File;
|
||||
|
@ -72,19 +58,10 @@ import java.io.File;
|
|||
public class TechReborn {
|
||||
|
||||
public static final String MOD_ID = "techreborn";
|
||||
public static final String MOD_NAME = "Tech Reborn";
|
||||
public static final String MOD_VERSION = "@MODVERSION@";
|
||||
public static final String MOD_DEPENDENCIES = "required-after:forge@[14.23.3.2694,);required-after:reborncore;after:jei@[4.7,)";
|
||||
public static final String CLIENT_PROXY_CLASS = "techreborn.proxies.ClientProxy";
|
||||
public static final String SERVER_PROXY_CLASS = "techreborn.proxies.CommonProxy";
|
||||
public static final String GUI_FACTORY_CLASS = "techreborn.config.TechRebornGUIFactory";
|
||||
|
||||
public static final Logger LOGGER = LogManager.getLogger(MOD_ID);
|
||||
// @SidedProxy(clientSide = TechReborn.CLIENT_PROXY_CLASS, serverSide = TechReborn.SERVER_PROXY_CLASS)
|
||||
public static CommonProxy proxy;
|
||||
// @Mod.Instance
|
||||
public static TechReborn INSTANCE;
|
||||
public static TechRebornWorldGen worldGen;
|
||||
public static File configDir;
|
||||
|
||||
public static final ItemGroup ITEMGROUP = new ItemGroup(-1, MOD_ID) {
|
||||
|
@ -101,13 +78,9 @@ public class TechReborn {
|
|||
INSTANCE = this;
|
||||
|
||||
configDir = new File(new File("teamreborn"), "techreborn");
|
||||
worldGen = new TechRebornWorldGen();
|
||||
worldGen.configFile = (new File(configDir, "ores.json"));
|
||||
|
||||
//CommonProxy.isChiselAround = Loader.isModLoaded("ctm");
|
||||
TechRebornAPI.subItemRetriever = new SubItemRetriever();
|
||||
// Registration
|
||||
TRTileEntities.init();
|
||||
ModFluids.init();
|
||||
|
||||
ClientboundPackets.init();
|
||||
|
@ -116,7 +89,7 @@ public class TechReborn {
|
|||
// Entitys
|
||||
//EntityRegistry.registerModEntity(new ResourceLocation("techreborn", "nuke"), EntityNukePrimed.class, "nuke", 0, INSTANCE, 160, 5, true);
|
||||
|
||||
proxy.preInit(event);
|
||||
proxy.preInit();
|
||||
|
||||
// Registers Chest Loot
|
||||
ModLoot.init();
|
||||
|
|
|
@ -61,7 +61,7 @@ public class EntityNukePrimed extends EntityTNTPrimed {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate() {
|
||||
public void tick() {
|
||||
this.prevPosX = this.posX;
|
||||
this.prevPosY = this.posY;
|
||||
this.prevPosZ = this.posZ;
|
||||
|
|
|
@ -25,10 +25,8 @@
|
|||
package techreborn.proxies;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.block.statemap.StateMap;
|
||||
import net.minecraft.client.renderer.entity.Render;
|
||||
import net.minecraft.client.renderer.entity.RenderManager;
|
||||
import net.minecraft.client.util.RecipeBookClient;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import net.minecraftforge.client.model.ModelLoader;
|
||||
|
@ -36,8 +34,6 @@ import net.minecraftforge.common.MinecraftForge;
|
|||
import net.minecraftforge.fml.client.registry.ClientRegistry;
|
||||
import net.minecraftforge.fml.client.registry.IRenderFactory;
|
||||
import net.minecraftforge.fml.client.registry.RenderingRegistry;
|
||||
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
|
||||
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
|
||||
import reborncore.api.tile.IUpgradeable;
|
||||
import reborncore.client.IconSupplier;
|
||||
import reborncore.client.hud.StackInfoHUD;
|
||||
|
@ -59,8 +55,8 @@ import techreborn.items.ItemFrequencyTransmitter;
|
|||
public class ClientProxy extends CommonProxy {
|
||||
|
||||
@Override
|
||||
public void preInit(FMLPreInitializationEvent event) {
|
||||
super.preInit(event);
|
||||
public void preInit() {
|
||||
super.preInit();
|
||||
StackInfoHUD.registerElement(new ItemFrequencyTransmitter.StackInfoFreqTransmitter());
|
||||
RenderingRegistry.registerEntityRenderingHandler(EntityNukePrimed.class, new RenderManagerNuke());
|
||||
MinecraftForge.EVENT_BUS.register(new IconSupplier());
|
||||
|
@ -68,8 +64,8 @@ public class ClientProxy extends CommonProxy {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void init(FMLInitializationEvent event) {
|
||||
super.init(event);
|
||||
public void init() {
|
||||
super.init();
|
||||
MinecraftForge.EVENT_BUS.register(new StackToolTipEvent());
|
||||
MinecraftForge.EVENT_BUS.register(GuiSlotConfiguration.class);
|
||||
MinecraftForge.EVENT_BUS.register(GuiFluidConfiguration.class);
|
||||
|
@ -81,10 +77,6 @@ public class ClientProxy extends CommonProxy {
|
|||
GuiBase.fluidCellProvider = DynamicCell::getCellWithFluid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCTMAvailable() {
|
||||
return isChiselAround;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUpgradeConfigText() {
|
||||
|
@ -112,9 +104,4 @@ public class ClientProxy extends CommonProxy {
|
|||
return Minecraft.getInstance().gameSettings.fancyGraphics;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void rebuildRecipeBook() {
|
||||
super.rebuildRecipeBook();
|
||||
RecipeBookClient.rebuildTable();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,35 +24,23 @@
|
|||
|
||||
package techreborn.proxies;
|
||||
|
||||
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
|
||||
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
|
||||
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
|
||||
import net.minecraftforge.fml.common.event.FMLServerStartingEvent;
|
||||
import techreborn.TechReborn;
|
||||
|
||||
public class CommonProxy {
|
||||
public static boolean isChiselAround;
|
||||
|
||||
public void preInit(FMLPreInitializationEvent event) {
|
||||
if (isChiselAround) {
|
||||
TechReborn.LOGGER.info("Hello chisel, shiny things will be enabled in techreborn");
|
||||
}
|
||||
}
|
||||
|
||||
public void init(FMLInitializationEvent event) {
|
||||
public void preInit() {
|
||||
|
||||
}
|
||||
|
||||
public void postInit(FMLPostInitializationEvent event) {
|
||||
public void init() {
|
||||
|
||||
}
|
||||
|
||||
public void serverStarting(FMLServerStartingEvent event) {
|
||||
public void postInit() {
|
||||
|
||||
}
|
||||
|
||||
public boolean isCTMAvailable() {
|
||||
return false;
|
||||
public void serverStarting() {
|
||||
|
||||
}
|
||||
|
||||
public String getUpgradeConfigText() {
|
||||
|
@ -63,8 +51,5 @@ public class CommonProxy {
|
|||
return true;
|
||||
}
|
||||
|
||||
public void rebuildRecipeBook(){
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -24,16 +24,13 @@
|
|||
|
||||
package techreborn.world;
|
||||
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.chunk.IChunkProvider;
|
||||
import net.minecraft.world.gen.IChunkGenerator;
|
||||
import net.minecraft.world.gen.feature.WorldGenLakes;
|
||||
import net.minecraftforge.fml.common.IWorldGenerator;
|
||||
import reborncore.common.registration.RebornRegister;
|
||||
import reborncore.common.registration.config.ConfigRegistry;
|
||||
import techreborn.TechReborn;
|
||||
import techreborn.init.ModFluids;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
|
@ -58,13 +55,13 @@ public class OilLakeGenerator implements IWorldGenerator {
|
|||
if (!enable) {
|
||||
return;
|
||||
}
|
||||
if (!world.provider.isSurfaceWorld()) {
|
||||
if (!world.getDimension().isSurfaceWorld()) {
|
||||
return;
|
||||
}
|
||||
if (random.nextInt(rareity) != 0) {
|
||||
return;
|
||||
}
|
||||
int y = random.nextInt(maxHeight);
|
||||
new WorldGenLakes(ModFluids.BLOCK_OIL).generate(world, random, new BlockPos((chunkX * 16) + 8, y, (chunkZ * 16) + 8));
|
||||
//new WorldGenLakes(ModFluids.BLOCK_OIL).generate(world, random, new BlockPos((chunkX * 16) + 8, y, (chunkZ * 16) + 8));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,9 +28,13 @@ import net.minecraft.block.Block;
|
|||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IWorld;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.chunk.IChunkProvider;
|
||||
import net.minecraft.world.gen.IChunkGenerator;
|
||||
import net.minecraft.world.gen.feature.WorldGenerator;
|
||||
import net.minecraftforge.common.IPlantable;
|
||||
import net.minecraftforge.fml.common.IWorldGenerator;
|
||||
import techreborn.TechReborn;
|
||||
import techreborn.blocks.BlockRubberLeaves;
|
||||
import techreborn.blocks.BlockRubberLog;
|
||||
|
@ -38,7 +42,7 @@ import techreborn.init.TRContent;
|
|||
|
||||
import java.util.Random;
|
||||
|
||||
public class RubberTreeGenerator extends WorldGenerator {
|
||||
public class RubberTreeGenerator implements IWorldGenerator {
|
||||
|
||||
boolean isWorldGen = true;
|
||||
|
||||
|
@ -69,7 +73,7 @@ public class RubberTreeGenerator extends WorldGenerator {
|
|||
return false;
|
||||
}
|
||||
|
||||
public boolean growTree(World world, Random rand, int x, int y, int z) {
|
||||
public boolean growTree(IWorld world, Random rand, int x, int y, int z) {
|
||||
int treeHeight = rand.nextInt(5) + TechReborn.worldGen.config.rubberTreeConfig.treeBaseHeight;
|
||||
int worldHeight = world.getHeight();
|
||||
if (y >= 1 && y + treeHeight + 1 <= worldHeight) {
|
||||
|
@ -172,4 +176,9 @@ public class RubberTreeGenerator extends WorldGenerator {
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void generate(Random random, int chunkX, int chunkZ, World world, IChunkGenerator chunkGenerator, IChunkProvider chunkProvider) {
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,106 +0,0 @@
|
|||
/*
|
||||
* This file is part of TechReborn, licensed under the MIT License (MIT).
|
||||
*
|
||||
* Copyright (c) 2018 TechReborn
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package techreborn.world;
|
||||
|
||||
import com.google.common.base.MoreObjects;
|
||||
import com.google.common.collect.Sets;
|
||||
import net.minecraft.util.math.ChunkPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.event.world.ChunkDataEvent;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.gameevent.TickEvent;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import reborncore.common.misc.ChunkCoord;
|
||||
import techreborn.TechReborn;
|
||||
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.Deque;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Based off https://github.com/SteamNSteel/SteamNSteel
|
||||
*/
|
||||
public class TechRebornRetroGen {
|
||||
private static final String RETROGEN_TAG = "techrebonr:retogen";
|
||||
private static final Set<ChunkPos> completedChunks = Sets.newHashSet();
|
||||
private final Deque<ChunkPos> chunksToRetroGen = new ArrayDeque<>(64);
|
||||
|
||||
private boolean isChunkEligibleForRetroGen(ChunkDataEvent.Load event) {
|
||||
return TechReborn.worldGen.config.retroGenOres && event.getWorld().provider.getDimension() == 0
|
||||
&& event.getData().getString(RETROGEN_TAG).isEmpty();
|
||||
}
|
||||
|
||||
public void markChunk(ChunkPos coord) {
|
||||
completedChunks.add(coord);
|
||||
}
|
||||
|
||||
private boolean isTickEligibleForRetroGen(TickEvent.WorldTickEvent event) {
|
||||
return event.phase == TickEvent.Phase.END || event.side == Side.SERVER;
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onWorldTick(TickEvent.WorldTickEvent event) {
|
||||
if (isTickEligibleForRetroGen(event)) {
|
||||
if (!chunksToRetroGen.isEmpty()) {
|
||||
final ChunkPos coord = chunksToRetroGen.pollFirst();
|
||||
TechReborn.LOGGER.info("Regenerating ore in " + coord + '.');
|
||||
final World world = event.world;
|
||||
if (world.getChunkProvider().getLoadedChunk(coord.getX(), coord.getZ()) != null) {
|
||||
final long seed = world.getSeed();
|
||||
final Random rng = new Random(seed);
|
||||
final long xSeed = rng.nextLong() >> 2 + 1L;
|
||||
final long zSeed = rng.nextLong() >> 2 + 1L;
|
||||
final long chunkSeed = (xSeed * coord.getX() + zSeed * coord.getZ()) * seed;
|
||||
rng.setSeed(chunkSeed);
|
||||
TechReborn.worldGen.generate(rng, coord.getX(), coord.getZ(), world, null, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onChunkLoad(ChunkDataEvent.Load event) {
|
||||
if (isChunkEligibleForRetroGen(event)) {
|
||||
final ChunkPos coord = ChunkPos.of(event);
|
||||
TechReborn.LOGGER.info("Queueing retro ore gen for " + coord + '.');
|
||||
chunksToRetroGen.addLast(coord);
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onChunkSave(ChunkDataEvent.Save event) {
|
||||
final ChunkPos coord = ChunkPos.of(event);
|
||||
if (completedChunks.contains(coord)) {
|
||||
event.getData().setString(RETROGEN_TAG, "X");
|
||||
completedChunks.remove(coord);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return MoreObjects.toStringHelper(this).add("chunksToRetroGen", chunksToRetroGen).toString();
|
||||
}
|
||||
}
|
|
@ -1,281 +0,0 @@
|
|||
/*
|
||||
* This file is part of TechReborn, licensed under the MIT License (MIT).
|
||||
*
|
||||
* Copyright (c) 2018 TechReborn
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package techreborn.world;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.block.state.pattern.BlockMatcher;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
import net.minecraft.world.chunk.IChunkProvider;
|
||||
import net.minecraft.world.gen.IChunkGenerator;
|
||||
import net.minecraft.world.gen.feature.WorldGenMinable;
|
||||
import net.minecraftforge.common.BiomeDictionary;
|
||||
import net.minecraftforge.fml.common.IWorldGenerator;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import reborncore.common.misc.ChunkCoord;
|
||||
import techreborn.TechReborn;
|
||||
import techreborn.world.config.OreConfig;
|
||||
import techreborn.world.config.WorldGenConfig;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
/**
|
||||
* Created by modmuss50 on 11/03/2016.
|
||||
*/
|
||||
public class TechRebornWorldGen implements IWorldGenerator {
|
||||
|
||||
public static RubberTreeGenerator treeGenerator = new RubberTreeGenerator();
|
||||
public final TechRebornRetroGen retroGen = new TechRebornRetroGen();
|
||||
public File configFile;
|
||||
public boolean jsonInvalid = false;
|
||||
public WorldGenConfig config;
|
||||
WorldGenConfig defaultConfig;
|
||||
|
||||
private void init() {
|
||||
defaultConfig = new WorldGenConfig();
|
||||
defaultConfig.overworldOres = new ArrayList<>();
|
||||
defaultConfig.endOres = new ArrayList<>();
|
||||
defaultConfig.neatherOres = new ArrayList<>();
|
||||
// TODO: Fix block
|
||||
// defaultConfig.overworldOres.add(new OreConfig(ModBlocks.ORE.getBlockStateFromName("Galena"), 8, 16, 10, 60));
|
||||
// defaultConfig.overworldOres.add(new OreConfig(ModBlocks.ORE.getBlockStateFromName("Iridium"), 3, 3, 5, 60));
|
||||
// defaultConfig.overworldOres.add(new OreConfig(ModBlocks.ORE.getBlockStateFromName("Ruby"), 6, 3, 10, 60));
|
||||
// defaultConfig.overworldOres.add(new OreConfig(ModBlocks.ORE.getBlockStateFromName("Sapphire"), 6, 3, 10, 60));
|
||||
// defaultConfig.overworldOres.add(new OreConfig(ModBlocks.ORE.getBlockStateFromName("Bauxite"), 6, 10, 10, 60));
|
||||
// defaultConfig.overworldOres.add(new OreConfig(ModBlocks.ORE.getBlockStateFromName("Lead"), 6, 16, 20, 60));
|
||||
// defaultConfig.overworldOres.add(new OreConfig(ModBlocks.ORE.getBlockStateFromName("Silver"), 6, 16, 20, 60));
|
||||
// defaultConfig.overworldOres.add(new OreConfig(ModBlocks.ORE.getBlockStateFromName("copper"), 8, 16, 20, 60));
|
||||
// defaultConfig.overworldOres.add(new OreConfig(ModBlocks.ORE.getBlockStateFromName("tin"), 8, 16, 20, 60));
|
||||
//
|
||||
// defaultConfig.neatherOres.add(new OreConfig(ModBlocks.ORE.getBlockStateFromName("Pyrite"), 6, 3, 10, 126));
|
||||
// defaultConfig.neatherOres.add(new OreConfig(ModBlocks.ORE.getBlockStateFromName("Cinnabar"), 6, 3, 10, 126));
|
||||
// defaultConfig.neatherOres.add(new OreConfig(ModBlocks.ORE.getBlockStateFromName("Sphalerite"), 6, 3, 10, 126));
|
||||
//
|
||||
// defaultConfig.endOres.add(new OreConfig(ModBlocks.ORE.getBlockStateFromName("Tungsten"), 6, 3, 10, 250));
|
||||
// defaultConfig.endOres.add(new OreConfig(ModBlocks.ORE.getBlockStateFromName("Sheldonite"), 6, 3, 10, 250));
|
||||
// defaultConfig.endOres.add(new OreConfig(ModBlocks.ORE.getBlockStateFromName("Peridot"), 6, 3, 10, 250));
|
||||
// defaultConfig.endOres.add(new OreConfig(ModBlocks.ORE.getBlockStateFromName("Sodalite"), 6, 3, 10, 250));
|
||||
}
|
||||
|
||||
public void load() {
|
||||
init();
|
||||
if (configFile.exists()) {
|
||||
loadFromJson();
|
||||
} else {
|
||||
config = defaultConfig;
|
||||
jsonInvalid = true;
|
||||
}
|
||||
config.overworldOres.addAll(getMissingOres(config.overworldOres, defaultConfig.overworldOres));
|
||||
config.neatherOres.addAll(getMissingOres(config.neatherOres, defaultConfig.neatherOres));
|
||||
config.endOres.addAll(getMissingOres(config.endOres, defaultConfig.endOres));
|
||||
if (jsonInvalid) {
|
||||
save();
|
||||
}
|
||||
}
|
||||
|
||||
private List<OreConfig> getMissingOres(List<OreConfig> config, List<OreConfig> defaultOres) {
|
||||
List<OreConfig> missingOres = new ArrayList<>();
|
||||
for (OreConfig defaultOre : defaultOres) {
|
||||
boolean hasFoundOre = false;
|
||||
for (OreConfig ore : config) {
|
||||
if (ore.blockName.replaceAll(":", ".").equals(defaultOre.blockName.replaceAll(":", ".")) && ore.meta == defaultOre.meta) {
|
||||
hasFoundOre = true;
|
||||
// Should allow for states to be saved/loaded
|
||||
ore.state = defaultOre.state;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!hasFoundOre) {
|
||||
missingOres.add(defaultOre);
|
||||
}
|
||||
}
|
||||
return missingOres;
|
||||
}
|
||||
|
||||
private void loadFromJson() {
|
||||
try {
|
||||
Gson gson = new Gson();
|
||||
String jsonString = FileUtils.readFileToString(configFile, Charset.defaultCharset());
|
||||
config = gson.fromJson(jsonString, WorldGenConfig.class);
|
||||
// ArrayUtils.addAll(config.endOres, config.neatherOres, config.overworldOres).stream().forEach(oreConfig -> {
|
||||
// if (oreConfig.minYHeight > oreConfig.maxYHeight) {
|
||||
// printError(oreConfig.blockName + " ore generation value is invalid, the min y height is bigger than the max y height, this ore value will be disabled in code");
|
||||
//
|
||||
// oreConfig.minYHeight = -1;
|
||||
// oreConfig.maxYHeight = -1;
|
||||
// }
|
||||
//
|
||||
// if (oreConfig.minYHeight < 0 || oreConfig.maxYHeight < 0) {
|
||||
// printError(oreConfig.blockName + " ore generation value is invalid, the min y height or the max y height is less than 0, this ore value will be disabled in code");
|
||||
// oreConfig.minYHeight = -1;
|
||||
// oreConfig.maxYHeight = -1;
|
||||
// }
|
||||
//
|
||||
// });
|
||||
} catch (Exception e) {
|
||||
TechReborn.LOGGER.error(
|
||||
"The ores.json file was invalid, bad things are about to happen, I will try and save the world now :");
|
||||
config = defaultConfig;
|
||||
jsonInvalid = true;
|
||||
TechReborn.LOGGER.error(
|
||||
"The ores.json file was ignored and the default values loaded, you file will NOT be over written");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void printError(String string) {
|
||||
TechReborn.LOGGER.error("###############-ERROR-####################");
|
||||
TechReborn.LOGGER.error("");
|
||||
TechReborn.LOGGER.error(string);
|
||||
TechReborn.LOGGER.error("");
|
||||
TechReborn.LOGGER.error("###############-ERROR-####################");
|
||||
}
|
||||
|
||||
private void save() {
|
||||
Gson gson = new GsonBuilder().setPrettyPrinting().create();
|
||||
String json = gson.toJson(config);
|
||||
try {
|
||||
FileUtils.writeStringToFile(configFile, json, Charset.defaultCharset());
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public List<OreConfig> getAllGenOresFromList(List<OreConfig> configList) {
|
||||
List<OreConfig> list = new ArrayList<>();
|
||||
for (OreConfig config : configList) {
|
||||
if (config.veinSize != 0 && config.veinsPerChunk != 0 && config.shouldSpawn) {
|
||||
list.add(config);
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void generate(Random random, int chunkX, int chunkZ, World world, IChunkGenerator chunkGenerator,
|
||||
IChunkProvider chunkProvider) {
|
||||
// TODO this could be optimised to not run every chunk gen
|
||||
if (!config.generateTechRebornFeatures) {
|
||||
return;
|
||||
}
|
||||
boolean genTree = false;
|
||||
List<OreConfig> list = new ArrayList<>();
|
||||
Predicate<IBlockState> predicate = BlockMatcher.forBlock(Blocks.STONE);
|
||||
if (world.provider.getDimension() == -1) {
|
||||
list.addAll(getAllGenOresFromList(config.neatherOres));
|
||||
predicate = BlockMatcher.forBlock(Blocks.NETHERRACK);
|
||||
} else if (world.provider.getDimension() == 1) {
|
||||
list.addAll(getAllGenOresFromList(config.endOres));
|
||||
predicate = BlockMatcher.forBlock(Blocks.END_STONE);
|
||||
}
|
||||
else if (config.overworldOresInModdedDims || world.provider.getDimension() == 0) {
|
||||
list.addAll(getAllGenOresFromList(config.overworldOres));
|
||||
genTree = true;
|
||||
}
|
||||
|
||||
if (!list.isEmpty() && config.generateOres) {
|
||||
int xPos, yPos, zPos;
|
||||
for (OreConfig ore : list) {
|
||||
WorldGenMinable worldGenMinable = new WorldGenMinable(ore.state, ore.veinSize, predicate);
|
||||
if (ore.state == null) {
|
||||
continue;
|
||||
}
|
||||
for (int i = 0; i < ore.veinsPerChunk; i++) {
|
||||
xPos = chunkX * 16 + random.nextInt(16);
|
||||
if (ore.maxYHeight == -1 || ore.minYHeight == -1) {
|
||||
continue;
|
||||
}
|
||||
yPos = ore.minYHeight + random.nextInt(ore.maxYHeight - ore.minYHeight);
|
||||
zPos = chunkZ * 16 + random.nextInt(16);
|
||||
BlockPos pos = new BlockPos(xPos, yPos, zPos);
|
||||
|
||||
if (ore.veinSize < 4) {
|
||||
// Workaround for small veins
|
||||
for (int j = 1; j < ore.veinSize; j++) {
|
||||
// standard worldgen offset is added here like in WorldGenMinable#generate
|
||||
BlockPos smallVeinPos = pos.add(8, 0, 8);
|
||||
smallVeinPos.add(random.nextInt(2), random.nextInt(2), random.nextInt(2));
|
||||
IBlockState blockState = world.getBlockState(smallVeinPos);
|
||||
if (blockState.getBlock().isReplaceableOreGen(blockState, world, smallVeinPos, predicate)) {
|
||||
world.setBlockState(smallVeinPos, ore.state, 2);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
worldGenMinable.generate(world, random, pos);
|
||||
} catch (ArrayIndexOutOfBoundsException e) {
|
||||
TechReborn.LOGGER.error("Something bad is happening during world gen the ore "
|
||||
+ ore.blockNiceName
|
||||
+ " caused a crash when generating. Report this to the TechReborn devs with a log");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (genTree && config.rubberTreeConfig.shouldSpawn) {
|
||||
int chance = config.rubberTreeConfig.chance;
|
||||
boolean isValidSpawn = false;
|
||||
Biome biomeGenBase = world.getBiomeForCoordsBody(new BlockPos(chunkX * 16, 72, chunkZ * 16));
|
||||
if(biomeGenBase.getRegistryName() != null && Arrays.asList(config.rubberTreeConfig.rubberTreeBiomeBlacklist).contains(biomeGenBase.getRegistryName().toString())){
|
||||
return;
|
||||
}
|
||||
if (BiomeDictionary.hasType(biomeGenBase, BiomeDictionary.Type.SWAMP)) {
|
||||
// TODO check the config file for bounds on this, might cause issues
|
||||
chance -= random.nextInt(10) + 10;
|
||||
isValidSpawn = true;
|
||||
}
|
||||
if (BiomeDictionary.hasType(biomeGenBase, BiomeDictionary.Type.FOREST)
|
||||
|| BiomeDictionary.hasType(biomeGenBase, BiomeDictionary.Type.JUNGLE)) {
|
||||
chance -= random.nextInt(5) + 3;
|
||||
isValidSpawn = true;
|
||||
}
|
||||
if (!isValidSpawn) {
|
||||
return;
|
||||
}
|
||||
if (chance <= 0) {
|
||||
chance = 1;
|
||||
}
|
||||
if (random.nextInt(chance) == 0) {
|
||||
int x = chunkX * 16;
|
||||
int z = chunkZ * 16;
|
||||
for (int i = 0; i < config.rubberTreeConfig.clusterSize; i++) {
|
||||
treeGenerator.generate(world, random, new BlockPos(x, 72, z));
|
||||
}
|
||||
}
|
||||
}
|
||||
retroGen.markChunk(ChunkCoord.of(chunkX, chunkZ));
|
||||
}
|
||||
}
|
|
@ -1,36 +0,0 @@
|
|||
/*
|
||||
* This file is part of TechReborn, licensed under the MIT License (MIT).
|
||||
*
|
||||
* Copyright (c) 2018 TechReborn
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package techreborn.world.config;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
|
||||
/**
|
||||
* Created by modmuss50 on 11/03/2016.
|
||||
*/
|
||||
public interface IOreNameProvider {
|
||||
|
||||
public String getUserLoclisedName(IBlockState state);
|
||||
|
||||
}
|
|
@ -1,70 +0,0 @@
|
|||
/*
|
||||
* This file is part of TechReborn, licensed under the MIT License (MIT).
|
||||
*
|
||||
* Copyright (c) 2018 TechReborn
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package techreborn.world.config;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
|
||||
/**
|
||||
* Created by modmuss50 on 11/03/2016.
|
||||
*/
|
||||
public class OreConfig {
|
||||
|
||||
public String blockName;
|
||||
|
||||
public String blockNiceName;
|
||||
|
||||
public int meta;
|
||||
|
||||
// This doesn't get written to the json file
|
||||
public transient IBlockState state;
|
||||
|
||||
public int veinSize;
|
||||
|
||||
public int veinsPerChunk;
|
||||
|
||||
public int minYHeight;
|
||||
|
||||
public int maxYHeight;
|
||||
|
||||
public boolean shouldSpawn = true;
|
||||
|
||||
public OreConfig(IBlockState blockSate, int veinSize, int veinsPerChunk, int minYHeight, int maxYHeight) {
|
||||
this.meta = blockSate.getBlock().getMetaFromState(blockSate);
|
||||
this.state = blockSate;
|
||||
this.blockName = blockSate.getBlock().getTranslationKey();
|
||||
if (blockSate.getBlock() instanceof IOreNameProvider) {
|
||||
this.blockNiceName = ((IOreNameProvider) blockSate.getBlock()).getUserLoclisedName(blockSate);
|
||||
} else {
|
||||
this.blockNiceName = "unknown";
|
||||
}
|
||||
this.veinSize = veinSize;
|
||||
this.veinsPerChunk = veinsPerChunk;
|
||||
this.minYHeight = minYHeight;
|
||||
this.maxYHeight = maxYHeight;
|
||||
}
|
||||
|
||||
public OreConfig() {
|
||||
}
|
||||
}
|
|
@ -1,46 +0,0 @@
|
|||
/*
|
||||
* This file is part of TechReborn, licensed under the MIT License (MIT).
|
||||
*
|
||||
* Copyright (c) 2018 TechReborn
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package techreborn.world.config;
|
||||
|
||||
/**
|
||||
* Created by modmuss50 on 11/03/2016.
|
||||
*/
|
||||
// TODO add some sanity checks to this
|
||||
public class RubberTreeConfig {
|
||||
|
||||
public boolean shouldSpawn = true;
|
||||
|
||||
public int chance = 75;
|
||||
|
||||
public int clusterSize = 7;
|
||||
|
||||
public int sapRarity = 10;
|
||||
|
||||
public int spireHeight = 4;
|
||||
|
||||
public int treeBaseHeight = 5;
|
||||
|
||||
public String[] rubberTreeBiomeBlacklist = new String[]{};
|
||||
}
|
|
@ -1,49 +0,0 @@
|
|||
/*
|
||||
* This file is part of TechReborn, licensed under the MIT License (MIT).
|
||||
*
|
||||
* Copyright (c) 2018 TechReborn
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package techreborn.world.config;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by modmuss50 on 11/03/2016.
|
||||
*/
|
||||
public class WorldGenConfig {
|
||||
|
||||
public boolean generateTechRebornFeatures = true;
|
||||
|
||||
public boolean generateOres = true;
|
||||
|
||||
public boolean retroGenOres = false;
|
||||
|
||||
public boolean overworldOresInModdedDims = true;
|
||||
|
||||
public List<OreConfig> overworldOres;
|
||||
|
||||
public List<OreConfig> neatherOres;
|
||||
|
||||
public List<OreConfig> endOres;
|
||||
|
||||
public RubberTreeConfig rubberTreeConfig = new RubberTreeConfig();
|
||||
}
|
|
@ -96,7 +96,7 @@ public class VillageComponentRubberPlantaion extends VillagePieces.Field1 {
|
|||
return true;
|
||||
}
|
||||
|
||||
private void growRandom(int coloum, int row, MutableBoundingBox structureBoundingBox, Random random, World world) {
|
||||
private void growRandom(int coloum, int row, MutableBoundingBox structureBoundingBox, Random random, IWorld world) {
|
||||
if (random.nextInt(10) == 0) {
|
||||
setBlockState(world, Blocks.AIR.getDefaultState(), row, 1, coloum, structureBoundingBox);
|
||||
BlockPos pos = new BlockPos(this.getXWithOffset(row, coloum), this.getYWithOffset(1), this.getZWithOffset(row, coloum));
|
||||
|
|
Loading…
Reference in a new issue