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);
}
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);
}
}
}
}
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;
}
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");
}
Aggregations