Search in sources :

Example 1 with IStructureConfigurationCapability

use of com.wuest.prefab.Capabilities.IStructureConfigurationCapability in project MC-Prefab by Brian-Wuest.

the class GuiBasicStructure method Initialize.

@Override
protected void Initialize() {
    // Get the structure configuration for this itemstack.
    ItemStack stack = ItemBasicStructure.getBasicStructureItemInHand(this.player);
    if (stack != null) {
        IStructureConfigurationCapability capability = stack.getCapability(ModRegistry.StructureConfiguration, EnumFacing.NORTH);
        this.configuration = capability.getConfiguration();
        if (!ClientEventHandler.playerConfig.clientConfigurations.containsKey(this.configuration.basicStructureName.getName())) {
            ClientEventHandler.playerConfig.clientConfigurations.put(this.configuration.basicStructureName.getName(), this.configuration);
        } else {
            this.configuration = ClientEventHandler.playerConfig.getClientConfig(this.configuration.basicStructureName.getName(), BasicStructureConfiguration.class);
        }
        this.includePicture = this.doesPictureExist();
    }
    this.configuration.pos = this.pos;
    if (!this.includePicture) {
        this.modifiedInitialXAxis = 125;
    }
    // Get the upper left hand corner of the GUI box.
    int grayBoxX = this.getCenteredXAxis() - this.modifiedInitialXAxis;
    int grayBoxY = this.getCenteredYAxis() - this.modifiedINitialYAxis;
    // Create the buttons.
    this.btnVisualize = new GuiButtonExt(4, grayBoxX + 10, grayBoxY + 20, 90, 20, GuiLangKeys.translateString(GuiLangKeys.GUI_BUTTON_PREVIEW));
    this.buttonList.add(this.btnVisualize);
    // Create the done and cancel buttons.
    this.btnBuild = new GuiButtonExt(1, grayBoxX + 10, grayBoxY + 136, 90, 20, GuiLangKeys.translateString(GuiLangKeys.GUI_BUTTON_BUILD));
    this.buttonList.add(this.btnBuild);
    this.btnCancel = new GuiButtonExt(2, grayBoxX + 147, grayBoxY + 136, 90, 20, GuiLangKeys.translateString(GuiLangKeys.GUI_BUTTON_CANCEL));
    this.buttonList.add(this.btnCancel);
}
Also used : BasicStructureConfiguration(com.wuest.prefab.Config.Structures.BasicStructureConfiguration) GuiButtonExt(net.minecraftforge.fml.client.config.GuiButtonExt) IStructureConfigurationCapability(com.wuest.prefab.Capabilities.IStructureConfigurationCapability) ItemStack(net.minecraft.item.ItemStack)

Example 2 with IStructureConfigurationCapability

use of com.wuest.prefab.Capabilities.IStructureConfigurationCapability in project MC-Prefab by Brian-Wuest.

the class ItemBasicStructure method getSubItems.

/**
 * returns a list of items with the same ID, but different meta (eg: dye
 * returns 16 items)
 */
@Override
@SideOnly(Side.CLIENT)
public void getSubItems(CreativeTabs tab, NonNullList<ItemStack> subItems) {
    if (this.isInCreativeTab(tab)) {
        for (EnumBasicStructureName value : EnumBasicStructureName.values()) {
            if (value.getResourceLocation() != null) {
                ItemStack stack = new ItemStack(this);
                IStructureConfigurationCapability capability = stack.getCapability(ModRegistry.StructureConfiguration, EnumFacing.NORTH);
                capability.getConfiguration().basicStructureName = value;
                subItems.add(stack);
            }
        }
    }
}
Also used : EnumBasicStructureName(com.wuest.prefab.Config.Structures.BasicStructureConfiguration.EnumBasicStructureName) IStructureConfigurationCapability(com.wuest.prefab.Capabilities.IStructureConfigurationCapability) ItemStack(net.minecraft.item.ItemStack) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 3 with IStructureConfigurationCapability

