mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-11-16 13:03:12 +01:00
Added a debug command to spawn all the blocks
This commit is contained in:
parent
6d4da92261
commit
1995378d49
2 changed files with 59 additions and 0 deletions
|
@ -2,11 +2,13 @@ package de.ellpeck.actuallyadditions.common;
|
||||||
|
|
||||||
import de.ellpeck.actuallyadditions.client.ClientSetup;
|
import de.ellpeck.actuallyadditions.client.ClientSetup;
|
||||||
import de.ellpeck.actuallyadditions.common.blocks.ActuallyBlocks;
|
import de.ellpeck.actuallyadditions.common.blocks.ActuallyBlocks;
|
||||||
|
import de.ellpeck.actuallyadditions.common.commands.DebugCommand;
|
||||||
import de.ellpeck.actuallyadditions.common.config.Config;
|
import de.ellpeck.actuallyadditions.common.config.Config;
|
||||||
import de.ellpeck.actuallyadditions.common.container.ActuallyContainers;
|
import de.ellpeck.actuallyadditions.common.container.ActuallyContainers;
|
||||||
import de.ellpeck.actuallyadditions.common.items.ActuallyItems;
|
import de.ellpeck.actuallyadditions.common.items.ActuallyItems;
|
||||||
import net.minecraft.client.renderer.RenderType;
|
import net.minecraft.client.renderer.RenderType;
|
||||||
import net.minecraft.client.renderer.RenderTypeLookup;
|
import net.minecraft.client.renderer.RenderTypeLookup;
|
||||||
|
import net.minecraft.command.Commands;
|
||||||
import net.minecraft.item.ItemGroup;
|
import net.minecraft.item.ItemGroup;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraftforge.common.MinecraftForge;
|
import net.minecraftforge.common.MinecraftForge;
|
||||||
|
@ -16,6 +18,7 @@ import net.minecraftforge.fml.common.Mod;
|
||||||
import net.minecraftforge.fml.config.ModConfig;
|
import net.minecraftforge.fml.config.ModConfig;
|
||||||
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
|
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
|
||||||
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
|
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
|
||||||
|
import net.minecraftforge.fml.event.server.FMLServerStartingEvent;
|
||||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||||
import org.apache.logging.log4j.LogManager;
|
import org.apache.logging.log4j.LogManager;
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
|
@ -47,13 +50,17 @@ public class ActuallyAdditions {
|
||||||
eventBus.addListener(this::setup);
|
eventBus.addListener(this::setup);
|
||||||
eventBus.addListener(this::clientSetup);
|
eventBus.addListener(this::clientSetup);
|
||||||
|
|
||||||
|
MinecraftForge.EVENT_BUS.addListener(this::serverLoad);
|
||||||
MinecraftForge.EVENT_BUS.register(this);
|
MinecraftForge.EVENT_BUS.register(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setup(FMLCommonSetupEvent event) {
|
private void setup(FMLCommonSetupEvent event) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void clientSetup(FMLClientSetupEvent event) {
|
private void clientSetup(FMLClientSetupEvent event) {
|
||||||
|
ClientSetup.setup();
|
||||||
|
|
||||||
RenderTypeLookup.setRenderLayer(ActuallyBlocks.CRYSTAL_CLUSTER_VOID.get(), RenderType.getTranslucent());
|
RenderTypeLookup.setRenderLayer(ActuallyBlocks.CRYSTAL_CLUSTER_VOID.get(), RenderType.getTranslucent());
|
||||||
RenderTypeLookup.setRenderLayer(ActuallyBlocks.CRYSTAL_CLUSTER_ENORI.get(), RenderType.getTranslucent());
|
RenderTypeLookup.setRenderLayer(ActuallyBlocks.CRYSTAL_CLUSTER_ENORI.get(), RenderType.getTranslucent());
|
||||||
RenderTypeLookup.setRenderLayer(ActuallyBlocks.CRYSTAL_CLUSTER_RESTONIA.get(), RenderType.getTranslucent());
|
RenderTypeLookup.setRenderLayer(ActuallyBlocks.CRYSTAL_CLUSTER_RESTONIA.get(), RenderType.getTranslucent());
|
||||||
|
@ -62,4 +69,11 @@ public class ActuallyAdditions {
|
||||||
RenderTypeLookup.setRenderLayer(ActuallyBlocks.CRYSTAL_CLUSTER_EMERADIC.get(), RenderType.getTranslucent());
|
RenderTypeLookup.setRenderLayer(ActuallyBlocks.CRYSTAL_CLUSTER_EMERADIC.get(), RenderType.getTranslucent());
|
||||||
RenderTypeLookup.setRenderLayer(ActuallyBlocks.GREENHOUSE_GLASS.get(), RenderType.getCutout());
|
RenderTypeLookup.setRenderLayer(ActuallyBlocks.GREENHOUSE_GLASS.get(), RenderType.getCutout());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void serverLoad(FMLServerStartingEvent event) {
|
||||||
|
event.getServer().getCommandManager().getDispatcher().register(
|
||||||
|
Commands.literal(MOD_ID)
|
||||||
|
.then(DebugCommand.register())
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,45 @@
|
||||||
|
package de.ellpeck.actuallyadditions.common.commands;
|
||||||
|
|
||||||
|
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
||||||
|
import com.mojang.brigadier.context.CommandContext;
|
||||||
|
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||||
|
import de.ellpeck.actuallyadditions.common.blocks.ActuallyBlocks;
|
||||||
|
import net.minecraft.block.Block;
|
||||||
|
import net.minecraft.command.CommandSource;
|
||||||
|
import net.minecraft.command.Commands;
|
||||||
|
import net.minecraft.entity.player.ServerPlayerEntity;
|
||||||
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import net.minecraftforge.fml.RegistryObject;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
|
||||||
|
public class DebugCommand {
|
||||||
|
public static LiteralArgumentBuilder<CommandSource> register() {
|
||||||
|
return Commands.literal("debug-spawn")
|
||||||
|
.requires(commandSource -> commandSource.hasPermissionLevel(2))
|
||||||
|
.executes(DebugCommand::execute);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static int execute(CommandContext<CommandSource> context) throws CommandSyntaxException {
|
||||||
|
ServerPlayerEntity player = context.getSource().asPlayer();
|
||||||
|
|
||||||
|
Collection<RegistryObject<Block>> entries = ActuallyBlocks.BLOCKS.getEntries();
|
||||||
|
|
||||||
|
int x = player.getPosition().getX(), z = player.getPosition().getZ();
|
||||||
|
int row = 0, col = 0;
|
||||||
|
for (RegistryObject<Block> block: entries) {
|
||||||
|
if (row > 10) {
|
||||||
|
col += 1;
|
||||||
|
row = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
context.getSource().getWorld().setBlockState(new BlockPos(
|
||||||
|
x + (2 * row), player.getPosition().getY(), z + (2 * col)
|
||||||
|
), block.get().getDefaultState());
|
||||||
|
|
||||||
|
row ++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue