Search in sources :

Example 6 with RCEntityInfo

use of ivorius.reccomplex.capability.RCEntityInfo in project RecurrentComplex by Ivorforce.

the class CommandPreview method execute.

@Override
public void execute(MinecraftServer server, ICommandSender commandSender, String[] args) throws CommandException {
    RCParameters parameters = RCParameters.of(args);
    EntityPlayer player = getCommandSenderAsPlayer(commandSender);
    RCEntityInfo RCEntityInfo = RCCommands.getStructureEntityInfo(player, null);
    Operation.PreviewType previewType = parameters.get().first().map(Operation.PreviewType::find, s -> ServerTranslations.commandException("commands.rcpreview.invalid")).require();
    RCEntityInfo.setPreviewType(previewType);
    RCEntityInfo.sendPreviewTypeToClients(player);
    commandSender.sendMessage(ServerTranslations.format("commands.rcpreview.success", previewType.key));
}
Also used : RCParameters(ivorius.reccomplex.commands.parameters.RCParameters) Operation(ivorius.reccomplex.operation.Operation) RCCommands(ivorius.reccomplex.commands.RCCommands) RCEntityInfo(ivorius.reccomplex.capability.RCEntityInfo) ServerTranslations(ivorius.reccomplex.utils.ServerTranslations) CommandBase(net.minecraft.command.CommandBase) BlockPos(net.minecraft.util.math.BlockPos) RCConfig(ivorius.reccomplex.RCConfig) RCExpect(ivorius.reccomplex.commands.parameters.RCExpect) CommandException(net.minecraft.command.CommandException) MinecraftServer(net.minecraft.server.MinecraftServer) List(java.util.List) ICommandSender(net.minecraft.command.ICommandSender) EntityPlayer(net.minecraft.entity.player.EntityPlayer) RCParameters(ivorius.reccomplex.commands.parameters.RCParameters) Nullable(javax.annotation.Nullable) EntityPlayer(net.minecraft.entity.player.EntityPlayer) RCEntityInfo(ivorius.reccomplex.capability.RCEntityInfo) Operation(ivorius.reccomplex.operation.Operation)

Example 7 with RCEntityInfo

use of ivorius.reccomplex.capability.RCEntityInfo in project RecurrentComplex by Ivorforce.

the class CommandCancel method execute.

@Override
public void execute(MinecraftServer server, ICommandSender commandSender, String[] args) throws CommandException {
    EntityPlayer player = getCommandSenderAsPlayer(commandSender);
    RCEntityInfo RCEntityInfo = RCCommands.getStructureEntityInfo(player, null);
    if (!RCEntityInfo.cancelOperation(commandSender.getEntityWorld(), player))
        throw ServerTranslations.commandException("commands.rc.noOperation");
}
Also used : EntityPlayer(net.minecraft.entity.player.EntityPlayer) RCEntityInfo(ivorius.reccomplex.capability.RCEntityInfo)

Example 8 with RCEntityInfo

use of ivorius.reccomplex.capability.RCEntityInfo in project RecurrentComplex by Ivorforce.

the class RCRegistryHandler method preInit.