use of com.wuest.prefab.Capabilities.IStructureConfigurationCapability in project MC-Prefab by Brian-Wuest.

the class ItemBasicStructure method getStackCapability.

public static IStructureConfigurationCapability getStackCapability(ItemStack stack) {
    if (stack.hasCapability(ModRegistry.StructureConfiguration, EnumFacing.NORTH)) {
        NBTTagCompound forgeCapabilities = stack.getSubCompound("ForgeCaps");
        IStructureConfigurationCapability stackCapability = stack.getCapability(ModRegistry.StructureConfiguration, EnumFacing.NORTH);
        if (forgeCapabilities != null) {
            if (stackCapability.getDirty() && forgeCapabilities.hasKey(Prefab.MODID + ":structuresconfiguration")) {
                StructureConfigurationCapability capabilityTemp = new StructureConfigurationCapability();
                StructureConfigurationStorage storage = new StructureConfigurationStorage();
                storage.readNBT(ModRegistry.StructureConfiguration, capabilityTemp, EnumFacing.NORTH, forgeCapabilities.getCompoundTag(Prefab.MODID + ":structuresconfiguration"));
                if (!capabilityTemp.getConfiguration().basicStructureName.getName().equals(stackCapability.getConfiguration().basicStructureName.getName())) {
                    stackCapability.setConfiguration(capabilityTemp.getConfiguration());
                    stackCapability.setDirty(false);
                }
            }
        }
        return stackCapability;
    }
    return null;
}
Also used : StructureConfigurationCapability(com.wuest.prefab.Capabilities.StructureConfigurationCapability) IStructureConfigurationCapability(com.wuest.prefab.Capabilities.IStructureConfigurationCapability) StructureConfigurationStorage(com.wuest.prefab.Capabilities.Storage.StructureConfigurationStorage) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) IStructureConfigurationCapability(com.wuest.prefab.Capabilities.IStructureConfigurationCapability)

Example 4 with IStructureConfigurationCapability

use of com.wuest.prefab.Capabilities.IStructureConfigurationCapability in project MC-Prefab by Brian-Wuest.

the class PrefabModelMesher method getModelLocation.

@Override
public ModelResourceLocation getModelLocation(ItemStack stack) {
    IStructureConfigurationCapability structureCapability = ItemBasicStructure.getStackCapability(stack);
    ResourceLocation resourceLocation = null;
    if (structureCapability != null) {
        resourceLocation = structureCapability.getConfiguration().basicStructureName.getResourceLocation();
    }
    if (resourceLocation == null) {
        resourceLocation = EnumBasicStructureName.AdvancedCoop.getResourceLocation();
    }
    return new ModelResourceLocation(resourceLocation, "inventory");
}
Also used : ModelResourceLocation(net.minecraft.client.renderer.block.model.ModelResourceLocation) ResourceLocation(net.minecraft.util.ResourceLocation) IStructureConfigurationCapability(com.wuest.prefab.Capabilities.IStructureConfigurationCapability) ModelResourceLocation(net.minecraft.client.renderer.block.model.ModelResourceLocation)

Aggregations

IStructureConfigurationCapability (com.wuest.prefab.Capabilities.IStructureConfigurationCapability)4 ItemStack (net.minecraft.item.ItemStack)2 StructureConfigurationStorage (com.wuest.prefab.Capabilities.Storage.StructureConfigurationStorage)1 StructureConfigurationCapability (com.wuest.prefab.Capabilities.StructureConfigurationCapability)1 BasicStructureConfiguration (com.wuest.prefab.Config.Structures.BasicStructureConfiguration)1 EnumBasicStructureName (com.wuest.prefab.Config.Structures.BasicStructureConfiguration.EnumBasicStructureName)1 ModelResourceLocation (net.minecraft.client.renderer.block.model.ModelResourceLocation)1 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)1 ResourceLocation (net.minecraft.util.ResourceLocation)1 GuiButtonExt (net.minecraftforge.fml.client.config.GuiButtonExt)1 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)1