Well that worked

This commit is contained in:
Sollace 2019-02-16 17:49:55 +02:00
parent 19d81acfc4
commit 31e92ac25f
8 changed files with 75 additions and 17 deletions

View file

@ -16,6 +16,7 @@ import net.minecraft.util.math.RayTraceResult;
import net.minecraft.world.World;
import net.minecraft.world.biome.Biome;
import net.minecraft.world.gen.structure.MapGenStructureIO;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.event.entity.ProjectileImpactEvent;
import net.minecraftforge.event.entity.item.ItemTossEvent;
@ -55,6 +56,7 @@ import com.minelittlepony.unicopia.command.Commands;
import com.minelittlepony.unicopia.enchanting.Pages;
import com.minelittlepony.unicopia.enchanting.SpellRecipe;
import com.minelittlepony.unicopia.forgebullshit.FBS;
import com.minelittlepony.unicopia.forgebullshit.FUF;
import com.minelittlepony.unicopia.inventory.gui.ContainerSpellBook;
import com.minelittlepony.unicopia.inventory.gui.GuiSpellBook;
import com.minelittlepony.unicopia.network.MsgPlayerAbility;
@ -76,6 +78,8 @@ import com.minelittlepony.unicopia.world.UWorld;
)
@EventBusSubscriber
public class Unicopia implements IGuiHandler {
public static final String MODID = "unicopia";
public static final String NAME = "@NAME@";
public static final String VERSION = "@VERSION@";
@ -86,10 +90,22 @@ public class Unicopia implements IGuiHandler {
private static CraftingManager craftingManager;
@EventHandler
public void preInit(FMLPreInitializationEvent event) {
UConfig.init(event.getModConfigurationDirectory());
UClient.instance().preInit(event);
UWorld.instance().init();
MinecraftForge.TERRAIN_GEN_BUS.register(Unicopia.class);
}
@FUF(reason = "Why u no run!?!??!")
@SubscribeEvent
public static void onStructureGenStatic(PopulateChunkEvent.Populate event) {
if (event.getType() == EventType.DUNGEON) {
UWorld.instance().generateStructures(event.getWorld(), event.getChunkX(), event.getChunkZ(), event.getGen());
}
}
@EventHandler
@ -132,13 +148,6 @@ public class Unicopia implements IGuiHandler {
MapGenStructureIO.registerStructureComponent(CloudDungeon.class, "unicopia:cloud_dungeon");
}
@EventHandler
public static void onStructureGen(PopulateChunkEvent.Populate event) {
if (event.getType() == EventType.DUNGEON) {
UWorld.instance().generateStructures(event.getWorld(), event.getChunkX(), event.getChunkZ(), event.getGen());
}
}
public static CraftingManager getCraftingManager() {
return craftingManager;
}

View file

@ -80,7 +80,7 @@ public class ParticleSphere extends Particle implements IAttachableParticle {
GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS);
if (alpha < 0) {
if (alpha < 1) {
GlStateManager.depthMask(false);
GlStateManager.shadeModel(GL11.GL_SMOOTH);
GlStateManager.tryBlendFuncSeparate(

View file

@ -107,6 +107,19 @@ public abstract class AbstractFeature extends StructureComponent {
super(x, z);
addComponents(world, rand, x, z, biome);
updateBoundingBox();
init(world, rand, x, z, biome);
}
protected void init(World world, Random rand, int x, int z, Biome biome) {
}
public void offset(int x, int y, int z) {
boundingBox.offset(x, y, z);
for (StructureComponent structurecomponent : components) {
structurecomponent.offset(x, y, z);
}
}
protected abstract void addComponents(World world, Random ran, int x, int z, Biome biome);

View file

@ -12,16 +12,24 @@ import net.minecraft.world.gen.structure.template.TemplateManager;
public class CloudDungeon extends TemplateBasedFeature {
private static final ResourceLocation STRUCTURE = new ResourceLocation(Unicopia.MODID, "cloud/dungeon_1");
private static final ResourceLocation STRUCTURE = new ResourceLocation(Unicopia.MODID, "cloud/temple_small");
public CloudDungeon() {
}
public CloudDungeon(Random rand, int x, int z) {
super(rand, x, 120, z, 7, 5, 8);
super(rand, x, 0, z, 7, 5, 8);
}
@Override
public boolean addComponentParts(World world, BlockPos startPos, TemplateManager templates, PlacementSettings placement) {
if (startPos.getY() < 200) {
startPos = new BlockPos(startPos.getX(), 200, startPos.getZ());
}
applyTemplate(world, startPos, templates, placement, STRUCTURE);
return false;
return true;
}
}

View file

@ -28,7 +28,6 @@ public abstract class TemplateBasedFeature extends AbstractFeature {
super(rand, x, y, z, sizeX, sizeY, sizeX);
}
@Override
public boolean addComponentParts(World world, Random rand, StructureBoundingBox bounds) {
@ -53,7 +52,7 @@ public abstract class TemplateBasedFeature extends AbstractFeature {
}
protected void applyTemplate(World world, BlockPos startPos, TemplateManager templates, PlacementSettings placement, ResourceLocation templateId) {
Template template = templates.get(world.getMinecraftServer(), templateId);
Template template = templates.getTemplate(world.getMinecraftServer(), templateId);
template.addBlocksToWorldChunk(world, startPos, placement);

View file

@ -9,6 +9,7 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraft.world.biome.Biome;
import net.minecraft.world.gen.structure.MapGenScatteredFeature;
import net.minecraft.world.gen.structure.StructureBoundingBox;
import net.minecraft.world.gen.structure.StructureStart;
public class CloudGen extends MapGenScatteredFeature {
@ -29,19 +30,27 @@ public class CloudGen extends MapGenScatteredFeature {
}
public static class Start extends AbstractFeature.Start {
public Start() { }
public Start() {
}
public Start(World world, Random rand, int x, int z) {
super(world, rand, x, z);
}
public Start(World world, Random rand, int x, int z, Biome biome) {
super(world, rand, x, z, biome);
@Override
protected void init(World world, Random rand, int x, int z, Biome biome) {
setRandomHeight(world, rand, 150, world.getActualHeight() - getBoundingBox().getYSize());
}
@Override
protected void addComponents(World world, Random rand, int x, int z, Biome biome) {
components.add(new CloudDungeon(rand, x * 16, z * 16));
}
@Override
public void generateStructure(World world, Random rand, StructureBoundingBox bounds) {
super.generateStructure(world, rand, bounds);
}
}
}

View file

@ -1,6 +1,7 @@
package com.minelittlepony.unicopia.world;
import java.util.Queue;
import java.util.Random;
import com.google.common.collect.Queues;
import com.minelittlepony.jumpingcastle.Exceptions;
@ -8,10 +9,14 @@ import com.minelittlepony.unicopia.Unicopia;
import net.minecraft.util.math.ChunkPos;
import net.minecraft.world.World;
import net.minecraft.world.chunk.ChunkPrimer;
import net.minecraft.world.chunk.IChunkProvider;
import net.minecraft.world.gen.ChunkGeneratorOverworld;
import net.minecraft.world.gen.IChunkGenerator;
import net.minecraftforge.fml.common.IWorldGenerator;
import net.minecraftforge.fml.common.registry.GameRegistry;
public class UWorld {
public class UWorld implements IWorldGenerator {
private static final UWorld instance = new UWorld();
@ -40,6 +45,10 @@ public class UWorld {
private CloudGen cloudStructureGen = new CloudGen();
public void init() {
GameRegistry.registerWorldGenerator(this, 1);
}
public void generateStructures(World world, int chunkX, int chunkZ, IChunkGenerator gen) {
if (gen instanceof ChunkGeneratorOverworld) {
if (world.getWorldInfo().isMapFeaturesEnabled()) {
@ -49,4 +58,15 @@ public class UWorld {
}
}
}
@Override
public void generate(Random random, int chunkX, int chunkZ, World world, IChunkGenerator chunkGenerator, IChunkProvider chunkProvider) {
if (chunkGenerator instanceof ChunkGeneratorOverworld) {
if (world.getWorldInfo().isMapFeaturesEnabled()) {
ChunkPrimer primer = new ChunkPrimer();
cloudStructureGen.generate(world, chunkX, chunkZ, primer);
}
}
}
}