public static void preInit(FMLPreInitializationEvent event, RecurrentComplex mod) {
    if (!RecurrentComplex.isLite()) {
        tabStructureTools = new CreativeTabs("structureTools") {

            @Override
            public ItemStack getTabIconItem() {
                return new ItemStack(RCItems.blockSelector);
            }
        };
        tabInventoryGenerators = new CreativeTabs("inventoryGenerators") {

            @Override
            public ItemStack getTabIconItem() {
                return new ItemStack(RCItems.inventoryGenerationTag);
            }
        };
    }
    RCMaterials.materialNegativeSpace = new MaterialNegativeSpace();
    RCMaterials.materialGenericSolid = (new Material(MapColor.STONE));
    CapabilityManager.INSTANCE.register(RCEntityInfo.class, new NBTCompoundObjectCapabilityStorage<>(RCEntityInfo.class), RCEntityInfo::new);
    CapabilityManager.INSTANCE.register(CapabilitySelection.class, new NBTCompoundObjectCapabilityStorage<>(CapabilitySelection.class), CapabilitySelection::new);
    blockSelector = new ItemBlockSelectorBlock().setUnlocalizedName("blockSelector");
    blockSelector.setCreativeTab(tabStructureTools);
    register(blockSelector, "block_selector");
    RecurrentComplex.cremapper.registerLegacyIDs(blockSelector, "blockSelector");
    blockSelectorFloating = new ItemBlockSelectorFloating().setUnlocalizedName("blockSelectorFloating");
    blockSelectorFloating.setCreativeTab(tabStructureTools);
    register(blockSelectorFloating, "block_selector_floating");
    RecurrentComplex.cremapper.registerLegacyIDs(blockSelectorFloating, "blockSelectorFloating");
    inventoryGenerationTag = (ItemInventoryGenMultiTag) new ItemInventoryGenMultiTag().setUnlocalizedName("inventoryGenerationTag");
    inventoryGenerationTag.setCreativeTab(tabInventoryGenerators);
    register(inventoryGenerationTag, "inventory_generation_tag");
    RecurrentComplex.cremapper.registerLegacyIDs(inventoryGenerationTag, "inventoryGenerationTag");
    inventoryGenerationSingleTag = (ItemInventoryGenSingleTag) new ItemInventoryGenSingleTag().setUnlocalizedName("inventoryGenerationSingleTag");
    inventoryGenerationSingleTag.setCreativeTab(tabInventoryGenerators);
    register(inventoryGenerationSingleTag, "inventory_generation_single_tag");
    RecurrentComplex.cremapper.registerLegacyIDs(inventoryGenerationSingleTag, "inventoryGenerationSingleTag");
    inventoryGenerationComponentTag = (ItemInventoryGenComponentTag) new ItemInventoryGenComponentTag().setUnlocalizedName("inventoryGenerationComponentTag");
    inventoryGenerationComponentTag.setCreativeTab(tabInventoryGenerators);
    register(inventoryGenerationComponentTag, "inventory_generation_component_tag");
    artifactGenerationTag = new ItemArtifactGenerator().setUnlocalizedName("artifactGenerationTag");
    artifactGenerationTag.setCreativeTab(tabInventoryGenerators);
    register(artifactGenerationTag, "artifact_generation_tag");
    RecurrentComplex.cremapper.registerLegacyIDs(artifactGenerationTag, "artifactGenerationTag");
    bookGenerationTag = new ItemBookGenerator().setUnlocalizedName("bookGenerationTag");
    bookGenerationTag.setCreativeTab(tabInventoryGenerators);
    register(bookGenerationTag, "book_generation_tag");
    RecurrentComplex.cremapper.registerLegacyIDs(bookGenerationTag, "bookGenerationTag");
    genericSpace = (BlockGenericSpace) new BlockGenericSpace().setUnlocalizedName("negativeSpace");
    genericSpace.setCreativeTab(tabStructureTools);
    register(genericSpace, "generic_space", new ItemBlockGenericSpace(genericSpace));
    RecurrentComplex.cremapper.registerLegacyIDs(genericSpace, true, "negativeSpace");
    genericSolid = new BlockGenericSolid().setUnlocalizedName("naturalFloor");
    genericSolid.setCreativeTab(tabStructureTools);
    register(genericSolid, "generic_solid", new ItemBlockGenericSolid(genericSolid));
    RecurrentComplex.cremapper.registerLegacyIDs(genericSolid, true, "naturalFloor");
    structureGenerator = new BlockStructureGenerator().setUnlocalizedName("structureGenerator");
    register(structureGenerator, "structure_generator");
    register(BlockStructureGenerator.TileEntityStructureGenerator.class, "RCStructureGenerator", "SGStructureGenerator");
    RecurrentComplex.cremapper.registerLegacyIDs(structureGenerator, true, "structureGenerator");
    mazeGenerator = new BlockMazeGenerator().setUnlocalizedName("mazeGenerator");
    register(mazeGenerator, "maze_generator");
    register(BlockMazeGenerator.TileEntityMazeGenerator.class, "RCMazeGenerator", "SGMazeGenerator");
    RecurrentComplex.cremapper.registerLegacyIDs(mazeGenerator, true, "mazeGenerator");
    spawnCommands = new BlockSpawnCommand().setUnlocalizedName("spawn_command");
    register(spawnCommands, "weighted_command_block");
    register(BlockSpawnCommand.TileEntitySpawnCommand.class, "RCSpawnCommand");
    RecurrentComplex.cremapper.registerLegacyIDs(spawnCommands, true, "spawnCommand");
    spawnScript = new BlockScript().setUnlocalizedName("spawn_script");
    spawnScript.setCreativeTab(tabStructureTools);
    register(spawnScript, "spawn_script");
    register(TileEntityBlockScript.class, "RCSpawnScript");
    inspector = new ItemInspector().setUnlocalizedName("recinspector");
    inspector.setCreativeTab(tabStructureTools);
    register(inspector, "inspector");
    // Set preset defaults
    GenericPlacerPresets.instance().getRegistry().register("clear", MOD_ID, PresetRegistry.fullPreset("clear", new GenericPlacer(), new PresetRegistry.Metadata("Clear", "Do not place anywhere")), true, LeveledRegistry.Level.INTERNAL);
    GenericPlacerPresets.instance().setDefault("clear");
    DimensionMatcherPresets.instance().getRegistry().register("clear", MOD_ID, PresetRegistry.fullPreset("clear", new ArrayList<>(), new PresetRegistry.Metadata("None", "No dimensions")), true, LeveledRegistry.Level.INTERNAL);
    DimensionMatcherPresets.instance().setDefault("clear");
    BiomeMatcherPresets.instance().getRegistry().register("clear", MOD_ID, PresetRegistry.fullPreset("clear", new ArrayList<>(), new PresetRegistry.Metadata("None", "No biomes")), true, LeveledRegistry.Level.INTERNAL);
    BiomeMatcherPresets.instance().setDefault("clear");
    WeightedBlockStatePresets.instance().getRegistry().register("clear", MOD_ID, PresetRegistry.fullPreset("clear", new ArrayList<>(), new PresetRegistry.Metadata("None", "No blocks")), true, LeveledRegistry.Level.INTERNAL);
    WeightedBlockStatePresets.instance().setDefault("clear");
    TransfomerPresets.instance().getRegistry().register("clear", MOD_ID, PresetRegistry.fullPreset("clear", new TransformerMulti.Data(), new PresetRegistry.Metadata("None", "No transformers")), true, LeveledRegistry.Level.INTERNAL);
    TransfomerPresets.instance().setDefault("clear");
    GenerationSanityChecker.init();
}
Also used : ArrayList(java.util.ArrayList) GenericPlacer(ivorius.reccomplex.world.gen.feature.structure.generic.placement.GenericPlacer) CapabilitySelection(ivorius.reccomplex.capability.CapabilitySelection) Material(net.minecraft.block.material.Material) CreativeTabs(net.minecraft.creativetab.CreativeTabs) RCEntityInfo(ivorius.reccomplex.capability.RCEntityInfo) MaterialNegativeSpace(ivorius.reccomplex.block.materials.MaterialNegativeSpace) ItemStack(net.minecraft.item.ItemStack)

