Messages when stones are generating
This commit is contained in:
parent
7b6099e8e2
commit
98ac438a98
|
@ -3,6 +3,7 @@ package anvil.infinity;
|
|||
import anvil.infinity.capabilities.Factory;
|
||||
import anvil.infinity.capabilities.ICapabilityPlayerData;
|
||||
import anvil.infinity.capabilities.Storage;
|
||||
import anvil.infinity.command.GeneratedCommand;
|
||||
import anvil.infinity.compat.CompatHandler;
|
||||
import anvil.infinity.config.ConfigHandler;
|
||||
import anvil.infinity.config.ModConfig;
|
||||
|
@ -18,6 +19,7 @@ import net.minecraftforge.event.RegistryEvent;
|
|||
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 net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.common.network.NetworkRegistry;
|
||||
|
@ -69,5 +71,11 @@ public class Infinity {
|
|||
|
||||
}
|
||||
|
||||
@Mod.EventHandler
|
||||
public static void init(FMLServerStartingEvent event)
|
||||
{
|
||||
event.registerServerCommand(new GeneratedCommand());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
package anvil.infinity.command;
|
||||
|
||||
import anvil.infinity.worldgen.WorldData;
|
||||
import net.minecraft.command.CommandBase;
|
||||
import net.minecraft.command.CommandException;
|
||||
import net.minecraft.command.ICommandSender;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.TextComponentString;
|
||||
|
||||
public class GeneratedCommand extends CommandBase {
|
||||
@Override
|
||||
public String getName() {
|
||||
return "generatedStones";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUsage(ICommandSender sender) {
|
||||
return "Shows, which stones are generated";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException {
|
||||
WorldData data = WorldData.get(server.getWorld(0));
|
||||
ITextComponent msg = new TextComponentString("Generated: ");
|
||||
msg.appendText("\n Space Stone: " + data.space);
|
||||
msg.appendText("\n Power Stone: " + data.power);
|
||||
msg.appendText("\n Mind Stone: " + data.mind);
|
||||
msg.appendText("\n Soul Stone: " + data.soul);
|
||||
msg.appendText("\n Time Stone: " + data.time);
|
||||
msg.appendText("\n Reality Stone: " + data.reality);
|
||||
sender.sendMessage(msg);
|
||||
}
|
||||
}
|
|
@ -72,6 +72,10 @@ public class ModConfig {
|
|||
@Config.Name("Mind Stone Dimension")
|
||||
public static int mindDim = 0;
|
||||
|
||||
@Config.Name("Worldgen Debug")
|
||||
@Config.Comment("WARNING: Console Spam")
|
||||
public static boolean debug = false;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -23,10 +23,16 @@ public class InfinityWorldGenerator extends WorldGenerator implements IWorldGene
|
|||
@Override
|
||||
public void generate(Random random, int chunkX, int chunkZ, World world, IChunkGenerator chunkGenerator, IChunkProvider chunkProvider) {
|
||||
int dim = world.provider.getDimension();
|
||||
if (ModConfig.Worldgen.debug)
|
||||
System.out.println("Chunk generation in Dim: " + dim);
|
||||
|
||||
if ( (chunkX > 1000 || chunkX < -1000) && (chunkZ > 1000 || chunkZ < -1000) && ModConfig.Worldgen.enable ) {
|
||||
int blockX = chunkX * 16 + 8;
|
||||
int blockZ = chunkZ * 16 + 8;
|
||||
if (canGenMind(world) || canGenPower(world) || canGenReality(world) || canGenSoul(world) || canGenSpace(world) || canGenTime(world)) {
|
||||
if (ModConfig.Worldgen.debug)
|
||||
System.out.println("A Stone can be generted here");
|
||||
|
||||
if ((int) (Math.random() * 1000) == 0) {
|
||||
int y = getGroundFromAbove(world, blockX, blockZ);
|
||||
BlockPos pos = new BlockPos(blockX, y, blockZ);
|
||||
|
|
|
@ -8,6 +8,7 @@ import net.minecraft.init.Blocks;
|
|||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.management.PlayerList;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.tileentity.TileEntityChest;
|
||||
import net.minecraft.util.Mirror;
|
||||
|
@ -15,6 +16,9 @@ import net.minecraft.util.ResourceLocation;
|
|||
import net.minecraft.util.Rotation;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.ChunkPos;
|
||||
import net.minecraft.util.text.TextComponentString;
|
||||
import net.minecraft.util.text.TextComponentTranslation;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.WorldServer;
|
||||
import net.minecraft.world.gen.feature.WorldGenerator;
|
||||
|
@ -35,36 +39,42 @@ public class StoneTempleGen extends WorldGenerator {
|
|||
WorldData data = WorldData.get(world);
|
||||
data.mind = true;
|
||||
data.markDirty();
|
||||
sendMessage("Mind", world);
|
||||
return true;
|
||||
} else if (InfinityWorldGenerator.canGenSpace(world)) {
|
||||
gen(world, position, Items.SPACE_STONE);
|
||||
WorldData data = WorldData.get(world);
|
||||
data.space = true;
|
||||
data.markDirty();
|
||||
sendMessage("Space", world);
|
||||
return true;
|
||||
} else if (InfinityWorldGenerator.canGenReality(world)) {
|
||||
gen(world, position, Items.REALITY_STONE);
|
||||
WorldData data = WorldData.get(world);
|
||||
data.reality = true;
|
||||
data.markDirty();
|
||||
sendMessage("Reality", world);
|
||||
return true;
|
||||
} else if (InfinityWorldGenerator.canGenTime(world)) {
|
||||
gen(world, position, Items.TIME_STONE);
|
||||
WorldData data = WorldData.get(world);
|
||||
data.time = true;
|
||||
data.markDirty();
|
||||
sendMessage("Time", world);
|
||||
return true;
|
||||
} else if (InfinityWorldGenerator.canGenSoul(world)) {
|
||||
gen(world, position, Items.SOUL_STONE);
|
||||
WorldData data = WorldData.get(world);
|
||||
data.soul = true;
|
||||
data.markDirty();
|
||||
sendMessage("Soul", world);
|
||||
return true;
|
||||
} else if (InfinityWorldGenerator.canGenPower(world)) {
|
||||
gen(world, position, Items.POWER_STONE);
|
||||
WorldData data = WorldData.get(world);
|
||||
data.power = true;
|
||||
data.markDirty();
|
||||
sendMessage("Power", world);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -104,4 +114,14 @@ public class StoneTempleGen extends WorldGenerator {
|
|||
}
|
||||
}
|
||||
|
||||
void sendMessage(String stone, World world) {
|
||||
MinecraftServer server = world.getMinecraftServer();
|
||||
assert server != null;
|
||||
PlayerList players = server.getPlayerList();
|
||||
TextComponentString msg = new TextComponentString("The " + stone + " Stone has been generated");
|
||||
msg.getStyle().setColor(TextFormatting.GOLD);
|
||||
msg.getStyle().setBold(true);
|
||||
players.sendMessage(msg);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -13,6 +13,10 @@ public class WorldData extends WorldSavedData {
|
|||
super(NAME);
|
||||
}
|
||||
|
||||
public WorldData(String name) {
|
||||
super(name);
|
||||
}
|
||||
|
||||
public boolean power;
|
||||
public boolean space;
|
||||
public boolean reality;
|
||||
|
|
Loading…
Reference in New Issue