Example 9 with RCEntityInfo

use of ivorius.reccomplex.capability.RCEntityInfo in project RecurrentComplex by Ivorforce.

the class PacketEditStructureHandler method openEditStructure.

public static void openEditStructure(GenericStructure structureInfo, String structureID, EntityPlayerMP player) {
    if (structureID == null)
        structureID = "NewStructure";
    RCEntityInfo entityInfo = RCEntityInfo.get(player, null);
    if (entityInfo != null)
        entityInfo.setCachedExportStructureBlockDataNBT(structureInfo.worldDataCompound);
    SimpleLeveledRegistry<Structure<?>>.Status<Structure<?>> status = StructureRegistry.INSTANCE.status(structureID);
    RecurrentComplex.network.sendTo(new PacketEditStructure(structureInfo, structureID, SaveDirectoryData.defaultData(structureID, status != null && status.isActive(), RecurrentComplex.loader.tryFindIDs(ResourceDirectory.ACTIVE.toPath(), RCFileSuffix.STRUCTURE), RecurrentComplex.loader.tryFindIDs(ResourceDirectory.INACTIVE.toPath(), RCFileSuffix.STRUCTURE))), player);
}
Also used : RCEntityInfo(ivorius.reccomplex.capability.RCEntityInfo) GenericStructure(ivorius.reccomplex.world.gen.feature.structure.generic.GenericStructure) Structure(ivorius.reccomplex.world.gen.feature.structure.Structure) GuiEditGenericStructure(ivorius.reccomplex.gui.editstructure.GuiEditGenericStructure) SimpleLeveledRegistry(ivorius.reccomplex.files.SimpleLeveledRegistry)

Example 10 with RCEntityInfo

use of ivorius.reccomplex.capability.RCEntityInfo in project RecurrentComplex by Ivorforce.

the class RCForgeEventHandler method onDrawWorld.

@SideOnly(Side.CLIENT)
@SubscribeEvent
public void onDrawWorld(RenderWorldLastEvent event) {
    Minecraft mc = Minecraft.getMinecraft();
    int ticks = mc.player.ticksExisted;
    Entity renderEntity = mc.getRenderViewEntity();
    RCEntityInfo info = RCEntityInfo.get(mc.player, null);
    double entityX = renderEntity.lastTickPosX + (renderEntity.posX - renderEntity.lastTickPosX) * (double) event.getPartialTicks();
    double entityY = renderEntity.lastTickPosY + (renderEntity.posY - renderEntity.lastTickPosY) * (double) event.getPartialTicks();
    double entityZ = renderEntity.lastTickPosZ + (renderEntity.posZ - renderEntity.lastTickPosZ) * (double) event.getPartialTicks();
    GlStateManager.pushMatrix();
    GlStateManager.translate(-entityX, -entityY, -entityZ);
    if (info != null && info.showGrid) {
        int spacing = 10;
        GlStateManager.disableTexture2D();
        GlStateManager.color(0.5f, 0.5f, 0.5f);
        GlStateManager.pushMatrix();
        GlStateManager.translate(MathHelper.floor(entityX / spacing) * spacing, MathHelper.floor(entityY / spacing) * spacing, MathHelper.floor(entityZ / spacing) * spacing);
        GridRenderer.renderGrid(8, spacing, 100, 0.05f);
        GlStateManager.popMatrix();
        GlStateManager.enableTexture2D();
    }
    SelectionRenderer.renderSelection(mc.player, ticks, event.getPartialTicks());
    if (info != null && info.danglingOperation != null)
        info.danglingOperation.renderPreview(info.getPreviewType(), mc.world, ticks, event.getPartialTicks());
    GlStateManager.popMatrix();
}
Also used : Entity(net.minecraft.entity.Entity) RCEntityInfo(ivorius.reccomplex.capability.RCEntityInfo) Minecraft(net.minecraft.client.Minecraft) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Aggregations

RCEntityInfo (ivorius.reccomplex.capability.RCEntityInfo)12 EntityPlayer (net.minecraft.entity.player.EntityPlayer)5 GenericStructure (ivorius.reccomplex.world.gen.feature.structure.generic.GenericStructure)3 WorldServer (net.minecraft.world.WorldServer)3 CapabilitySelection (ivorius.reccomplex.capability.CapabilitySelection)2 SelectionOwner (ivorius.reccomplex.capability.SelectionOwner)2 RCParameters (ivorius.reccomplex.commands.parameters.RCParameters)2 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)2 BlockPos (net.minecraft.util.math.BlockPos)2 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)2 BlockArea (ivorius.ivtoolkit.blocks.BlockArea)1 AxisAlignedTransform2D (ivorius.ivtoolkit.math.AxisAlignedTransform2D)1 IvWorldData (ivorius.ivtoolkit.tools.IvWorldData)1 RCConfig (ivorius.reccomplex.RCConfig)1 MaterialNegativeSpace (ivorius.reccomplex.block.materials.MaterialNegativeSpace)1 RCCommands (ivorius.reccomplex.commands.RCCommands)1 RCExpect (ivorius.reccomplex.commands.parameters.RCExpect)1 SimpleLeveledRegistry (ivorius.reccomplex.files.SimpleLeveledRegistry)1 ResourceDirectory (ivorius.reccomplex.files.loading.ResourceDirectory)1 GuiEditGenericStructure (ivorius.reccomplex.gui.editstructure.GuiEditGenericStructure)1