diff --git a/build.gradle b/build.gradle index daa63f8..f89a6ba 100644 --- a/build.gradle +++ b/build.gradle @@ -17,7 +17,7 @@ buildscript { apply plugin: 'forge' -version = "1.7.10-1.7.5" +version = "1.7.10-1.8.0" group= "com.jaquadro.minecraft.storagedrawers" // http://maven.apache.org/guides/mini/guide-naming-conventions.html archivesBaseName = "StorageDrawers" diff --git a/packs/BiomesOPlenty/build.gradle b/packs/BiomesOPlenty/build.gradle index 2e86ac8..ed061a1 100644 --- a/packs/BiomesOPlenty/build.gradle +++ b/packs/BiomesOPlenty/build.gradle @@ -17,7 +17,7 @@ buildscript { apply plugin: 'forge' -version = "1.7.10-1.1.0" +version = "1.7.10-1.1.1" group= "com.jaquadro.minecraft.storagedrawers" // http://maven.apache.org/guides/mini/guide-naming-conventions.html archivesBaseName = "StorageDrawers-BiomesOPlenty" @@ -26,7 +26,7 @@ minecraft { assetDir = "../../runtime/assets" replace '@VERSION@', project.version - replace 'required-after:StorageDrawers', "required-after:StorageDrawers@[1.7.5,)" + replace 'required-after:StorageDrawers', "required-after:StorageDrawers@[1.7.6,)" } sourceSets.main { diff --git a/packs/BiomesOPlenty/src/com/jaquadro/minecraft/storagedrawers/packs/bop/StorageDrawersPack.java b/packs/BiomesOPlenty/src/com/jaquadro/minecraft/storagedrawers/packs/bop/StorageDrawersPack.java index 81f04aa..c41cab9 100644 --- a/packs/BiomesOPlenty/src/com/jaquadro/minecraft/storagedrawers/packs/bop/StorageDrawersPack.java +++ b/packs/BiomesOPlenty/src/com/jaquadro/minecraft/storagedrawers/packs/bop/StorageDrawersPack.java @@ -41,7 +41,9 @@ public class StorageDrawersPack @Mod.EventHandler public void postInit (FMLPostInitializationEvent event) { IStorageDrawersApi api = StorageDrawersApi.instance(); - if (api != null) + if (api != null) { api.registerStandardPackRecipes(resolver); + api.packFactory().registerResolver(resolver); + } } } diff --git a/packs/Erebus/build.gradle b/packs/Erebus/build.gradle index ad02755..e94ca51 100644 --- a/packs/Erebus/build.gradle +++ b/packs/Erebus/build.gradle @@ -17,7 +17,7 @@ buildscript { apply plugin: 'forge' -version = "1.7.10-1.1.0" +version = "1.7.10-1.1.1" group= "com.jaquadro.minecraft.storagedrawers" // http://maven.apache.org/guides/mini/guide-naming-conventions.html archivesBaseName = "StorageDrawers-Erebus" @@ -26,7 +26,7 @@ minecraft { assetDir = "../../runtime/assets" replace '@VERSION@', project.version - replace 'required-after:StorageDrawers', "required-after:StorageDrawers@[1.7.5,)" + replace 'required-after:StorageDrawers', "required-after:StorageDrawers@[1.7.6,)" } sourceSets.main { diff --git a/packs/Erebus/src/com/jaquadro/minecraft/storagedrawers/packs/erebus/StorageDrawersPack.java b/packs/Erebus/src/com/jaquadro/minecraft/storagedrawers/packs/erebus/StorageDrawersPack.java index 53a5c38..95a751f 100644 --- a/packs/Erebus/src/com/jaquadro/minecraft/storagedrawers/packs/erebus/StorageDrawersPack.java +++ b/packs/Erebus/src/com/jaquadro/minecraft/storagedrawers/packs/erebus/StorageDrawersPack.java @@ -41,7 +41,9 @@ public class StorageDrawersPack @Mod.EventHandler public void postInit (FMLPostInitializationEvent event) { IStorageDrawersApi api = StorageDrawersApi.instance(); - if (api != null) + if (api != null) { api.registerStandardPackRecipes(resolver); + api.packFactory().registerResolver(resolver); + } } } diff --git a/packs/Forestry/build.gradle b/packs/Forestry/build.gradle index 1abcc20..68742a2 100644 --- a/packs/Forestry/build.gradle +++ b/packs/Forestry/build.gradle @@ -17,7 +17,7 @@ buildscript { apply plugin: 'forge' -version = "1.7.10-1.1.0" +version = "1.7.10-1.1.2" group= "com.jaquadro.minecraft.storagedrawers" // http://maven.apache.org/guides/mini/guide-naming-conventions.html archivesBaseName = "StorageDrawers-Forestry" @@ -26,7 +26,7 @@ minecraft { assetDir = "../../runtime/assets" replace '@VERSION@', project.version - replace 'required-after:StorageDrawers', "required-after:StorageDrawers@[1.7.5,)" + replace 'required-after:StorageDrawers', "required-after:StorageDrawers@[1.7.6,)" } sourceSets.main { diff --git a/packs/Forestry/src/com/jaquadro/minecraft/storagedrawers/packs/forestry/StorageDrawersPack.java b/packs/Forestry/src/com/jaquadro/minecraft/storagedrawers/packs/forestry/StorageDrawersPack.java index 81fbc87..24470ab 100644 --- a/packs/Forestry/src/com/jaquadro/minecraft/storagedrawers/packs/forestry/StorageDrawersPack.java +++ b/packs/Forestry/src/com/jaquadro/minecraft/storagedrawers/packs/forestry/StorageDrawersPack.java @@ -49,8 +49,10 @@ public class StorageDrawersPack public void postInit (FMLPostInitializationEvent event) { IStorageDrawersApi api = StorageDrawersApi.instance(); if (api != null) { - for (IExtendedDataResolver resolver : resolvers) + for (IExtendedDataResolver resolver : resolvers) { api.registerStandardPackRecipes(resolver); + api.packFactory().registerResolver(resolver); + } } } } diff --git a/packs/Forestry/src/com/jaquadro/minecraft/storagedrawers/packs/forestry/core/DataResolver.java b/packs/Forestry/src/com/jaquadro/minecraft/storagedrawers/packs/forestry/core/DataResolver.java index 1a0592f..a2af2c3 100644 --- a/packs/Forestry/src/com/jaquadro/minecraft/storagedrawers/packs/forestry/core/DataResolver.java +++ b/packs/Forestry/src/com/jaquadro/minecraft/storagedrawers/packs/forestry/core/DataResolver.java @@ -30,33 +30,37 @@ public class DataResolver extends ExtendedDataResolver public Block getBlock (BlockConfiguration blockConfig) { switch (blockConfig.getBlockType()) { case Drawers: - if (blockConfig.getDrawerCount() == 1) + if (blockConfig.getDrawerCount() == 1 && ModBlocks.fullDrawers1 != null) return ModBlocks.fullDrawers1[bank]; - if (blockConfig.getDrawerCount() == 2 && !blockConfig.isHalfDepth()) + if (blockConfig.getDrawerCount() == 2 && !blockConfig.isHalfDepth() && ModBlocks.fullDrawers2 != null) return ModBlocks.fullDrawers2[bank]; - if (blockConfig.getDrawerCount() == 4 && !blockConfig.isHalfDepth()) + if (blockConfig.getDrawerCount() == 4 && !blockConfig.isHalfDepth() && ModBlocks.fullDrawers4 != null) return ModBlocks.fullDrawers4[bank]; - if (blockConfig.getDrawerCount() == 2 && blockConfig.isHalfDepth()) + if (blockConfig.getDrawerCount() == 2 && blockConfig.isHalfDepth() && ModBlocks.halfDrawers2 != null) return ModBlocks.halfDrawers2[bank]; - if (blockConfig.getDrawerCount() == 4 && blockConfig.isHalfDepth()) + if (blockConfig.getDrawerCount() == 4 && blockConfig.isHalfDepth() && ModBlocks.halfDrawers4 != null) return ModBlocks.halfDrawers4[bank]; break; case DrawersSorting: - if (blockConfig.getDrawerCount() == 1) + if (blockConfig.getDrawerCount() == 1 && RefinedRelocation.fullDrawers1 != null) return RefinedRelocation.fullDrawers1[bank]; - if (blockConfig.getDrawerCount() == 2 && !blockConfig.isHalfDepth()) + if (blockConfig.getDrawerCount() == 2 && !blockConfig.isHalfDepth() && RefinedRelocation.fullDrawers2 != null) return RefinedRelocation.fullDrawers2[bank]; - if (blockConfig.getDrawerCount() == 4 && !blockConfig.isHalfDepth()) + if (blockConfig.getDrawerCount() == 4 && !blockConfig.isHalfDepth() && RefinedRelocation.fullDrawers4 != null) return RefinedRelocation.fullDrawers4[bank]; - if (blockConfig.getDrawerCount() == 2 && blockConfig.isHalfDepth()) + if (blockConfig.getDrawerCount() == 2 && blockConfig.isHalfDepth() && RefinedRelocation.halfDrawers2 != null) return RefinedRelocation.halfDrawers2[bank]; - if (blockConfig.getDrawerCount() == 4 && blockConfig.isHalfDepth()) + if (blockConfig.getDrawerCount() == 4 && blockConfig.isHalfDepth() && RefinedRelocation.halfDrawers4 != null) return RefinedRelocation.halfDrawers4[bank]; break; case Trim: - return ModBlocks.trim[bank]; + if (ModBlocks.trim != null) + return ModBlocks.trim[bank]; + break; case TrimSorting: - return RefinedRelocation.trim[bank]; + if (RefinedRelocation.trim != null) + return RefinedRelocation.trim[bank]; + break; } return null; } diff --git a/packs/Misc/build.gradle b/packs/Misc/build.gradle index afd81e9..cb1e762 100644 --- a/packs/Misc/build.gradle +++ b/packs/Misc/build.gradle @@ -17,7 +17,7 @@ buildscript { apply plugin: 'forge' -version = "1.7.10-1.1.0" +version = "1.7.10-1.1.2" group= "com.jaquadro.minecraft.storagedrawers" // http://maven.apache.org/guides/mini/guide-naming-conventions.html archivesBaseName = "StorageDrawers-Misc" @@ -26,7 +26,7 @@ minecraft { assetDir = "../../runtime/assets" replace '@VERSION@', project.version - replace 'required-after:StorageDrawers', "required-after:StorageDrawers@[1.7.5,)" + replace 'required-after:StorageDrawers', "required-after:StorageDrawers@[1.7.6,)" } sourceSets.main { diff --git a/packs/Misc/src/com/jaquadro/minecraft/storagedrawers/packs/misc/StorageDrawersPack.java b/packs/Misc/src/com/jaquadro/minecraft/storagedrawers/packs/misc/StorageDrawersPack.java index 7248a37..cd42acc 100644 --- a/packs/Misc/src/com/jaquadro/minecraft/storagedrawers/packs/misc/StorageDrawersPack.java +++ b/packs/Misc/src/com/jaquadro/minecraft/storagedrawers/packs/misc/StorageDrawersPack.java @@ -47,8 +47,10 @@ public class StorageDrawersPack public void postInit (FMLPostInitializationEvent event) { IStorageDrawersApi api = StorageDrawersApi.instance(); if (api != null) { - for (IExtendedDataResolver resolver : resolvers) + for (IExtendedDataResolver resolver : resolvers) { api.registerStandardPackRecipes(resolver); + api.packFactory().registerResolver(resolver); + } } } } diff --git a/packs/Misc/src/com/jaquadro/minecraft/storagedrawers/packs/misc/core/DataResolver.java b/packs/Misc/src/com/jaquadro/minecraft/storagedrawers/packs/misc/core/DataResolver.java index 4a8c2ed..5c8e23e 100644 --- a/packs/Misc/src/com/jaquadro/minecraft/storagedrawers/packs/misc/core/DataResolver.java +++ b/packs/Misc/src/com/jaquadro/minecraft/storagedrawers/packs/misc/core/DataResolver.java @@ -32,33 +32,37 @@ public class DataResolver extends ExtendedDataResolver public Block getBlock (BlockConfiguration blockConfig) { switch (blockConfig.getBlockType()) { case Drawers: - if (blockConfig.getDrawerCount() == 1) + if (blockConfig.getDrawerCount() == 1 && ModBlocks.fullDrawers1 != null) return ModBlocks.fullDrawers1[bank]; - if (blockConfig.getDrawerCount() == 2 && !blockConfig.isHalfDepth()) + if (blockConfig.getDrawerCount() == 2 && !blockConfig.isHalfDepth() && ModBlocks.fullDrawers2 != null) return ModBlocks.fullDrawers2[bank]; - if (blockConfig.getDrawerCount() == 4 && !blockConfig.isHalfDepth()) + if (blockConfig.getDrawerCount() == 4 && !blockConfig.isHalfDepth() && ModBlocks.fullDrawers4 != null) return ModBlocks.fullDrawers4[bank]; - if (blockConfig.getDrawerCount() == 2 && blockConfig.isHalfDepth()) + if (blockConfig.getDrawerCount() == 2 && blockConfig.isHalfDepth() && ModBlocks.halfDrawers2 != null) return ModBlocks.halfDrawers2[bank]; - if (blockConfig.getDrawerCount() == 4 && blockConfig.isHalfDepth()) + if (blockConfig.getDrawerCount() == 4 && blockConfig.isHalfDepth() && ModBlocks.halfDrawers4 != null) return ModBlocks.halfDrawers4[bank]; break; case DrawersSorting: - if (blockConfig.getDrawerCount() == 1) + if (blockConfig.getDrawerCount() == 1 && RefinedRelocation.fullDrawers1 != null) return RefinedRelocation.fullDrawers1[bank]; - if (blockConfig.getDrawerCount() == 2 && !blockConfig.isHalfDepth()) + if (blockConfig.getDrawerCount() == 2 && !blockConfig.isHalfDepth() && RefinedRelocation.fullDrawers2 != null) return RefinedRelocation.fullDrawers2[bank]; - if (blockConfig.getDrawerCount() == 4 && !blockConfig.isHalfDepth()) + if (blockConfig.getDrawerCount() == 4 && !blockConfig.isHalfDepth() && RefinedRelocation.fullDrawers4 != null) return RefinedRelocation.fullDrawers4[bank]; - if (blockConfig.getDrawerCount() == 2 && blockConfig.isHalfDepth()) + if (blockConfig.getDrawerCount() == 2 && blockConfig.isHalfDepth() && RefinedRelocation.halfDrawers2 != null) return RefinedRelocation.halfDrawers2[bank]; - if (blockConfig.getDrawerCount() == 4 && blockConfig.isHalfDepth()) + if (blockConfig.getDrawerCount() == 4 && blockConfig.isHalfDepth() && RefinedRelocation.halfDrawers4 != null) return RefinedRelocation.halfDrawers4[bank]; break; case Trim: - return ModBlocks.trim[bank]; + if (ModBlocks.trim != null) + return ModBlocks.trim[bank]; + break; case TrimSorting: - return RefinedRelocation.trim[bank]; + if (RefinedRelocation.trim != null) + return RefinedRelocation.trim[bank]; + break; } return null; } diff --git a/packs/Natura/build.gradle b/packs/Natura/build.gradle index 805dda8..c3076e6 100644 --- a/packs/Natura/build.gradle +++ b/packs/Natura/build.gradle @@ -17,7 +17,7 @@ buildscript { apply plugin: 'forge' -version = "1.7.10-1.1.0" +version = "1.7.10-1.1.1" group= "com.jaquadro.minecraft.storagedrawers" // http://maven.apache.org/guides/mini/guide-naming-conventions.html archivesBaseName = "StorageDrawers-Natura" @@ -26,7 +26,7 @@ minecraft { assetDir = "../../runtime/assets" replace '@VERSION@', project.version - replace 'required-after:StorageDrawers', "required-after:StorageDrawers@[1.7.5,)" + replace 'required-after:StorageDrawers', "required-after:StorageDrawers@[1.7.6,)" } sourceSets.main { diff --git a/packs/Natura/src/com/jaquadro/minecraft/storagedrawers/packs/natura/StorageDrawersPack.java b/packs/Natura/src/com/jaquadro/minecraft/storagedrawers/packs/natura/StorageDrawersPack.java index 81787fd..c256000 100644 --- a/packs/Natura/src/com/jaquadro/minecraft/storagedrawers/packs/natura/StorageDrawersPack.java +++ b/packs/Natura/src/com/jaquadro/minecraft/storagedrawers/packs/natura/StorageDrawersPack.java @@ -41,7 +41,9 @@ public class StorageDrawersPack @Mod.EventHandler public void postInit (FMLPostInitializationEvent event) { IStorageDrawersApi api = StorageDrawersApi.instance(); - if (api != null) + if (api != null) { api.registerStandardPackRecipes(resolver); + api.packFactory().registerResolver(resolver); + } } } diff --git a/resources/assets/storagedrawers/lang/de_DE.lang b/resources/assets/storagedrawers/lang/de_DE.lang new file mode 100644 index 0000000..5a57431 --- /dev/null +++ b/resources/assets/storagedrawers/lang/de_DE.lang @@ -0,0 +1,183 @@ +itemGroup.storageDrawers=Storage Drawers +itemGroup.storageDrawersSorting=Storage Drawers - Sortieren + +storageDrawers.container.drawers=Schubfächer +storageDrawers.container.compDrawers=Verdichtende Schubfächer +storageDrawers.container.upgrades=Upgrades +storageDrawers.container.controller=Schubfach-Controller +storageDrawers.container.unboundSlave=Uneingebundener Slave + +storagedrawers.msg.maxUpgrades=Dieses Schubfach kann keine Upgrades mehr annehmen. + +# Items +item.storagedrawers.upgradeTemplate.name=Upgradeschablone +item.storagedrawers.upgrade.iron.name=Speicherupgrade (II) +item.storagedrawers.upgrade.gold.name=Speicherupgrade (III) +item.storagedrawers.upgrade.obsidian.name=Speicherupgrade (IV) +item.storagedrawers.upgrade.diamond.name=Speicherupgrade (V) +item.storagedrawers.upgrade.emerald.name=Speicherupgrade (VI) +item.storagedrawers.upgradeStatus.level1.name=Statusupgrade (I) +item.storagedrawers.upgradeStatus.level1.description=Zeige volle Speicher +item.storagedrawers.upgradeStatus.level2.name=Statusupgrade (II) +item.storagedrawers.upgradeStatus.level2.description=Zeige Füllstand +item.storagedrawers.upgradeLock.name=Schubfachschlüssel +item.storagedrawers.upgradeLock.description=Schließt und öffnet Schubfach +item.storagedrawers.upgradeVoid.name=Void Upgrade +item.storagedrawers.upgradeVoid.description=Zerstört überschüssige Items +item.storagedrawers.upgradeCreative.store.name=Kreativspeicherupgrade +item.storagedrawers.upgradeCreative.store.description=Fast unendlicher Speicher +item.storagedrawers.upgradeCreative.vend.name=Kreativautomatenupgrade +item.storagedrawers.upgradeCreative.vend.description=Uneingeschränkte Itementnahme +item.storagedrawers.upgradeSorting.name=Sortierungsupgrade +item.storagedrawers.upgradeSorting.description=Für Refined Relocation +item.storagedrawers.shroudKey.name=Verbergungsschlüssel +item.storagedrawers.shroudKey.description=Zeige oder verstecke Itemlabels +item.storagedrawers.tape.name=Packband +item.storagedrawers.tape.description=Dichte Schubfächer ab für den Umzug + +# Blocks +tile.fullDrawers1.oak.name=Eichenschubfach +tile.fullDrawers1.spruce.name=Fichtenschubfach +tile.fullDrawers1.birch.name=Birkenschubfach +tile.fullDrawers1.jungle.name=Tropenschubfach +tile.fullDrawers1.acacia.name=Akazienschubfach +tile.fullDrawers1.big_oak.name=Dunkles Eichenschubfach + +tile.fullDrawers2.oak.name=Eichenschubfach 1x2 +tile.fullDrawers2.spruce.name=Fichtenschubfach 1x2 +tile.fullDrawers2.birch.name=Birkenschubfach 1x2 +tile.fullDrawers2.jungle.name=Tropenschubfach 1x2 +tile.fullDrawers2.acacia.name=Akazienschubfach 1x2 +tile.fullDrawers2.big_oak.name=Dunkles Eichenschubfach 1x2 + +tile.fullDrawers4.oak.name=Eichenschubfach 2x2 +tile.fullDrawers4.spruce.name=Fichtenschubfach 2x2 +tile.fullDrawers4.birch.name=Birkenschubfach 2x2 +tile.fullDrawers4.jungle.name=Tropenschubfach 2x2 +tile.fullDrawers4.acacia.name=Akazienschubfach 2x2 +tile.fullDrawers4.big_oak.name=Dunkles Eichenschubfach 2x2 + +tile.halfDrawers2.oak.name=Kompaktes Eichenschubfach 1x2 +tile.halfDrawers2.spruce.name=Kompaktes Fichtenschubfach 1x2 +tile.halfDrawers2.birch.name=Kompaktes Birkenschubfach 1x2 +tile.halfDrawers2.jungle.name=Kompaktes Tropenschubfach 1x2 +tile.halfDrawers2.acacia.name=Kompaktes Akazienschubfach 1x2 +tile.halfDrawers2.big_oak.name=Kompaktes Dunkles Eichenschubfach 1x2 + +tile.halfDrawers4.oak.name=Kompaktes Eichenschubfach 2x2 +tile.halfDrawers4.spruce.name=Kompaktes Fichtenschubfach 2x2 +tile.halfDrawers4.birch.name=Kompaktes Birkenschubfach 2x2 +tile.halfDrawers4.jungle.name=Kompaktes Tropenschubfach 2x2 +tile.halfDrawers4.acacia.name=Kompaktes Akazienschubfach 2x2 +tile.halfDrawers4.big_oak.name=Kompaktes Dunkles Eichenschubfach 2x2 + +tile.compDrawers.name=Verdichtendes Schubfach +tile.drawerController.name=Schubfach-Controller +tile.controllerSlave.name=Controller Slave + +tile.trim.oak.name=Eichenverkleidung +tile.trim.spruce.name=Fichtenverkleidung +tile.trim.birch.name=Birkenverkleidung +tile.trim.jungle.name=Tropenverkleidung +tile.trim.acacia.name=Akazienverkleidung +tile.trim.big_oak.name=Dunkle Eichenverkleidung + +storageDrawers.drawers.description=Hält %d Stapel pro Schubfach +storageDrawers.drawers.sealed=Inhalt abgedichtet +storageDrawers.upgrade.description=Erhöht den Speicher zu %d mal dem Grundwert +storageDrawers.controller.description=Interagiere mit einer Bank an verbundenen Schubfächern +storageDrawers.controllerSlave.description=Zusätzlich Anhangspunkte für Controller + +# Integration +storageDrawers.waila.empty= +storageDrawers.waila.level=Upgrade Level: %s +storageDrawers.waila.drawer=#%s: %s +storageDrawers.waila.locked=Gelockt +storageDrawers.waila.void=Void +storageDrawers.waila.sorting=Sortieren + +# Configuration +storageDrawers.config.title=Storage Drawers Konfiguration + +storageDrawers.config.general=Allgemeine Einstellungen +storageDrawers.config.general.tooltip=Dies und Jenes. + +storageDrawers.config.blocks=Blockeinstellungen +storageDrawers.config.blocks.tooltip=Konfiguriere individuelle Speicherblocks. + +storageDrawers.config.blocks.fullDrawers1=Schubfächer 1x1 +storageDrawers.config.blocks.fullDrawers2=Schubfächer 1x2 +storageDrawers.config.blocks.fullDrawers4=Schubfächer 2x2 +storageDrawers.config.blocks.halfDrawers2=Kompakte Schubfächer 1x2 +storageDrawers.config.blocks.halfDrawers4=Kompakte Schubfächer 2x2 +storageDrawers.config.blocks.compDrawers=Verdichtende Schubfächer +storageDrawers.config.blocks.controller=Schubfachcontroller +storageDrawers.config.blocks.trim=Verkleidung +storageDrawers.config.blocks.controllerSlave=Controller Slave + +storageDrawers.config.upgrades=Upgradeeinstellungen +storageDrawers.config.upgrades.tooltip=Konfiguriere einzelne Speicherupgrades. + +storageDrawers.config.upgrades.level2Mult=Speichermultiplikator (II) +storageDrawers.config.upgrades.level3Mult=Speichermultiplikator (III) +storageDrawers.config.upgrades.level4Mult=Speichermultiplikator (IV) +storageDrawers.config.upgrades.level5Mult=Speichermultiplikator (V) +storageDrawers.config.upgrades.level6Mult=Speichermultiplikator (VI) + +storageDrawers.config.prop.itemRenderType=Itemrendertyp +storageDrawers.config.prop.itemRenderType.tooltip=Rendere Items in 3D oder flach (2D). +storageDrawers.config.prop.enableIndicatorUpgrades=Erlaube Indikatorupgrades +storageDrawers.config.prop.enableStorageUpgrades=Erlaube Storageupgrades +storageDrawers.config.prop.enableLockUpgrades=Erlaube Schubfachverschließung +storageDrawers.config.prop.enableShroudUpgrades=Erlaube Verbergen +storageDrawers.config.prop.enableVoidUpgrades=Erlaube Voidupgrade +storageDrawers.config.prop.enableCreativeUpgrades=Erlaube Kreativupgrade +storageDrawers.config.prop.enableSortingUpgrades=Erlaube Sortierungsupgrade +storageDrawers.config.prop.enableSortingUpgrades.tooltip=Refined Relocation muss geladen seien. +storageDrawers.config.prop.renderStorageUpgrades=Zeige Speicherupgrades +storageDrawers.config.prop.creativeTabVanillaWoods=Kreativ-Tab Vanillaholz +storageDrawers.config.prop.creativeTabVanillaWoods.tooltip=Erlaube alle Vanillaholzarten in Kreativemenütab. +storageDrawers.config.prop.enabled=Erlaubt +storageDrawers.config.prop.enabled.tooltip=Erlaube Block im Spiel. +storageDrawers.config.prop.baseStorage=Basisspeicher +storageDrawers.config.prop.baseStorage.tooltip=Anzahl an Stapeln gehalten in einem Schubfach +storageDrawers.config.prop.recipeOutput=Rezeptausgabe +storageDrawers.config.prop.recipeOutput.tooltip=Anzahl an Items von Einzelcrafting +storageDrawers.config.prop.enableDrawerUI=Erlaube Schubfach UI +storageDrawers.config.prop.enableDrawerUI.tooltip=Zeigt Itemzahlen und erlaubt Upgrades +storageDrawers.config.prop.enableSidedInput=Erlaube seitliche Itemeingabe +storageDrawers.config.prop.enableSidedInput.tooltip=Andere Blöcke können Items in Schubfächer einfügen +storageDrawers.config.prop.enableSidedOutput=Erlaube seitliche Itemausgabe +storageDrawers.config.prop.enableSidedOutput.tooltip=Andere Blöcke können Items auf Schubfächern entnehmen +storageDrawers.config.prop.enableItemConversion=Erlaube Itemumwandlung +storageDrawers.config.prop.enableItemConversion.tooltip=Schubfächer konvertieren automatich OreDict-kompatible Items +storageDrawers.config.prop.enableFallbackRecipes=Erlaube Fallback-Rezepte +storageDrawers.config.prop.enableFallbackRecipes.tooltip=Jedes valide Brettholz kann zu Eichenschubfächern gefertigt werden +storageDrawers.config.prop.invertShift=Invertiere Shift +storageDrawers.config.prop.invertShift.tooltip=Invertiert Klick- und Shift-Klick-Verhalten +storageDrawers.config.prop.enableDebugLogging=Enable Debug Logging +storageDrawers.config.prop.enableDebugLogging.tooltip=Gibt zusätzliche Informationen in das Log +storageDrawers.config.prop.enableTape=Erlaube Packband +storageDrawers.config.prop.enableTape.tooltip=Zum Verschieben der Schubfächer mit Iteminhalten +storageDrawers.config.prop.wailaStackRemainder=WAILA Anzahl-Darstellung +storageDrawers.config.prop.wailaStackRemainder.tooltip=Bestimme wie Anzahlen in WAILA dargestellt werden +storageDrawers.config.prop.controllerRange=Controllerreichweite +storageDrawers.config.prop.controllerRange.tooltip=Reichweite zur Erkennung von Netzwerkblöcken + +storageDrawers.config.addons=Addons +storageDrawers.config.addons.tooltip=Konfiguriere globale Addons-Einstellungen + +storageDrawers.config.addons.showNEI=Zeige Blöcke in NEI +storageDrawers.config.addons.showCreative=Zeige Blöcke in Kreativtabs +storageDrawers.config.addons.separateTabs=Separate Kreativtabs +storageDrawers.config.addons.tooltip=Jedes Pack benutzt seinen eigenen Kreativtab. + +storageDrawers.config.integration=Integration +storageDrawers.config.integration.tooltip=Konfiguriere Integration mit anderen Mods + +storageDrawers.config.integration.enableAE2=Erlaube Applied Energistics 2 Integration +storageDrawers.config.integration.enableWaila=Erlaube WAILA Integration +storageDrawers.config.integration.enableThaumcraft=Erlaube Thaumcraft Integration +storageDrawers.config.integration.enableMineTweaker=Erlaube MineTweaker Integration +storageDrawers.config.integration.enableRefinedRelocation=Erlaube Refined Relocation Integration +storageDrawers.config.integration.enableThermalExpansion=Elaube Thermal Expansion Integration diff --git a/resources/assets/storagedrawers/lang/en_US.lang b/resources/assets/storagedrawers/lang/en_US.lang index 3b06ec7..1c089f5 100644 --- a/resources/assets/storagedrawers/lang/en_US.lang +++ b/resources/assets/storagedrawers/lang/en_US.lang @@ -32,6 +32,10 @@ item.storagedrawers.upgradeSorting.name=Sorting Upgrade item.storagedrawers.upgradeSorting.description=For Refined Relocation item.storagedrawers.shroudKey.name=Concealment Key item.storagedrawers.shroudKey.description=Show or hide item labels +item.storagedrawers.personalKey.default.name=Personal Key +item.storagedrawers.personalKey.default.description=Protect access from other players +item.storagedrawers.personalKey.cofh.name=Personal Key (CoFH) +item.storagedrawers.personalKey.cofh.description=Protect access from other players item.storagedrawers.tape.name=Packing Tape item.storagedrawers.tape.description=Seals drawers for moving @@ -92,9 +96,12 @@ storageDrawers.controllerSlave.description=Extra attach points for controllers storageDrawers.waila.empty= storageDrawers.waila.level=Upgrade Level: %s storageDrawers.waila.drawer=#%s: %s +storageDrawers.waila.limit=Stack Limit: %s (x%s) +storageDrawers.waila.nolimit=Stack Limit: ∞ storageDrawers.waila.locked=Locked storageDrawers.waila.void=Void storageDrawers.waila.sorting=Sorting +storageDrawers.waila.protected=Protected # Configuration storageDrawers.config.title=Storage Drawers Configuration @@ -130,6 +137,7 @@ storageDrawers.config.prop.enableIndicatorUpgrades=Enable Indicator Upgrades storageDrawers.config.prop.enableStorageUpgrades=Enable Storage Upgrades storageDrawers.config.prop.enableLockUpgrades=Enable Drawer Locking storageDrawers.config.prop.enableShroudUpgrades=Enable Item Concealing +storageDrawers.config.prop.enablePersonalUpgrades=Enable Access Protection storageDrawers.config.prop.enableVoidUpgrades=Enable Void Upgrade storageDrawers.config.prop.enableCreativeUpgrades=Enable Creative Upgrade storageDrawers.config.prop.enableSortingUpgrades=Enable Sorting Upgrade @@ -181,3 +189,4 @@ storageDrawers.config.integration.enableThaumcraft=Enable Thaumcraft Integration storageDrawers.config.integration.enableMineTweaker=Enable MineTweaker Integration storageDrawers.config.integration.enableRefinedRelocation=Enable Refined Relocation Integration storageDrawers.config.integration.enableThermalExpansion=Enable Thermal Expansion Integration +storageDrawers.config.integration.enableThermalFoundation=Enable Thermal Foundation Integration diff --git a/resources/assets/storagedrawers/lang/zh_TW.lang b/resources/assets/storagedrawers/lang/zh_TW.lang index 48288a4..45a95c2 100644 --- a/resources/assets/storagedrawers/lang/zh_TW.lang +++ b/resources/assets/storagedrawers/lang/zh_TW.lang @@ -35,7 +35,7 @@ item.storagedrawers.shroudKey.description=隱藏或顯示抽屜上的物品圖 item.storagedrawers.tape.name=打包帶 item.storagedrawers.tape.description=捆紮封裝抽屜以便攜帶。 -# Block +# Blocks tile.fullDrawers1.oak.name=橡木抽屜 tile.fullDrawers1.spruce.name=雲杉木抽屜 tile.fullDrawers1.birch.name=白樺木抽屜 @@ -88,15 +88,17 @@ storageDrawers.upgrade.description=將抽屜容量升級為其基礎容量的%d storageDrawers.controller.description=將放入的物品分配存入鄰接的抽屜中。 storageDrawers.controllerSlave.description=為抽屜管理器擴展存儲連接面。 -# Integration/WAILA +# Integration storageDrawers.waila.empty=<空> storageDrawers.waila.level=級別:%s storageDrawers.waila.drawer=#%s:%s +storageDrawers.waila.limit=堆疊上限: %s (x%s) +storageDrawers.waila.nolimit=堆疊上限: ∞ storageDrawers.waila.locked=鎖定 storageDrawers.waila.void=清空 storageDrawers.waila.sorting=分揀 -# Configruation +# Configuration storageDrawers.config.title=儲物抽屜-模組選項 storageDrawers.config.general=一般設定 @@ -180,3 +182,4 @@ storageDrawers.config.integration.enableWaila=允許關聯WAILA顯示 storageDrawers.config.integration.enableThaumcraft=允許關聯秘術時代 storageDrawers.config.integration.enableMineTweaker=允許關聯MineTweaker storageDrawers.config.integration.enableRefinedRelocation=允許關聯精準重定位 +storageDrawers.config.integration.enableThermalExpansion=允許關聯精煉機械 diff --git a/resources/assets/storagedrawers/textures/blocks/indicator/claim_icon.png b/resources/assets/storagedrawers/textures/blocks/indicator/claim_icon.png new file mode 100644 index 0000000..a054a47 Binary files /dev/null and b/resources/assets/storagedrawers/textures/blocks/indicator/claim_icon.png differ diff --git a/resources/assets/storagedrawers/textures/blocks/indicator/claim_lock_icon.png b/resources/assets/storagedrawers/textures/blocks/indicator/claim_lock_icon.png new file mode 100644 index 0000000..47e4c5f Binary files /dev/null and b/resources/assets/storagedrawers/textures/blocks/indicator/claim_lock_icon.png differ diff --git a/resources/assets/storagedrawers/textures/items/drawer_key_personal_cofh.png b/resources/assets/storagedrawers/textures/items/drawer_key_personal_cofh.png new file mode 100644 index 0000000..03ae7eb Binary files /dev/null and b/resources/assets/storagedrawers/textures/items/drawer_key_personal_cofh.png differ diff --git a/resources/assets/storagedrawers/textures/items/drawer_key_personal_default.png b/resources/assets/storagedrawers/textures/items/drawer_key_personal_default.png new file mode 100644 index 0000000..1b36446 Binary files /dev/null and b/resources/assets/storagedrawers/textures/items/drawer_key_personal_default.png differ diff --git a/src/com/jaquadro/minecraft/storagedrawers/StorageDrawers.java b/src/com/jaquadro/minecraft/storagedrawers/StorageDrawers.java index 64e1d8c..aad246b 100644 --- a/src/com/jaquadro/minecraft/storagedrawers/StorageDrawers.java +++ b/src/com/jaquadro/minecraft/storagedrawers/StorageDrawers.java @@ -1,11 +1,14 @@ package com.jaquadro.minecraft.storagedrawers; +import com.jaquadro.minecraft.storagedrawers.api.StorageDrawersApi; import com.jaquadro.minecraft.storagedrawers.config.*; import com.jaquadro.minecraft.storagedrawers.core.*; +import com.jaquadro.minecraft.storagedrawers.core.api.BlockRegistry; import com.jaquadro.minecraft.storagedrawers.core.handlers.GuiHandler; import com.jaquadro.minecraft.storagedrawers.integration.IntegrationRegistry; import com.jaquadro.minecraft.storagedrawers.network.BlockClickMessage; import com.jaquadro.minecraft.storagedrawers.network.CountUpdateMessage; +import com.jaquadro.minecraft.storagedrawers.security.SecurityRegistry; import cpw.mods.fml.client.event.ConfigChangedEvent; import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.Mod; @@ -43,6 +46,8 @@ public class StorageDrawers public static RecipeHandlerRegistry recipeHandlerRegistry; public static RenderRegistry renderRegistry; public static WailaRegistry wailaRegistry; + public static BlockRegistry blockRegistry; + public static SecurityRegistry securityRegistry; @Mod.Instance(MOD_ID) public static StorageDrawers instance; @@ -69,6 +74,8 @@ public class StorageDrawers recipeHandlerRegistry = new RecipeHandlerRegistry(); renderRegistry = new RenderRegistry(); wailaRegistry = new WailaRegistry(); + blockRegistry = new BlockRegistry(); + securityRegistry = new SecurityRegistry(); blocks.init(); items.init(); @@ -90,6 +97,8 @@ public class StorageDrawers recipes.init(); IntegrationRegistry.instance().postInit(); + + StorageDrawersApi.instance().packFactory().registerResolver(ModBlocks.resolver); } @SubscribeEvent diff --git a/src/com/jaquadro/minecraft/storagedrawers/api/pack/IPackBlockFactory.java b/src/com/jaquadro/minecraft/storagedrawers/api/pack/IPackBlockFactory.java index 41a9793..0f399b0 100644 --- a/src/com/jaquadro/minecraft/storagedrawers/api/pack/IPackBlockFactory.java +++ b/src/com/jaquadro/minecraft/storagedrawers/api/pack/IPackBlockFactory.java @@ -21,4 +21,9 @@ public interface IPackBlockFactory * Hides block from NEI if NEI is active. */ void hideBlock (String blockID); + + /** + * Registers block metadata from an initialized DataResolver with Storage Drawers. + */ + void registerResolver (IExtendedDataResolver resolver); } diff --git a/src/com/jaquadro/minecraft/storagedrawers/api/security/ISecurityProvider.java b/src/com/jaquadro/minecraft/storagedrawers/api/security/ISecurityProvider.java new file mode 100644 index 0000000..66752c0 --- /dev/null +++ b/src/com/jaquadro/minecraft/storagedrawers/api/security/ISecurityProvider.java @@ -0,0 +1,13 @@ +package com.jaquadro.minecraft.storagedrawers.api.security; + +import com.jaquadro.minecraft.storagedrawers.api.storage.attribute.IProtectable; +import com.mojang.authlib.GameProfile; + +public interface ISecurityProvider +{ + String getProviderID (); + + boolean hasOwnership (GameProfile profile, IProtectable target); + + boolean hasAccess (GameProfile profile, IProtectable target); +} diff --git a/src/com/jaquadro/minecraft/storagedrawers/api/storage/ISmartGroup.java b/src/com/jaquadro/minecraft/storagedrawers/api/storage/ISmartGroup.java new file mode 100644 index 0000000..c441a76 --- /dev/null +++ b/src/com/jaquadro/minecraft/storagedrawers/api/storage/ISmartGroup.java @@ -0,0 +1,18 @@ +package com.jaquadro.minecraft.storagedrawers.api.storage; + +import net.minecraft.item.ItemStack; + +public interface ISmartGroup +{ + /** + * Gets a lazy enumeration of all slots that will accept at least one item of the given stack, ordered by + * insertion preference. + */ + Iterable enumerateDrawersForInsertion (ItemStack stack, boolean strict); + + /** + * Gets a lazy enumeration of all slots that will provide at least one item of the given stack, ordered by + * extraction preference. + */ + Iterable enumerateDrawersForExtraction (ItemStack stack, boolean strict); +} diff --git a/src/com/jaquadro/minecraft/storagedrawers/api/storage/attribute/IProtectable.java b/src/com/jaquadro/minecraft/storagedrawers/api/storage/attribute/IProtectable.java new file mode 100644 index 0000000..b08649f --- /dev/null +++ b/src/com/jaquadro/minecraft/storagedrawers/api/storage/attribute/IProtectable.java @@ -0,0 +1,31 @@ +package com.jaquadro.minecraft.storagedrawers.api.storage.attribute; + +import com.jaquadro.minecraft.storagedrawers.api.security.ISecurityProvider; + +import java.util.UUID; + +public interface IProtectable +{ + /** + * Gets the owner of the drawer, or null if there is no owner. + */ + UUID getOwner (); + + /** + * Sets the owner of the drawer. Set to null to set no owner. + * @return false if the operation is not supported, true otherwise. + */ + boolean setOwner (UUID owner); + + /** + * Gets the provider managing security for the target. + * @return null to use the default provider, which enforces strict owner access. + */ + ISecurityProvider getSecurityProvider (); + + /** + * Sets the provider managing security for the target. Set to null for default provider. + * @return false if the operation is not supported, true otherwise. + */ + boolean setSecurityProvider (ISecurityProvider provder); +} diff --git a/src/com/jaquadro/minecraft/storagedrawers/block/BlockCompDrawers.java b/src/com/jaquadro/minecraft/storagedrawers/block/BlockCompDrawers.java index 01a3886..28fc504 100644 --- a/src/com/jaquadro/minecraft/storagedrawers/block/BlockCompDrawers.java +++ b/src/com/jaquadro/minecraft/storagedrawers/block/BlockCompDrawers.java @@ -1,6 +1,7 @@ package com.jaquadro.minecraft.storagedrawers.block; import com.jaquadro.minecraft.storagedrawers.StorageDrawers; +import com.jaquadro.minecraft.storagedrawers.api.pack.BlockType; import com.jaquadro.minecraft.storagedrawers.api.storage.IDrawer; import com.jaquadro.minecraft.storagedrawers.api.storage.INetworked; import com.jaquadro.minecraft.storagedrawers.block.tile.TileEntityDrawers; @@ -52,6 +53,11 @@ public class BlockCompDrawers extends BlockDrawers implements INetworked return 2; } + @Override + public BlockType retrimType () { + return null; + } + @Override public TileEntityDrawers createNewTileEntity (World world, int meta) { return new TileEntityDrawersComp(); diff --git a/src/com/jaquadro/minecraft/storagedrawers/block/BlockController.java b/src/com/jaquadro/minecraft/storagedrawers/block/BlockController.java index 305e64f..d56624d 100644 --- a/src/com/jaquadro/minecraft/storagedrawers/block/BlockController.java +++ b/src/com/jaquadro/minecraft/storagedrawers/block/BlockController.java @@ -1,11 +1,13 @@ package com.jaquadro.minecraft.storagedrawers.block; import com.jaquadro.minecraft.storagedrawers.StorageDrawers; +import com.jaquadro.minecraft.storagedrawers.api.security.ISecurityProvider; import com.jaquadro.minecraft.storagedrawers.api.storage.INetworked; import com.jaquadro.minecraft.storagedrawers.api.storage.attribute.LockAttribute; import com.jaquadro.minecraft.storagedrawers.block.tile.TileEntityController; import com.jaquadro.minecraft.storagedrawers.core.ModCreativeTabs; import com.jaquadro.minecraft.storagedrawers.core.ModItems; +import com.jaquadro.minecraft.storagedrawers.item.ItemPersonalKey; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.block.Block; @@ -121,12 +123,22 @@ public class BlockController extends BlockContainer implements INetworked if (item != null && item.getItem() != null) { if (item.getItem() == ModItems.shroudKey) { if (!world.isRemote) - te.toggleShroud(); + te.toggleShroud(player.getGameProfile()); return true; } else if (item.getItem() == ModItems.upgradeLock) { if (!world.isRemote) - te.toggleLock(EnumSet.allOf(LockAttribute.class), LockAttribute.LOCK_POPULATED); + te.toggleLock(EnumSet.allOf(LockAttribute.class), LockAttribute.LOCK_POPULATED, player.getGameProfile()); + return true; + } + else if (item.getItem() == ModItems.personalKey) { + if (!world.isRemote) { + String securityKey = ((ItemPersonalKey) item.getItem()).getSecurityProviderKey(item.getItemDamage()); + ISecurityProvider provider = StorageDrawers.securityRegistry.getProvider(securityKey); + + te.toggleProtection(player.getGameProfile(), provider); + } + return true; } } diff --git a/src/com/jaquadro/minecraft/storagedrawers/block/BlockDrawers.java b/src/com/jaquadro/minecraft/storagedrawers/block/BlockDrawers.java index 823fe30..5e1167c 100644 --- a/src/com/jaquadro/minecraft/storagedrawers/block/BlockDrawers.java +++ b/src/com/jaquadro/minecraft/storagedrawers/block/BlockDrawers.java @@ -3,6 +3,9 @@ package com.jaquadro.minecraft.storagedrawers.block; import com.google.gson.JsonObject; import com.google.gson.JsonParser; import com.jaquadro.minecraft.storagedrawers.StorageDrawers; +import com.jaquadro.minecraft.storagedrawers.api.pack.BlockConfiguration; +import com.jaquadro.minecraft.storagedrawers.api.pack.BlockType; +import com.jaquadro.minecraft.storagedrawers.api.security.ISecurityProvider; import com.jaquadro.minecraft.storagedrawers.api.storage.IDrawer; import com.jaquadro.minecraft.storagedrawers.api.storage.INetworked; import com.jaquadro.minecraft.storagedrawers.api.storage.attribute.LockAttribute; @@ -11,8 +14,11 @@ import com.jaquadro.minecraft.storagedrawers.block.tile.TileEntityDrawersStandar import com.jaquadro.minecraft.storagedrawers.core.ModCreativeTabs; import com.jaquadro.minecraft.storagedrawers.core.ModItems; import com.jaquadro.minecraft.storagedrawers.core.handlers.GuiHandler; +import com.jaquadro.minecraft.storagedrawers.item.ItemPersonalKey; +import com.jaquadro.minecraft.storagedrawers.item.ItemTrim; import com.jaquadro.minecraft.storagedrawers.network.BlockClickMessage; +import com.jaquadro.minecraft.storagedrawers.security.SecurityManager; import cpw.mods.fml.common.FMLLog; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @@ -96,6 +102,10 @@ public class BlockDrawers extends BlockContainer implements IExtendedBlockClickH @SideOnly(Side.CLIENT) private IIcon iconLock; @SideOnly(Side.CLIENT) + private IIcon iconClaim; + @SideOnly(Side.CLIENT) + private IIcon iconClaimLock; + @SideOnly(Side.CLIENT) private IIcon iconVoid; @SideOnly(Side.CLIENT) @@ -122,6 +132,54 @@ public class BlockDrawers extends BlockContainer implements IExtendedBlockClickH setLightOpacity(255); } + public boolean retrimBlock (World world, int x, int y, int z, ItemStack prototype) { + if (retrimType() == null) + return false; + + Block protoBlock = Block.getBlockFromItem(prototype.getItem()); + int protoMeta = prototype.getItemDamage(); + + BlockConfiguration config = BlockConfiguration.by(retrimType(), drawerCount, halfDepth); + + Block plankBlock = StorageDrawers.blockRegistry.getPlankBlock(BlockConfiguration.Trim, protoBlock, protoMeta); + int plankMeta = StorageDrawers.blockRegistry.getPlankMeta(BlockConfiguration.Trim, protoBlock, protoMeta); + + Block newBlock = StorageDrawers.blockRegistry.getBlock(config, plankBlock, plankMeta); + int newMeta = StorageDrawers.blockRegistry.getMeta(config, plankBlock, plankMeta); + + if (newBlock == null) + return false; + + TileEntityDrawers tile = getTileEntity(world, x, y, z); + if (newBlock == this && newMeta == world.getBlockMetadata(x, y, z) && !tile.shouldHideUpgrades()) { + tile.setShouldHideUpgrades(true); + return true; + } + + if (newBlock == this) + world.setBlockMetadataWithNotify(x, y, z, newMeta, 3); + else { + + TileEntity newDrawer = createNewTileEntity(world, newMeta); + + NBTTagCompound tag = new NBTTagCompound(); + tile.writeToNBT(tag); + newDrawer.readFromNBT(tag); + + world.removeTileEntity(x, y, z); + world.setBlockToAir(x, y, z); + + world.setBlock(x, y, z, newBlock, newMeta, 3); + world.setTileEntity(x, y, z, newDrawer); + } + + return true; + } + + public BlockType retrimType () { + return BlockType.Drawers; + } + public float getTrimWidth () { return trimWidth; } @@ -246,13 +304,27 @@ public class BlockDrawers extends BlockContainer implements IExtendedBlockClickH TileEntityDrawers tileDrawers = getTileEntitySafe(world, x, y, z); ItemStack item = player.inventory.getCurrentItem(); + if (!SecurityManager.hasAccess(player.getGameProfile(), tileDrawers)) + return false; + if (StorageDrawers.config.cache.debugTrace) { FMLLog.log(StorageDrawers.MOD_ID, Level.INFO, "BlockDrawers.onBlockActivated"); FMLLog.log(StorageDrawers.MOD_ID, Level.INFO, (item == null) ? " null item" : " " + item.toString()); } if (item != null && item.getItem() != null) { - if (item.getItem() == ModItems.upgrade || item.getItem() == ModItems.upgradeStatus || item.getItem() == ModItems.upgradeVoid || item.getItem() == ModItems.upgradeCreative) { + if (item.getItem() instanceof ItemTrim && player.isSneaking()) { + if (!retrimBlock(world, x, y, z, item)) + return false; + + if (player != null && !player.capabilities.isCreativeMode) { + if (--item.stackSize <= 0) + player.inventory.setInventorySlotContents(player.inventory.currentItem, null); + } + + return true; + } + else if (item.getItem() == ModItems.upgrade || item.getItem() == ModItems.upgradeStatus || item.getItem() == ModItems.upgradeVoid || item.getItem() == ModItems.upgradeCreative) { if (!tileDrawers.addUpgrade(item)) { player.addChatMessage(new ChatComponentTranslation("storagedrawers.msg.maxUpgrades")); return false; @@ -278,6 +350,22 @@ public class BlockDrawers extends BlockContainer implements IExtendedBlockClickH tileDrawers.setIsShrouded(!tileDrawers.isShrouded()); return true; } + else if (item.getItem() instanceof ItemPersonalKey) { + String securityKey = ((ItemPersonalKey) item.getItem()).getSecurityProviderKey(item.getItemDamage()); + ISecurityProvider provider = StorageDrawers.securityRegistry.getProvider(securityKey); + + if (tileDrawers.getOwner() == null) { + tileDrawers.setOwner(player.getPersistentID()); + tileDrawers.setSecurityProvider(provider); + } + else if (SecurityManager.hasOwnership(player.getGameProfile(), tileDrawers)) { + tileDrawers.setOwner(null); + tileDrawers.setSecurityProvider(null); + } + else + return false; + return true; + } else if (item.getItem() == ModItems.tape) return false; } @@ -371,6 +459,9 @@ public class BlockDrawers extends BlockContainer implements IExtendedBlockClickH if (tileDrawers.isSealed()) return; + if (!SecurityManager.hasAccess(player.getGameProfile(), tileDrawers)) + return; + int slot = getDrawerSlot(side, hitX, hitY, hitZ); IDrawer drawer = tileDrawers.getDrawer(slot); @@ -465,17 +556,19 @@ public class BlockDrawers extends BlockContainer implements IExtendedBlockClickH dropBlockAsItem(world, x, y, z, stack); } - for (int i = 0; i < tile.getDrawerCount(); i++) { - if (!tile.isDrawerEnabled(i)) - continue; + if (!tile.isVending()) { + for (int i = 0; i < tile.getDrawerCount(); i++) { + if (!tile.isDrawerEnabled(i)) + continue; - IDrawer drawer = tile.getDrawer(i); - while (drawer.getStoredItemCount() > 0) { - ItemStack stack = tile.takeItemsFromSlot(i, drawer.getStoredItemStackSize()); - if (stack == null || stack.stackSize == 0) - break; + IDrawer drawer = tile.getDrawer(i); + while (drawer.getStoredItemCount() > 0) { + ItemStack stack = tile.takeItemsFromSlot(i, drawer.getStoredItemStackSize()); + if (stack == null || stack.stackSize == 0) + break; - dropStackInBatches(world, x, y, z, stack); + dropStackInBatches(world, x, y, z, stack); + } } } @@ -727,8 +820,15 @@ public class BlockDrawers extends BlockContainer implements IExtendedBlockClickH } @SideOnly(Side.CLIENT) - public IIcon getLockIcon () { - return iconLock; + public IIcon getLockIcon (boolean locked, boolean claimed) { + if (locked && claimed) + return iconClaimLock; + else if (locked) + return iconLock; + else if (claimed) + return iconClaim; + else + return null; } @SideOnly(Side.CLIENT) @@ -790,6 +890,8 @@ public class BlockDrawers extends BlockContainer implements IExtendedBlockClickH iconIndicator4[1] = register.registerIcon(StorageDrawers.MOD_ID + ":indicator/indicator_4_on"); iconLock = register.registerIcon(StorageDrawers.MOD_ID + ":indicator/lock_icon"); + iconClaim = register.registerIcon(StorageDrawers.MOD_ID + ":indicator/claim_icon"); + iconClaimLock = register.registerIcon(StorageDrawers.MOD_ID + ":indicator/claim_lock_icon"); iconVoid = register.registerIcon(StorageDrawers.MOD_ID + ":indicator/void_icon"); loadBlockConfig(); diff --git a/src/com/jaquadro/minecraft/storagedrawers/block/DataResolver.java b/src/com/jaquadro/minecraft/storagedrawers/block/DataResolver.java new file mode 100644 index 0000000..7bd1f5e --- /dev/null +++ b/src/com/jaquadro/minecraft/storagedrawers/block/DataResolver.java @@ -0,0 +1,67 @@ +package com.jaquadro.minecraft.storagedrawers.block; + +import com.jaquadro.minecraft.storagedrawers.api.pack.BlockConfiguration; +import com.jaquadro.minecraft.storagedrawers.api.pack.BlockType; +import com.jaquadro.minecraft.storagedrawers.api.pack.ExtendedDataResolver; +import com.jaquadro.minecraft.storagedrawers.core.ModBlocks; +import com.jaquadro.minecraft.storagedrawers.core.ModCreativeTabs; +import com.jaquadro.minecraft.storagedrawers.integration.RefinedRelocation; +import net.minecraft.block.Block; +import net.minecraft.block.BlockWood; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.init.Blocks; + +public class DataResolver extends ExtendedDataResolver +{ + private static String[] textureNames = BlockWood.field_150096_a; + + public DataResolver (String modID) { + super(modID, textureNames); + } + + @Override + public CreativeTabs getCreativeTabs (BlockType type) { + return ModCreativeTabs.tabStorageDrawers; + } + + @Override + public Block getBlock (BlockConfiguration blockConfig) { + switch (blockConfig.getBlockType()) { + case Drawers: + if (blockConfig.getDrawerCount() == 1) + return ModBlocks.fullDrawers1; + if (blockConfig.getDrawerCount() == 2 && !blockConfig.isHalfDepth()) + return ModBlocks.fullDrawers2; + if (blockConfig.getDrawerCount() == 4 && !blockConfig.isHalfDepth()) + return ModBlocks.fullDrawers4; + if (blockConfig.getDrawerCount() == 2 && blockConfig.isHalfDepth()) + return ModBlocks.halfDrawers2; + if (blockConfig.getDrawerCount() == 4 && blockConfig.isHalfDepth()) + return ModBlocks.halfDrawers4; + break; + case DrawersSorting: + if (blockConfig.getDrawerCount() == 1) + return RefinedRelocation.fullDrawers1; + if (blockConfig.getDrawerCount() == 2 && !blockConfig.isHalfDepth()) + return RefinedRelocation.fullDrawers2; + if (blockConfig.getDrawerCount() == 4 && !blockConfig.isHalfDepth()) + return RefinedRelocation.fullDrawers4; + if (blockConfig.getDrawerCount() == 2 && blockConfig.isHalfDepth()) + return RefinedRelocation.halfDrawers2; + if (blockConfig.getDrawerCount() == 4 && blockConfig.isHalfDepth()) + return RefinedRelocation.halfDrawers4; + break; + case Trim: + return ModBlocks.trim; + case TrimSorting: + return RefinedRelocation.trim; + } + return null; + } + + @Override + public void init () { + for (int i = 0, p = 0, m = 0; i < 6; i++, p++, m++) + setPlankSlab(i, Blocks.planks, p, Blocks.wooden_slab, m); + } +} diff --git a/src/com/jaquadro/minecraft/storagedrawers/block/tile/TileEntityController.java b/src/com/jaquadro/minecraft/storagedrawers/block/tile/TileEntityController.java index 4d8d89b..2908ee4 100644 --- a/src/com/jaquadro/minecraft/storagedrawers/block/tile/TileEntityController.java +++ b/src/com/jaquadro/minecraft/storagedrawers/block/tile/TileEntityController.java @@ -2,15 +2,19 @@ package com.jaquadro.minecraft.storagedrawers.block.tile; import com.jaquadro.minecraft.storagedrawers.StorageDrawers; import com.jaquadro.minecraft.storagedrawers.api.inventory.IDrawerInventory; +import com.jaquadro.minecraft.storagedrawers.api.security.ISecurityProvider; import com.jaquadro.minecraft.storagedrawers.api.storage.*; -import com.jaquadro.minecraft.storagedrawers.api.storage.attribute.ILockable; -import com.jaquadro.minecraft.storagedrawers.api.storage.attribute.IShroudable; -import com.jaquadro.minecraft.storagedrawers.api.storage.attribute.IVoidable; -import com.jaquadro.minecraft.storagedrawers.api.storage.attribute.LockAttribute; +import com.jaquadro.minecraft.storagedrawers.api.storage.attribute.*; import com.jaquadro.minecraft.storagedrawers.block.BlockSlave; +import com.jaquadro.minecraft.storagedrawers.security.SecurityManager; +import com.jaquadro.minecraft.storagedrawers.util.ItemMetaListRegistry; +import com.jaquadro.minecraft.storagedrawers.util.ItemMetaRegistry; +import com.jaquadro.minecraft.storagedrawers.util.UniqueMetaIdentifier; +import com.mojang.authlib.GameProfile; import net.minecraft.block.Block; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.ISidedInventory; +import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.network.NetworkManager; @@ -22,13 +26,14 @@ import net.minecraftforge.common.util.ForgeDirection; import java.util.*; -public class TileEntityController extends TileEntity implements IDrawerGroup, IPriorityGroup, ISidedInventory +public class TileEntityController extends TileEntity implements IDrawerGroup, IPriorityGroup, ISmartGroup, ISidedInventory { private static final int PRI_VOID = 0; private static final int PRI_LOCKED = 1; private static final int PRI_NORMAL = 2; private static final int PRI_EMPTY = 3; - private static final int PRI_DISABLED = 4; + private static final int PRI_LOCKED_EMPTY = 4; + private static final int PRI_DISABLED = 5; private static final int DEPTH_LIMIT = 12; private static final int[] emptySlots = new int[0]; @@ -85,7 +90,12 @@ public class TileEntityController extends TileEntity implements IDrawerGroup, IP IDrawer drawer = group.getDrawer(drawerSlot); if (drawer.isEmpty()) { - return PRI_EMPTY; + if ((drawer instanceof ILockable && ((ILockable) drawer).isLocked(LockAttribute.LOCK_EMPTY)) || + (group instanceof ILockable && ((ILockable) group).isLocked(LockAttribute.LOCK_EMPTY))) { + return PRI_LOCKED_EMPTY; + } + else + return PRI_EMPTY; } if ((drawer instanceof IVoidable && ((IVoidable) drawer).isVoid()) || @@ -108,6 +118,9 @@ public class TileEntityController extends TileEntity implements IDrawerGroup, IP private List invSlotList = new ArrayList(); private List drawerSlotList = new ArrayList(); + private ItemMetaListRegistry invPrimaryLookup = new ItemMetaListRegistry(); + private ItemMetaListRegistry drawerPrimaryLookup = new ItemMetaListRegistry(); + private int[] inventorySlots = new int[0]; private int[] drawerSlots = new int[0]; private int[] autoSides = new int[] { 0, 1, 2, 3, 4, 5 }; @@ -142,27 +155,26 @@ public class TileEntityController extends TileEntity implements IDrawerGroup, IP boolean dumpInventory = worldObj.getTotalWorldTime() - lastClickTime < 10 && player.getPersistentID().equals(lastClickUUID); int count = 0; - for (int i = 0, n = drawerSlots.length; i < n; i++) { - int slotIndex = drawerSlots[i]; + if (!dumpInventory) { + ItemStack currentStack = player.inventory.getCurrentItem(); + if (currentStack != null) { + count = insertItems(currentStack, player.getGameProfile()); + if (currentStack.stackSize == 0) + player.inventory.setInventorySlotContents(player.inventory.currentItem, null); + } + } + else { + for (int i = 0, n = player.inventory.getSizeInventory(); i < n; i++) { + ItemStack subStack = player.inventory.getStackInSlot(i); + if (subStack != null) { + count += insertItems(subStack, player.getGameProfile()); + if (subStack.stackSize == 0) + player.inventory.setInventorySlotContents(i, null); + } + } - IDrawerGroup group = getGroupForDrawerSlot(slotIndex); - if (group == null || !(group instanceof IDrawerGroupInteractive)) - continue; - - IDrawerGroupInteractive intGroup = (IDrawerGroupInteractive)group; - - int slot = getLocalDrawerSlot(slotIndex); - if (!group.isDrawerEnabled(slot)) - continue; - - IDrawer drawer = group.getDrawer(slot); - if (drawer == null || drawer.isEmpty()) - continue; - - if (dumpInventory) - count += intGroup.interactPutCurrentInventoryIntoSlot(slot, player); - else - count += intGroup.interactPutCurrentItemIntoSlot(slot, player); + if (count > 0) + StorageDrawers.proxy.updatePlayerInventory(player); } lastClickTime = worldObj.getTotalWorldTime(); @@ -171,7 +183,87 @@ public class TileEntityController extends TileEntity implements IDrawerGroup, IP return count; } - public void toggleShroud () { + private int insertItems (ItemStack stack, GameProfile profile) { + int itemsLeft = stack.stackSize; + + for (int slot : enumerateDrawersForInsertion(stack, false)) { + IDrawerGroup group = getGroupForDrawerSlot(slot); + if (group instanceof IProtectable) { + if (!SecurityManager.hasAccess(profile, (IProtectable)group)) + continue; + } + + IDrawer drawer = getDrawer(slot); + ItemStack itemProto = drawer.getStoredItemPrototype(); + if (itemProto == null) + break; + + itemsLeft = insertItemsIntoDrawer(drawer, itemsLeft); + + if (drawer instanceof IVoidable && ((IVoidable) drawer).isVoid()) + itemsLeft = 0; + if (itemsLeft == 0) + break; + } + + int count = stack.stackSize - itemsLeft; + stack.stackSize = itemsLeft; + + return count; + } + + private int insertItemsIntoDrawer (IDrawer drawer, int itemCount) { + int capacity = drawer.getMaxCapacity(); + int storedItems = drawer.getStoredItemCount(); + + int storableItems = capacity - storedItems; + if (drawer instanceof IFractionalDrawer) { + IFractionalDrawer fracDrawer = (IFractionalDrawer)drawer; + if (!fracDrawer.isSmallestUnit() && fracDrawer.getStoredItemRemainder() > 0) + storableItems--; + } + + if (storableItems == 0) + return itemCount; + + int remainder = Math.max(itemCount - storableItems, 0); + storedItems += Math.min(itemCount, storableItems); + drawer.setStoredItemCount(storedItems); + + return remainder; + } + + public void toggleProtection (GameProfile profile, ISecurityProvider provider) { + IProtectable template = null; + UUID state = null; + + for (StorageRecord record : storage.values()) { + if (record.storage == null) + continue; + + if (record.storage instanceof IProtectable) { + IProtectable protectable = (IProtectable)record.storage; + if (!SecurityManager.hasOwnership(profile, protectable)) + continue; + + if (template == null) { + template = protectable; + + if (template.getOwner() == null) + state = profile.getId(); + else { + state = null; + provider = null; + } + } + + protectable.setOwner(state); + protectable.setSecurityProvider(provider); + } + } + } + + public void toggleShroud (GameProfile profile) { IShroudable template = null; boolean state = false; @@ -179,6 +271,11 @@ public class TileEntityController extends TileEntity implements IDrawerGroup, IP if (record.storage == null) continue; + if (record.storage instanceof IProtectable) { + if (!SecurityManager.hasAccess(profile, (IProtectable)record.storage)) + continue; + } + for (int i = 0, n = record.storage.getDrawerCount(); i < n; i++) { if (!record.storage.isDrawerEnabled(i)) continue; @@ -198,7 +295,7 @@ public class TileEntityController extends TileEntity implements IDrawerGroup, IP } } - public void toggleLock (EnumSet attributes, LockAttribute key) { + public void toggleLock (EnumSet attributes, LockAttribute key, GameProfile profile) { ILockable template = null; boolean state = false; @@ -206,6 +303,11 @@ public class TileEntityController extends TileEntity implements IDrawerGroup, IP if (record.storage == null) continue; + if (record.storage instanceof IProtectable) { + if (!SecurityManager.hasAccess(profile, (IProtectable)record.storage)) + continue; + } + if (record.storage instanceof ILockable) { ILockable lockableStorage = (ILockable)record.storage; if (template == null) { @@ -261,9 +363,12 @@ public class TileEntityController extends TileEntity implements IDrawerGroup, IP populateNodes(xCoord, yCoord, zCoord); flattenLists(); - inventorySlots = sortSlotRecords(invSlotList, true); //sortInventorySlots(); + inventorySlots = sortSlotRecords(invSlotList, true); drawerSlots = sortSlotRecords(drawerSlotList, false); + rebuildPrimaryLookup(invPrimaryLookup, invSlotList, true); + rebuildPrimaryLookup(drawerPrimaryLookup, drawerSlotList, false); + if (preCount != inventorySlots.length && (preCount == 0 || inventorySlots.length == 0)) { if (!worldObj.isRemote) markDirty(); @@ -293,6 +398,27 @@ public class TileEntityController extends TileEntity implements IDrawerGroup, IP return slotMap; } + private void rebuildPrimaryLookup (ItemMetaListRegistry lookup, List records, boolean invBased) { + lookup.clear(); + + for (SlotRecord record : records) { + IDrawerGroup group = getGroupForCoord(record.coord); + if (group == null) + continue; + + int drawerSlot = (invBased) ? group.getDrawerInventory().getDrawerSlot(record.slot) : record.slot; + if (!group.isDrawerEnabled(drawerSlot)) + continue; + + IDrawer drawer = group.getDrawer(drawerSlot); + if (drawer.isEmpty()) + continue; + + ItemStack item = drawer.getStoredItemPrototype(); + lookup.register(item.getItem(), item.getItemDamage(), record); + } + } + private boolean containsNullEntries (List list) { int nullCount = 0; for (int i = 0, n = list.size(); i < n; i++) { @@ -638,6 +764,20 @@ public class TileEntityController extends TileEntity implements IDrawerGroup, IP if (inventory == null) return false; + if (slot >= invSlotList.size()) + return false; + + SlotRecord record = invSlotList.get(slot); + List primaryRecords = invPrimaryLookup.getEntries(stack.getItem(), stack.getItemDamage()); + if (primaryRecords != null && !primaryRecords.contains(record)) { + for (SlotRecord candidate : primaryRecords) { + IDrawerGroup candidateGroup = getGroupForCoord(candidate.coord); + IDrawerInventory candidateInventory = candidateGroup.getDrawerInventory(); + if (candidateInventory.canInsertItem(candidate.slot, stack)) + return false; + } + } + return inventory.canInsertItem(getLocalInvSlot(slot), stack); } @@ -728,6 +868,127 @@ public class TileEntityController extends TileEntity implements IDrawerGroup, IP if (inventory == null) return false; + if (slot >= invSlotList.size()) + return false; + + SlotRecord record = invSlotList.get(slot); + List primaryRecords = invPrimaryLookup.getEntries(stack.getItem(), stack.getItemDamage()); + if (primaryRecords != null && !primaryRecords.contains(record)) { + for (SlotRecord candidate : primaryRecords) { + IDrawerGroup candidateGroup = getGroupForCoord(candidate.coord); + IDrawerInventory candidateInventory = candidateGroup.getDrawerInventory(); + if (candidateInventory.isItemValidForSlot(candidate.slot, stack)) + return false; + } + } + return inventory.isItemValidForSlot(getLocalInvSlot(slot), stack); } + + private class DrawerStackIterator implements Iterable + { + private ItemStack stack; + private boolean strict; + private boolean insert; + + public DrawerStackIterator (ItemStack stack, boolean strict, boolean insert) { + this.stack = stack; + this.strict = strict; + this.insert = insert; + } + + @Override + public Iterator iterator () { + return new Iterator () + { + List primaryRecords = drawerPrimaryLookup.getEntries(stack.getItem(), stack.getItemDamage()); + Iterator iter1; + int index2; + Integer nextSlot = null; + + @Override + public boolean hasNext () { + if (nextSlot == null) + advance(); + return nextSlot != null; + } + + @Override + public Integer next () { + if (nextSlot == null) + advance(); + + Integer slot = nextSlot; + nextSlot = null; + return slot; + } + + private void advance () { + if (iter1 == null && primaryRecords != null && primaryRecords.size() > 0) + iter1 = primaryRecords.iterator(); + + if (iter1 != null) { + while (iter1.hasNext()) { + SlotRecord candidate = iter1.next(); + IDrawerGroup candidateGroup = getGroupForCoord(candidate.coord); + IDrawer drawer = candidateGroup.getDrawer(candidate.slot); + + if (insert) { + if (!(drawer.canItemBeStored(stack) && (drawer.isEmpty() || drawer.getRemainingCapacity() > 0))) + continue; + } + else { + if (!(drawer.canItemBeExtracted(stack) && drawer.getStoredItemCount() > 0)) + continue; + } + + int slot = drawerSlotList.indexOf(candidate); + if (slot > -1) { + nextSlot = slot; + return; + } + } + } + + for (; index2 < drawerSlots.length; index2++) { + int slot = drawerSlots[index2]; + if (!isDrawerEnabled(slot)) + continue; + + IDrawer drawer = getDrawer(slot); + if (strict) { + ItemStack proto = drawer.getStoredItemPrototype(); + if (proto != null && !proto.isItemEqual(stack)) + continue; + } + + if (insert) { + if (!(drawer.canItemBeStored(stack) && (drawer.isEmpty() || drawer.getRemainingCapacity() > 0))) + continue; + } + else { + if (!(drawer.canItemBeExtracted(stack) && drawer.getStoredItemCount() > 0)) + continue; + } + + SlotRecord record = drawerSlotList.get(slot); + if (primaryRecords != null && primaryRecords.contains(record)) + continue; + + nextSlot = slot; + index2++; + return; + } + } + }; + } + }; + + public Iterable enumerateDrawersForInsertion (ItemStack stack, boolean strict) { + return new DrawerStackIterator(stack, strict, true); + } + + public Iterable enumerateDrawersForExtraction (ItemStack stack, boolean strict) { + return new DrawerStackIterator(stack, strict, false); + } } diff --git a/src/com/jaquadro/minecraft/storagedrawers/block/tile/TileEntityDrawers.java b/src/com/jaquadro/minecraft/storagedrawers/block/tile/TileEntityDrawers.java index f20e829..2856fd4 100644 --- a/src/com/jaquadro/minecraft/storagedrawers/block/tile/TileEntityDrawers.java +++ b/src/com/jaquadro/minecraft/storagedrawers/block/tile/TileEntityDrawers.java @@ -2,9 +2,11 @@ package com.jaquadro.minecraft.storagedrawers.block.tile; import com.jaquadro.minecraft.storagedrawers.StorageDrawers; import com.jaquadro.minecraft.storagedrawers.api.inventory.IDrawerInventory; +import com.jaquadro.minecraft.storagedrawers.api.security.ISecurityProvider; import com.jaquadro.minecraft.storagedrawers.api.storage.IDrawer; import com.jaquadro.minecraft.storagedrawers.api.storage.IDrawerGroupInteractive; import com.jaquadro.minecraft.storagedrawers.api.storage.attribute.ILockable; +import com.jaquadro.minecraft.storagedrawers.api.storage.attribute.IProtectable; import com.jaquadro.minecraft.storagedrawers.api.storage.attribute.ISealable; import com.jaquadro.minecraft.storagedrawers.api.storage.attribute.LockAttribute; import com.jaquadro.minecraft.storagedrawers.config.ConfigManager; @@ -35,7 +37,7 @@ import java.util.EnumSet; import java.util.Iterator; import java.util.UUID; -public abstract class TileEntityDrawers extends BaseTileEntity implements IDrawerGroupInteractive, ISidedInventory, IUpgradeProvider, ILockable, ISealable +public abstract class TileEntityDrawers extends BaseTileEntity implements IDrawerGroupInteractive, ISidedInventory, IUpgradeProvider, ILockable, ISealable, IProtectable { private IDrawer[] drawers; private IDrawerInventory inventory; @@ -46,6 +48,9 @@ public abstract class TileEntityDrawers extends BaseTileEntity implements IDrawe private int drawerCapacity = 1; private boolean shrouded = false; private boolean taped = false; + private boolean hideUpgrade = false; + private UUID owner; + private String securityKey; private EnumSet lockAttributes = null; @@ -242,6 +247,67 @@ public abstract class TileEntityDrawers extends BaseTileEntity implements IDrawe } } + @Override + public UUID getOwner () { + if (!StorageDrawers.config.cache.enablePersonalUpgrades) + return null; + + return owner; + } + + @Override + public boolean setOwner (UUID owner) { + if (!StorageDrawers.config.cache.enablePersonalUpgrades) + return false; + + if ((this.owner != null && !this.owner.equals(owner)) || (owner != null && !owner.equals(this.owner))) { + this.owner = owner; + + if (worldObj != null && !worldObj.isRemote) { + markDirty(); + worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); + } + } + + return true; + } + + @Override + public ISecurityProvider getSecurityProvider () { + return StorageDrawers.securityRegistry.getProvider(securityKey); + } + + @Override + public boolean setSecurityProvider (ISecurityProvider provider) { + if (!StorageDrawers.config.cache.enablePersonalUpgrades) + return false; + + String newKey = (provider == null) ? null : provider.getProviderID(); + if ((newKey != null && !newKey.equals(securityKey)) || (securityKey != null && !securityKey.equals(newKey))) { + securityKey = newKey; + + if (worldObj != null && !worldObj.isRemote) { + markDirty(); + worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); + } + } + + return true; + } + + public boolean shouldHideUpgrades () { + return hideUpgrade; + } + + public void setShouldHideUpgrades (boolean hide) { + hideUpgrade = hide; + + if (worldObj != null && !worldObj.isRemote) { + markDirty(); + worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); + } + } + public boolean isSealed () { if (!StorageDrawers.config.cache.enableTape) return false; @@ -488,6 +554,18 @@ public abstract class TileEntityDrawers extends BaseTileEntity implements IDrawe if (tag.hasKey("Shr")) shrouded = tag.getBoolean("Shr"); + owner = null; + if (tag.hasKey("Own")) + owner = UUID.fromString(tag.getString("Own")); + + securityKey = null; + if (tag.hasKey("Sec")) + securityKey = tag.getString("Sec"); + + hideUpgrade = false; + if (tag.hasKey("HideUp")) + hideUpgrade = tag.getBoolean("HideUp"); + NBTTagList slots = tag.getTagList("Slots", Constants.NBT.TAG_COMPOUND); drawers = new IDrawer[slots.tagCount()]; @@ -537,6 +615,15 @@ public abstract class TileEntityDrawers extends BaseTileEntity implements IDrawe if (shrouded) tag.setBoolean("Shr", shrouded); + if (owner != null) + tag.setString("Own", owner.toString()); + + if (securityKey != null) + tag.setString("Sec", securityKey); + + if (hideUpgrade) + tag.setBoolean("HideUp", hideUpgrade); + NBTTagList slots = new NBTTagList(); for (IDrawer drawer : drawers) { NBTTagCompound slot = new NBTTagCompound(); diff --git a/src/com/jaquadro/minecraft/storagedrawers/client/renderer/DrawersRenderer.java b/src/com/jaquadro/minecraft/storagedrawers/client/renderer/DrawersRenderer.java index 9b4f482..261a37d 100644 --- a/src/com/jaquadro/minecraft/storagedrawers/client/renderer/DrawersRenderer.java +++ b/src/com/jaquadro/minecraft/storagedrawers/client/renderer/DrawersRenderer.java @@ -130,7 +130,7 @@ public class DrawersRenderer implements ISimpleBlockRenderingHandler renderer.uvRotateTop = 0; int maxStorageLevel = tile.getMaxStorageLevel(); - if (maxStorageLevel > 1 && StorageDrawers.config.cache.renderStorageUpgrades) { + if (maxStorageLevel > 1 && StorageDrawers.config.cache.renderStorageUpgrades && !tile.shouldHideUpgrades()) { for (int i = 0; i < 6; i++) boxRenderer.setExteriorIcon(block.getOverlayIcon(world, x, y, z, i, maxStorageLevel), i); @@ -151,7 +151,7 @@ public class DrawersRenderer implements ISimpleBlockRenderingHandler if (StorageDrawers.config.cache.enableIndicatorUpgrades) renderIndicator(block, x, y, z, side, renderer, tile.getEffectiveStatusLevel()); if (StorageDrawers.config.cache.enableLockUpgrades) - renderLock(block, x, y, z, side, renderer, tile.isLocked(LockAttribute.LOCK_POPULATED)); + renderLock(block, x, y, z, side, renderer, tile.isLocked(LockAttribute.LOCK_POPULATED), tile.getOwner() != null); if (StorageDrawers.config.cache.enableVoidUpgrades) renderVoid(block, x, y, z, side, renderer, tile.isVoid()); if (StorageDrawers.config.cache.enableTape) @@ -162,12 +162,12 @@ public class DrawersRenderer implements ISimpleBlockRenderingHandler return; } - private void renderLock (BlockDrawers block, int x, int y, int z, int side, RenderBlocks renderer, boolean locked) { - if (!locked) + private void renderLock (BlockDrawers block, int x, int y, int z, int side, RenderBlocks renderer, boolean locked, boolean owned) { + if (!locked && !owned) return; double depth = block.halfDepth ? .5 : 1; - IIcon iconLock = block.getLockIcon(); + IIcon iconLock = block.getLockIcon(locked, owned); RenderHelper.instance.setRenderBounds(0.46875, 0.9375, 0, 0.53125, 1, depth + .005); RenderHelper.instance.state.setRotateTransform(RenderHelper.ZPOS, side); diff --git a/src/com/jaquadro/minecraft/storagedrawers/client/renderer/RenderUtil.java b/src/com/jaquadro/minecraft/storagedrawers/client/renderer/RenderUtil.java index c1e4863..04aa1d0 100644 --- a/src/com/jaquadro/minecraft/storagedrawers/client/renderer/RenderUtil.java +++ b/src/com/jaquadro/minecraft/storagedrawers/client/renderer/RenderUtil.java @@ -137,6 +137,9 @@ public final class RenderUtil } public static void renderFaceYNegColorMult (RenderBlocks renderer, Block block, int x, int y, int z, IIcon icon, float r, float g, float b) { + if (icon == null) + return; + Tessellator tessellator = Tessellator.instance; tessellator.setColorOpaque_F(.5f * r, .5f * g, .5f * b); if (renderer.blockAccess == null) { @@ -154,6 +157,9 @@ public final class RenderUtil } public static void renderFaceYPosColorMult (RenderBlocks renderer, Block block, int x, int y, int z, IIcon icon, float r, float g, float b) { + if (icon == null) + return; + Tessellator tessellator = Tessellator.instance; tessellator.setColorOpaque_F(1f * r, 1f * g, 1f * b); if (renderer.blockAccess == null) { @@ -171,6 +177,9 @@ public final class RenderUtil } public static void renderFaceZNegColorMult (RenderBlocks renderer, Block block, int x, int y, int z, IIcon icon, float r, float g, float b) { + if (icon == null) + return; + Tessellator tessellator = Tessellator.instance; tessellator.setColorOpaque_F(.8f * r, .8f * g, .8f * b); if (renderer.blockAccess == null) { @@ -188,6 +197,9 @@ public final class RenderUtil } public static void renderFaceZPosColorMult (RenderBlocks renderer, Block block, int x, int y, int z, IIcon icon, float r, float g, float b) { + if (icon == null) + return; + Tessellator tessellator = Tessellator.instance; tessellator.setColorOpaque_F(.8f * r, .8f * g, .8f * b); if (renderer.blockAccess == null) { @@ -205,6 +217,9 @@ public final class RenderUtil } public static void renderFaceXNegColorMult (RenderBlocks renderer, Block block, int x, int y, int z, IIcon icon, float r, float g, float b) { + if (icon == null) + return; + Tessellator tessellator = Tessellator.instance; tessellator.setColorOpaque_F(.6f * r, .6f * g, .6f * b); if (renderer.blockAccess == null) { @@ -222,6 +237,9 @@ public final class RenderUtil } public static void renderFaceXPosColorMult (RenderBlocks renderer, Block block, int x, int y, int z, IIcon icon, float r, float g, float b) { + if (icon == null) + return; + Tessellator tessellator = Tessellator.instance; tessellator.setColorOpaque_F(.6f * r, .6f * g, .6f * b); if (renderer.blockAccess == null) { diff --git a/src/com/jaquadro/minecraft/storagedrawers/config/ConfigManager.java b/src/com/jaquadro/minecraft/storagedrawers/config/ConfigManager.java index e4caaf7..c605877 100644 --- a/src/com/jaquadro/minecraft/storagedrawers/config/ConfigManager.java +++ b/src/com/jaquadro/minecraft/storagedrawers/config/ConfigManager.java @@ -60,6 +60,7 @@ public class ConfigManager public boolean enableVoidUpgrades; public boolean enableCreativeUpgrades; public boolean enableShroudUpgrades; + public boolean enablePersonalUpgrades; public boolean enableSortingUpgrades; public boolean renderStorageUpgrades; public boolean enableDrawerUI; @@ -74,6 +75,7 @@ public class ConfigManager public boolean enableMineTweakerIntegration; public boolean enableRefinedRelocationIntegration; public boolean enableThermalExpansionIntegration; + public boolean enableThermalFoundationIntegration; public boolean enableTape; public boolean enableFallbackRecipes; public boolean invertShift; @@ -229,6 +231,7 @@ public class ConfigManager cache.enableVoidUpgrades = config.get(Configuration.CATEGORY_GENERAL, "enableVoidUpgrades", true).setLanguageKey(LANG_PREFIX + "prop.enableVoidUpgrades").setRequiresMcRestart(true).getBoolean(); cache.enableCreativeUpgrades = config.get(Configuration.CATEGORY_GENERAL, "enableCreativeUpgrades", true).setLanguageKey(LANG_PREFIX + "prop.enableCreativeUpgrades").setRequiresMcRestart(true).getBoolean(); cache.enableShroudUpgrades = config.get(Configuration.CATEGORY_GENERAL, "enableShroudUpgrades", true).setLanguageKey(LANG_PREFIX + "prop.enableShroudUpgrades").setRequiresMcRestart(true).getBoolean(); + cache.enablePersonalUpgrades = config.get(Configuration.CATEGORY_GENERAL, "enablePersonalUpgrades", true).setLanguageKey(LANG_PREFIX + "prop.enablePersonalUpgrades").setRequiresMcRestart(true).getBoolean(); cache.enableSortingUpgrades = config.get(Configuration.CATEGORY_GENERAL, "enableSortingUpgrades", true).setLanguageKey(LANG_PREFIX + "prop.enableSortingUpgrades").setRequiresMcRestart(true).getBoolean(); cache.enableTape = config.get(Configuration.CATEGORY_GENERAL, "enableTape", true).setLanguageKey(LANG_PREFIX + "prop.enableTape").setRequiresMcRestart(true).getBoolean(); cache.itemRenderType = config.get(Configuration.CATEGORY_GENERAL, "itemRenderType", "fast", null, new String[]{"fancy", "fast"}).setLanguageKey(LANG_PREFIX + "prop.itemRenderType").getString(); @@ -239,7 +242,7 @@ public class ConfigManager cache.enableSidedOutput = config.get(Configuration.CATEGORY_GENERAL, "enableSidedOutput", true).setLanguageKey(LANG_PREFIX + "prop.enableSidedOutput").getBoolean(); cache.enableItemConversion = config.get(Configuration.CATEGORY_GENERAL, "enableItemConversion", true).setLanguageKey(LANG_PREFIX + "prop.enableItemConversion").getBoolean(); cache.enableFallbackRecipes = config.get(Configuration.CATEGORY_GENERAL, "enableFallbackRecipes", true).setLanguageKey(LANG_PREFIX + "prop.enableFallbackRecipes").setRequiresMcRestart(true).getBoolean(); - cache.stackRemainderWaila = !config.get(Configuration.CATEGORY_GENERAL, "wailaStackRemainder", "exact", null, new String[]{"exact", "stack + remainder"}).setLanguageKey(LANG_PREFIX + "prop.wailaStackRemainder").getString().equals("exact"); + cache.stackRemainderWaila = !config.get(Configuration.CATEGORY_GENERAL, "wailaStackRemainder", "stack + remainder", null, new String[]{"exact", "stack + remainder"}).setLanguageKey(LANG_PREFIX + "prop.wailaStackRemainder").getString().equals("exact"); cache.invertShift = config.get(Configuration.CATEGORY_GENERAL, "invertShift", false, "Inverts how shift works with drawers. If this is true, shifting will only give one item, where regular clicks will give a full stack. Leave false for default behavior.") .setLanguageKey(LANG_PREFIX + "prop.invertShift").getBoolean(); @@ -253,6 +256,7 @@ public class ConfigManager cache.enableMineTweakerIntegration = config.get(sectionIntegration.getQualifiedName(), "enableMineTweaker", true).setLanguageKey(LANG_PREFIX + "integration.enableMineTweaker").setRequiresMcRestart(true).getBoolean(); cache.enableRefinedRelocationIntegration = config.get(sectionIntegration.getQualifiedName(), "enableRefinedRelocation", true).setLanguageKey(LANG_PREFIX + "integration.enableRefinedRelocation").setRequiresMcRestart(true).getBoolean(); cache.enableThermalExpansionIntegration = config.get(sectionIntegration.getQualifiedName(), "enableThermalExpansion", true).setLanguageKey(LANG_PREFIX + "integration.enableThermalExpansion").setRequiresMcRestart(true).getBoolean(); + cache.enableThermalFoundationIntegration = config.get(sectionIntegration.getQualifiedName(), "enableThermalFoundation", true).setLanguageKey(LANG_PREFIX + "integration.enableThermalFoundation").setRequiresMcRestart(true).getBoolean(); config.get(sectionBlocksFullDrawers1x1.getQualifiedName(), "enabled", true).setLanguageKey(LANG_PREFIX + "prop.enabled").setRequiresMcRestart(true); config.get(sectionBlocksFullDrawers1x1.getQualifiedName(), "baseStorage", 32).setLanguageKey(LANG_PREFIX + "prop.baseStorage").setRequiresWorldRestart(true); diff --git a/src/com/jaquadro/minecraft/storagedrawers/core/ModBlocks.java b/src/com/jaquadro/minecraft/storagedrawers/core/ModBlocks.java index 45e7133..a0c2592 100644 --- a/src/com/jaquadro/minecraft/storagedrawers/core/ModBlocks.java +++ b/src/com/jaquadro/minecraft/storagedrawers/core/ModBlocks.java @@ -19,6 +19,8 @@ import net.minecraftforge.oredict.OreDictionary; public class ModBlocks { + public static DataResolver resolver; + public static BlockDrawers fullDrawers1; public static BlockDrawers fullDrawers2; public static BlockDrawers fullDrawers4; @@ -33,6 +35,8 @@ public class ModBlocks public static BlockDrawersCustom fullCustom2; public void init () { + resolver = new DataResolver(StorageDrawers.MOD_ID); + fullDrawers1 = new BlockDrawers("fullDrawers1", 1, false); fullDrawers2 = new BlockDrawers("fullDrawers2", 2, false); fullDrawers4 = new BlockDrawers("fullDrawers4", 4, false); @@ -103,6 +107,8 @@ public class ModBlocks for (String key : new String[] { "drawerBasic" }) OreDictionary.registerOre(key, new ItemStack(fullCustom1, 1, OreDictionary.WILDCARD_VALUE)); + + resolver.init(); } public static String getQualifiedName (String name) { diff --git a/src/com/jaquadro/minecraft/storagedrawers/core/ModItems.java b/src/com/jaquadro/minecraft/storagedrawers/core/ModItems.java index a16346f..d989b92 100644 --- a/src/com/jaquadro/minecraft/storagedrawers/core/ModItems.java +++ b/src/com/jaquadro/minecraft/storagedrawers/core/ModItems.java @@ -14,6 +14,7 @@ public class ModItems public static ItemUpgradeVoid upgradeVoid; public static ItemUpgradeCreative upgradeCreative; public static ItemShroudKey shroudKey; + public static ItemPersonalKey personalKey; public static ItemTape tape; public void init () { @@ -24,6 +25,7 @@ public class ModItems upgradeVoid = new ItemUpgradeVoid(makeName("upgradeVoid")); upgradeCreative = new ItemUpgradeCreative(makeName("upgradeCreative")); shroudKey = new ItemShroudKey(makeName("shroudKey")); + personalKey = new ItemPersonalKey(makeName("personalKey")); tape = new ItemTape(makeName("tape")); GameRegistry.registerItem(upgradeTemplate, "upgradeTemplate"); @@ -40,6 +42,8 @@ public class ModItems GameRegistry.registerItem(upgradeLock, "upgradeLock"); if (StorageDrawers.config.cache.enableShroudUpgrades) GameRegistry.registerItem(shroudKey, "shroudKey"); + if (StorageDrawers.config.cache.enablePersonalUpgrades) + GameRegistry.registerItem(personalKey, "personalKey"); if (StorageDrawers.config.cache.enableTape) GameRegistry.registerItem(tape, "tape"); } diff --git a/src/com/jaquadro/minecraft/storagedrawers/core/ModRecipes.java b/src/com/jaquadro/minecraft/storagedrawers/core/ModRecipes.java index 764c1db..0a294d7 100644 --- a/src/com/jaquadro/minecraft/storagedrawers/core/ModRecipes.java +++ b/src/com/jaquadro/minecraft/storagedrawers/core/ModRecipes.java @@ -116,6 +116,10 @@ public class ModRecipes GameRegistry.addShapelessRecipe(new ItemStack(ModItems.shroudKey), ModItems.upgradeLock, Items.ender_eye); } + if (config.cache.enablePersonalUpgrades) { + GameRegistry.addShapelessRecipe(new ItemStack(ModItems.personalKey), ModItems.upgradeLock, Items.name_tag); + } + if (config.cache.enableTape) { GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(ModItems.tape), " x ", "yyy", 'x', "slimeball", 'y', Items.paper)); diff --git a/src/com/jaquadro/minecraft/storagedrawers/core/api/BlockRegistry.java b/src/com/jaquadro/minecraft/storagedrawers/core/api/BlockRegistry.java new file mode 100644 index 0000000..bf83f55 --- /dev/null +++ b/src/com/jaquadro/minecraft/storagedrawers/core/api/BlockRegistry.java @@ -0,0 +1,81 @@ +package com.jaquadro.minecraft.storagedrawers.core.api; + +import com.jaquadro.minecraft.storagedrawers.api.pack.BlockConfiguration; +import com.jaquadro.minecraft.storagedrawers.api.pack.IExtendedDataResolver; +import com.jaquadro.minecraft.storagedrawers.util.UniqueMetaIdentifier; +import com.jaquadro.minecraft.storagedrawers.util.UniqueMetaRegistry; +import net.minecraft.block.Block; + +import java.util.HashMap; +import java.util.Map; + +public class BlockRegistry +{ + private Map> registry = new HashMap>(); + private Map> invertRegistry = new HashMap>(); + + public void register (BlockConfiguration config, IExtendedDataResolver resolver) { + for (int i = 0; i < 16; i++) { + if (resolver.isValidMetaValue(i)) + register(config, resolver.getBlock(config), i, resolver.getPlankBlock(i), resolver.getPlankMeta(i)); + } + } + + public void register (BlockConfiguration config, Block block, int meta, Block plankBlock, int plankMeta) { + UniqueMetaRegistry uniq = registry.get(config); + if (uniq == null) { + uniq = new UniqueMetaRegistry(); + registry.put(config, uniq); + } + + uniq.register(UniqueMetaIdentifier.createFor(plankBlock, plankMeta), UniqueMetaIdentifier.createFor(block, meta)); + + UniqueMetaRegistry blockReg = invertRegistry.get(config); + if (blockReg == null) { + blockReg = new UniqueMetaRegistry(); + invertRegistry.put(config, blockReg); + } + + blockReg.register(UniqueMetaIdentifier.createFor(block, meta), UniqueMetaIdentifier.createFor(plankBlock, plankMeta)); + } + + public Block getBlock (BlockConfiguration config, Block plankBlock, int plankMeta) { + return blockLookup(registry, config, plankBlock, plankMeta); + } + + public int getMeta (BlockConfiguration config, Block plankBlock, int plankMeta) { + return metaLookup(registry, config, plankBlock, plankMeta); + } + + public Block getPlankBlock (BlockConfiguration config, Block block, int meta) { + return blockLookup(invertRegistry, config, block, meta); + } + + public int getPlankMeta (BlockConfiguration config, Block block, int meta) { + return metaLookup(invertRegistry, config, block, meta); + } + + private Block blockLookup (Map> reg, BlockConfiguration config, Block block, int meta) { + UniqueMetaRegistry uniq = reg.get(config); + if (uniq == null) + return null; + + UniqueMetaIdentifier id = uniq.getEntry(UniqueMetaIdentifier.createFor(block, meta)); + if (id == null) + return null; + + return id.getBlock(); + } + + private int metaLookup (Map> reg, BlockConfiguration config, Block block, int meta) { + UniqueMetaRegistry uniq = reg.get(config); + if (uniq == null) + return 0; + + UniqueMetaIdentifier id = uniq.getEntry(UniqueMetaIdentifier.createFor(block, meta)); + if (id == null) + return 0; + + return id.meta; + } +} diff --git a/src/com/jaquadro/minecraft/storagedrawers/core/api/PackFactory.java b/src/com/jaquadro/minecraft/storagedrawers/core/api/PackFactory.java index 6f845e2..b6ba386 100644 --- a/src/com/jaquadro/minecraft/storagedrawers/core/api/PackFactory.java +++ b/src/com/jaquadro/minecraft/storagedrawers/core/api/PackFactory.java @@ -2,9 +2,11 @@ package com.jaquadro.minecraft.storagedrawers.core.api; import com.jaquadro.minecraft.storagedrawers.StorageDrawers; import com.jaquadro.minecraft.storagedrawers.api.pack.BlockConfiguration; +import com.jaquadro.minecraft.storagedrawers.api.pack.IExtendedDataResolver; import com.jaquadro.minecraft.storagedrawers.api.pack.IPackBlockFactory; import com.jaquadro.minecraft.storagedrawers.api.pack.IPackDataResolver; import com.jaquadro.minecraft.storagedrawers.block.pack.BlockSortingTrimPack; +import com.jaquadro.minecraft.storagedrawers.config.ConfigManager; import com.jaquadro.minecraft.storagedrawers.integration.IntegrationRegistry; import com.jaquadro.minecraft.storagedrawers.block.pack.BlockDrawersPack; import com.jaquadro.minecraft.storagedrawers.block.pack.BlockSortingDrawersPack; @@ -15,6 +17,7 @@ import com.jaquadro.minecraft.storagedrawers.item.pack.ItemDrawersPack; import com.jaquadro.minecraft.storagedrawers.item.pack.ItemSortingDrawersPack; import com.jaquadro.minecraft.storagedrawers.item.pack.ItemSortingTrimPack; import com.jaquadro.minecraft.storagedrawers.item.pack.ItemTrimPack; +import cpw.mods.fml.common.Loader; import cpw.mods.fml.common.registry.GameRegistry; import net.minecraft.block.Block; import net.minecraft.item.ItemStack; @@ -83,4 +86,39 @@ public class PackFactory implements IPackBlockFactory public void hideBlock (String blockID) { NEIStorageDrawersConfig.hideBlock(blockID); } + + @Override + public void registerResolver (IExtendedDataResolver resolver) { + ConfigManager config = StorageDrawers.config; + if (config.isBlockEnabled("fulldrawers1")) { + StorageDrawers.blockRegistry.register(BlockConfiguration.BasicFull1, resolver); + if (Loader.isModLoaded("RefinedRelocation") && config.cache.enableRefinedRelocationIntegration) + StorageDrawers.blockRegistry.register(BlockConfiguration.SortingFull1, resolver); + } + if (config.isBlockEnabled("fulldrawers2")) { + StorageDrawers.blockRegistry.register(BlockConfiguration.BasicFull2, resolver); + if (Loader.isModLoaded("RefinedRelocation") && config.cache.enableRefinedRelocationIntegration) + StorageDrawers.blockRegistry.register(BlockConfiguration.SortingFull2, resolver); + } + if (config.isBlockEnabled("fulldrawers4")) { + StorageDrawers.blockRegistry.register(BlockConfiguration.BasicFull4, resolver); + if (Loader.isModLoaded("RefinedRelocation") && config.cache.enableRefinedRelocationIntegration) + StorageDrawers.blockRegistry.register(BlockConfiguration.SortingFull4, resolver); + } + if (config.isBlockEnabled("halfdrawers2")) { + StorageDrawers.blockRegistry.register(BlockConfiguration.BasicHalf2, resolver); + if (Loader.isModLoaded("RefinedRelocation") && config.cache.enableRefinedRelocationIntegration) + StorageDrawers.blockRegistry.register(BlockConfiguration.SortingHalf2, resolver); + } + if (config.isBlockEnabled("halfdrawers4")) { + StorageDrawers.blockRegistry.register(BlockConfiguration.BasicHalf4, resolver); + if (Loader.isModLoaded("RefinedRelocation") && config.cache.enableRefinedRelocationIntegration) + StorageDrawers.blockRegistry.register(BlockConfiguration.SortingHalf4, resolver); + } + if (config.isBlockEnabled("trim")) { + StorageDrawers.blockRegistry.register(BlockConfiguration.Trim, resolver); + if (Loader.isModLoaded("RefinedRelocation") && config.cache.enableRefinedRelocationIntegration) + StorageDrawers.blockRegistry.register(BlockConfiguration.TrimSorting, resolver); + } + } } diff --git a/src/com/jaquadro/minecraft/storagedrawers/integration/IntegrationModule.java b/src/com/jaquadro/minecraft/storagedrawers/integration/IntegrationModule.java index 00859d0..523c09d 100644 --- a/src/com/jaquadro/minecraft/storagedrawers/integration/IntegrationModule.java +++ b/src/com/jaquadro/minecraft/storagedrawers/integration/IntegrationModule.java @@ -11,9 +11,7 @@ import java.util.List; public abstract class IntegrationModule { - public String getModID () { - return null; - } + public abstract String getModID (); public boolean versionCheck () { String pattern = versionPattern(); diff --git a/src/com/jaquadro/minecraft/storagedrawers/integration/IntegrationRegistry.java b/src/com/jaquadro/minecraft/storagedrawers/integration/IntegrationRegistry.java index be49974..000609c 100644 --- a/src/com/jaquadro/minecraft/storagedrawers/integration/IntegrationRegistry.java +++ b/src/com/jaquadro/minecraft/storagedrawers/integration/IntegrationRegistry.java @@ -30,6 +30,8 @@ public class IntegrationRegistry reg.add(new NotEnoughItems()); if (Loader.isModLoaded("ThermalExpansion") && StorageDrawers.config.cache.enableThermalExpansionIntegration) reg.add(new ThermalExpansion()); + if (Loader.isModLoaded("ThermalFoundation") && StorageDrawers.config.cache.enableThermalFoundationIntegration) + reg.add(new ThermalFoundation()); } private IntegrationRegistry () { diff --git a/src/com/jaquadro/minecraft/storagedrawers/integration/ThermalExpansion.java b/src/com/jaquadro/minecraft/storagedrawers/integration/ThermalExpansion.java index 1c58862..3bc8c78 100644 --- a/src/com/jaquadro/minecraft/storagedrawers/integration/ThermalExpansion.java +++ b/src/com/jaquadro/minecraft/storagedrawers/integration/ThermalExpansion.java @@ -29,6 +29,11 @@ public class ThermalExpansion extends IntegrationModule static boolean initialized; + @Override + public String getModID () { + return MOD_ID; + } + @Override public void init () throws Throwable { clSawmillManager = Class.forName("cofh.thermalexpansion.util.crafting.SawmillManager"); @@ -121,37 +126,41 @@ public class ThermalExpansion extends IntegrationModule continue; Block plank = resolver.getPlankBlock(i); + int plankMeta = resolver.getPlankMeta(i); + if (plank != null) { if (basicFull1 != null) - mtSawmillAddRecipe.invoke(null, 2400, new ItemStack(basicFull1, 1, i), new ItemStack(plank, 6, i), new ItemStack(Blocks.planks, 8, 0), 100); + mtSawmillAddRecipe.invoke(null, 2400, new ItemStack(basicFull1, 1, i), new ItemStack(plank, 6, plankMeta), new ItemStack(Blocks.planks, 8, 0), 100); if (basicFull2 != null) - mtSawmillAddRecipe.invoke(null, 2400, new ItemStack(basicFull2, 1, i), new ItemStack(plank, 7, i), new ItemStack(Blocks.planks, 8, 0), 100); + mtSawmillAddRecipe.invoke(null, 2400, new ItemStack(basicFull2, 1, i), new ItemStack(plank, 7, plankMeta), new ItemStack(Blocks.planks, 8, 0), 100); if (basicFull4 != null) - mtSawmillAddRecipe.invoke(null, 2400, new ItemStack(basicFull4, 1, i), new ItemStack(plank, 5, i), new ItemStack(Blocks.planks, 8, 0), 100); + mtSawmillAddRecipe.invoke(null, 2400, new ItemStack(basicFull4, 1, i), new ItemStack(plank, 5, plankMeta), new ItemStack(Blocks.planks, 8, 0), 100); if (basicTrim != null) - mtSawmillAddRecipe.invoke(null, 2400, new ItemStack(basicTrim, 1, i), new ItemStack(plank, 5, i), itemSawdust, 100); + mtSawmillAddRecipe.invoke(null, 2400, new ItemStack(basicTrim, 1, i), new ItemStack(plank, 5, plankMeta), itemSawdust, 100); if (sortingFull1 != null) - mtSawmillAddRecipe.invoke(null, 2400, new ItemStack(sortingFull1, 1, i), new ItemStack(plank, 6, i), new ItemStack(Blocks.planks, 8, 0), 100); + mtSawmillAddRecipe.invoke(null, 2400, new ItemStack(sortingFull1, 1, i), new ItemStack(plank, 6, plankMeta), new ItemStack(Blocks.planks, 8, 0), 100); if (sortingFull2 != null) - mtSawmillAddRecipe.invoke(null, 2400, new ItemStack(sortingFull2, 1, i), new ItemStack(plank, 7, i), new ItemStack(Blocks.planks, 8, 0), 100); + mtSawmillAddRecipe.invoke(null, 2400, new ItemStack(sortingFull2, 1, i), new ItemStack(plank, 7, plankMeta), new ItemStack(Blocks.planks, 8, 0), 100); if (sortingFull4 != null) - mtSawmillAddRecipe.invoke(null, 2400, new ItemStack(sortingFull4, 1, i), new ItemStack(plank, 5, i), new ItemStack(Blocks.planks, 8, 0), 100); + mtSawmillAddRecipe.invoke(null, 2400, new ItemStack(sortingFull4, 1, i), new ItemStack(plank, 5, plankMeta), new ItemStack(Blocks.planks, 8, 0), 100); if (sortingTrim != null) - mtSawmillAddRecipe.invoke(null, 2400, new ItemStack(sortingTrim, 1, i), new ItemStack(plank, 5, i), itemSawdust, 100); + mtSawmillAddRecipe.invoke(null, 2400, new ItemStack(sortingTrim, 1, i), new ItemStack(plank, 5, plankMeta), itemSawdust, 100); } Block slab = resolver.getSlabBlock(i); + int slabMeta = resolver.getSlabMeta(i); + if (slab != null) { if (basicHalf2 != null) - mtSawmillAddRecipe.invoke(null, 2400, new ItemStack(basicHalf2, 1, i), new ItemStack(slab, 7, i), new ItemStack(Blocks.planks, 8, 0), 100); + mtSawmillAddRecipe.invoke(null, 2400, new ItemStack(basicHalf2, 1, i), new ItemStack(slab, 7, slabMeta), new ItemStack(Blocks.planks, 8, 0), 100); if (basicHalf4 != null) - mtSawmillAddRecipe.invoke(null, 2400, new ItemStack(basicHalf4, 1, i), new ItemStack(slab, 5, i), new ItemStack(Blocks.planks, 8, 0), 100); + mtSawmillAddRecipe.invoke(null, 2400, new ItemStack(basicHalf4, 1, i), new ItemStack(slab, 5, slabMeta), new ItemStack(Blocks.planks, 8, 0), 100); if (sortingHalf2 != null) - mtSawmillAddRecipe.invoke(null, 2400, new ItemStack(sortingHalf2, 1, i), new ItemStack(slab, 7, i), new ItemStack(Blocks.planks, 8, 0), 100); + mtSawmillAddRecipe.invoke(null, 2400, new ItemStack(sortingHalf2, 1, i), new ItemStack(slab, 7, slabMeta), new ItemStack(Blocks.planks, 8, 0), 100); if (sortingHalf4 != null) - mtSawmillAddRecipe.invoke(null, 2400, new ItemStack(sortingHalf4, 1, i), new ItemStack(slab, 5, i), new ItemStack(Blocks.planks, 8, 0), 100); + mtSawmillAddRecipe.invoke(null, 2400, new ItemStack(sortingHalf4, 1, i), new ItemStack(slab, 5, slabMeta), new ItemStack(Blocks.planks, 8, 0), 100); } } } diff --git a/src/com/jaquadro/minecraft/storagedrawers/integration/ThermalFoundation.java b/src/com/jaquadro/minecraft/storagedrawers/integration/ThermalFoundation.java new file mode 100644 index 0000000..5ddc957 --- /dev/null +++ b/src/com/jaquadro/minecraft/storagedrawers/integration/ThermalFoundation.java @@ -0,0 +1,55 @@ +package com.jaquadro.minecraft.storagedrawers.integration; + +import com.jaquadro.minecraft.storagedrawers.StorageDrawers; +import com.jaquadro.minecraft.storagedrawers.core.ModItems; +import com.jaquadro.minecraft.storagedrawers.integration.thermalfoundation.CoFHSecurityProvider; +import com.mojang.authlib.GameProfile; +import cpw.mods.fml.common.registry.GameRegistry; +import net.minecraft.init.Items; +import net.minecraft.item.ItemStack; +import net.minecraftforge.oredict.ShapedOreRecipe; + +import java.lang.reflect.Method; + +public class ThermalFoundation extends IntegrationModule +{ + private Class classRegistrySocial; + + private Method methodPlayerHasAccess; + + @Override + public String getModID () { + return "ThermalFoundation"; + } + + @Override + public void init () throws Throwable { + try { + classRegistrySocial = Class.forName("cofh.core.RegistrySocial"); + } + catch (ClassNotFoundException e) { + classRegistrySocial = Class.forName("cofh.core.util.SocialRegistry"); + } + + methodPlayerHasAccess = classRegistrySocial.getDeclaredMethod("playerHasAccess", String.class, GameProfile.class); + } + + @Override + public void postInit () { + StorageDrawers.securityRegistry.registerProvider(new CoFHSecurityProvider(this)); + + if (StorageDrawers.config.cache.enablePersonalUpgrades) { + GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(ModItems.personalKey, 1, 1), "xxx", "xyx", "xxx", + 'x', "nuggetSignalum", 'y', ModItems.personalKey)); + } + } + + public boolean playerHasAccess (String playerName, GameProfile owner) { + try { + return (Boolean) methodPlayerHasAccess.invoke(null, playerName, owner); + } + catch (Throwable t) { + return false; + } + } +} diff --git a/src/com/jaquadro/minecraft/storagedrawers/integration/Waila.java b/src/com/jaquadro/minecraft/storagedrawers/integration/Waila.java index 54e322e..f1782ba 100644 --- a/src/com/jaquadro/minecraft/storagedrawers/integration/Waila.java +++ b/src/com/jaquadro/minecraft/storagedrawers/integration/Waila.java @@ -8,11 +8,13 @@ import com.jaquadro.minecraft.storagedrawers.api.storage.IFractionalDrawer; import com.jaquadro.minecraft.storagedrawers.api.storage.attribute.LockAttribute; import com.jaquadro.minecraft.storagedrawers.block.BlockDrawers; import com.jaquadro.minecraft.storagedrawers.block.tile.TileEntityDrawers; +import com.jaquadro.minecraft.storagedrawers.security.SecurityManager; import cpw.mods.fml.common.event.FMLInterModComms; import mcp.mobius.waila.api.IWailaConfigHandler; import mcp.mobius.waila.api.IWailaDataAccessor; import mcp.mobius.waila.api.IWailaDataProvider; import mcp.mobius.waila.api.IWailaRegistrar; +import net.minecraft.client.Minecraft; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; @@ -61,39 +63,46 @@ public class Waila extends IntegrationModule public List getWailaBody (ItemStack itemStack, List currenttip, IWailaDataAccessor accessor, IWailaConfigHandler config) { TileEntityDrawers tile = (TileEntityDrawers) accessor.getTileEntity(); - IDrawerGroup group = tile; - for (int i = 0; i < group.getDrawerCount(); i++) { - if (!group.isDrawerEnabled(i)) - continue; + if (SecurityManager.hasAccess(Minecraft.getMinecraft().thePlayer.getGameProfile(), tile)) { + for (int i = 0; i < tile.getDrawerCount(); i++) { + if (!tile.isDrawerEnabled(i)) + continue; - String name = StatCollector.translateToLocal("storageDrawers.waila.empty"); + String name = StatCollector.translateToLocal("storageDrawers.waila.empty"); - IDrawer drawer = group.getDrawer(i); - ItemStack stack = drawer.getStoredItemPrototype(); - if (stack != null && stack.getItem() != null) { - String stackName = stack.getDisplayName(); - List handlers = StorageDrawers.wailaRegistry.getTooltipHandlers(); - for (int j = 0, n = handlers.size(); j < n; j++) - stackName = handlers.get(j).transformItemName(drawer, stackName); + IDrawer drawer = tile.getDrawer(i); + ItemStack stack = drawer.getStoredItemPrototype(); + if (stack != null && stack.getItem() != null) { + String stackName = stack.getDisplayName(); + List handlers = StorageDrawers.wailaRegistry.getTooltipHandlers(); + for (int j = 0, n = handlers.size(); j < n; j++) + stackName = handlers.get(j).transformItemName(drawer, stackName); - if (drawer.getStoredItemCount() == Integer.MAX_VALUE) - name = stackName + " [\u221E]"; - else if (drawer instanceof IFractionalDrawer && ((IFractionalDrawer) drawer).getConversionRate() > 1) - name = stackName + ((i == 0) ? " [" : " [+") + ((IFractionalDrawer) drawer).getStoredItemRemainder() + "]"; - else if (StorageDrawers.config.cache.stackRemainderWaila) { - int stacks = drawer.getStoredItemCount() / drawer.getStoredItemStackSize(); - int remainder = drawer.getStoredItemCount() - (stacks * drawer.getStoredItemStackSize()); - if (stacks > 0 && remainder > 0) - name = stackName + " [" + stacks + "x" + drawer.getStoredItemStackSize() + " + " + remainder + "]"; - else if (stacks > 0) - name = stackName + " [" + stacks + "x" + drawer.getStoredItemStackSize() + "]"; - else - name = stackName + " [" + remainder + "]"; + if (drawer.getStoredItemCount() == Integer.MAX_VALUE) + name = stackName + " [\u221E]"; + else if (drawer instanceof IFractionalDrawer && ((IFractionalDrawer) drawer).getConversionRate() > 1) + name = stackName + ((i == 0) ? " [" : " [+") + ((IFractionalDrawer) drawer).getStoredItemRemainder() + "]"; + else if (StorageDrawers.config.cache.stackRemainderWaila) { + int stacks = drawer.getStoredItemCount() / drawer.getStoredItemStackSize(); + int remainder = drawer.getStoredItemCount() - (stacks * drawer.getStoredItemStackSize()); + if (stacks > 0 && remainder > 0) + name = stackName + " [" + stacks + "x" + drawer.getStoredItemStackSize() + " + " + remainder + "]"; + else if (stacks > 0) + name = stackName + " [" + stacks + "x" + drawer.getStoredItemStackSize() + "]"; + else + name = stackName + " [" + remainder + "]"; + } else + name = stackName + " [" + drawer.getStoredItemCount() + "]"; } - else - name = stackName + " [" + drawer.getStoredItemCount() + "]"; + currenttip.add(StatCollector.translateToLocalFormatted("storageDrawers.waila.drawer", i + 1, name)); + } + + if (tile.isUnlimited() || tile.isVending()) + currenttip.add(StatCollector.translateToLocalFormatted("storageDrawers.waila.nolimit")); + else { + int limit = tile.getDrawerCapacity() * tile.getEffectiveStorageMultiplier(); + currenttip.add(StatCollector.translateToLocalFormatted("storageDrawers.waila.limit", limit, tile.getEffectiveStorageMultiplier())); } - currenttip.add(StatCollector.translateToLocalFormatted("storageDrawers.waila.drawer", i + 1, name)); } String attrib = ""; @@ -103,6 +112,8 @@ public class Waila extends IntegrationModule attrib += (attrib.isEmpty() ? "" : ", ") + StatCollector.translateToLocal("storageDrawers.waila.void"); if (tile.isSorting()) attrib += (attrib.isEmpty() ? "" : ", ") + StatCollector.translateToLocal("storageDrawers.waila.sorting"); + if (tile.getOwner() != null) + attrib += (attrib.isEmpty() ? "" : ", ") + StatCollector.translateToLocal("storageDrawers.waila.protected"); if (!attrib.isEmpty()) currenttip.add(attrib); diff --git a/src/com/jaquadro/minecraft/storagedrawers/integration/ae2/DrawerMEInventory.java b/src/com/jaquadro/minecraft/storagedrawers/integration/ae2/DrawerMEInventory.java index 451b24d..1671857 100644 --- a/src/com/jaquadro/minecraft/storagedrawers/integration/ae2/DrawerMEInventory.java +++ b/src/com/jaquadro/minecraft/storagedrawers/integration/ae2/DrawerMEInventory.java @@ -7,15 +7,14 @@ import appeng.api.storage.IMEInventory; import appeng.api.storage.StorageChannel; import appeng.api.storage.data.IAEItemStack; import appeng.api.storage.data.IItemList; -import com.jaquadro.minecraft.storagedrawers.api.storage.IDrawer; -import com.jaquadro.minecraft.storagedrawers.api.storage.IDrawerGroup; -import com.jaquadro.minecraft.storagedrawers.api.storage.IFractionalDrawer; -import com.jaquadro.minecraft.storagedrawers.api.storage.IPriorityGroup; +import com.jaquadro.minecraft.storagedrawers.api.storage.*; import com.jaquadro.minecraft.storagedrawers.api.storage.attribute.ILockable; import com.jaquadro.minecraft.storagedrawers.api.storage.attribute.IVoidable; import com.jaquadro.minecraft.storagedrawers.api.storage.attribute.LockAttribute; import net.minecraft.item.ItemStack; +import java.util.Iterator; + public class DrawerMEInventory implements IMEInventory { final IDrawerGroup group; @@ -26,52 +25,71 @@ public class DrawerMEInventory implements IMEInventory @Override public IAEItemStack injectItems (IAEItemStack input, Actionable type, BaseActionSource src) { - int[] order = null; - if (group instanceof IPriorityGroup) - order = ((IPriorityGroup) group).getAccessibleDrawerSlots(); - long itemsLeft = input.getStackSize(); - for (int i = 0, n = group.getDrawerCount(); i < n; i++) { - int slot = (order != null) ? order[i] : i; - if (!group.isDrawerEnabled(slot)) - continue; - IDrawer drawer = group.getDrawer(slot); - ItemStack itemProto = drawer.getStoredItemPrototype(); - if (itemProto != null) { - if (drawer.canItemBeStored(input.getItemStack())) { - itemsLeft = injectItemsIntoDrawer(drawer, itemsLeft, type); - if (drawer instanceof IVoidable && ((IVoidable) drawer).isVoid()) - itemsLeft = 0; - if (itemsLeft == 0) - return null; - } + if (group instanceof ISmartGroup) { + for (int slot : ((ISmartGroup) group).enumerateDrawersForInsertion(input.getItemStack(), false)) { + IDrawer drawer = group.getDrawer(slot); + ItemStack itemProto = drawer.getStoredItemPrototype(); + if (itemProto == null) + drawer.setStoredItem(input.getItemStack(), 0); + + itemsLeft = injectItemsIntoDrawer(drawer, itemsLeft, type); + + if (drawer instanceof IVoidable && ((IVoidable) drawer).isVoid()) + itemsLeft = 0; + if (itemsLeft == 0) + return null; } } + else { + int[] order = null; + if (group instanceof IPriorityGroup) + order = ((IPriorityGroup) group).getAccessibleDrawerSlots(); - for (int i = 0, n = group.getDrawerCount(); i < n; i++) { - int slot = (order != null) ? order[i] : i; - if (!group.isDrawerEnabled(slot)) - continue; - if (group instanceof ILockable && ((ILockable) group).isLocked(LockAttribute.LOCK_EMPTY)) - continue; + for (int i = 0, n = group.getDrawerCount(); i < n; i++) { + int slot = (order != null) ? order[i] : i; + if (!group.isDrawerEnabled(slot)) + continue; - IDrawer drawer = group.getDrawer(slot); - ItemStack itemProto = drawer.getStoredItemPrototype(); + IDrawer drawer = group.getDrawer(slot); + ItemStack itemProto = drawer.getStoredItemPrototype(); + if (itemProto != null) { + if (drawer.canItemBeStored(input.getItemStack())) { + itemsLeft = injectItemsIntoDrawer(drawer, itemsLeft, type); + if (drawer instanceof IVoidable && ((IVoidable) drawer).isVoid()) + itemsLeft = 0; + if (itemsLeft == 0) + return null; + } + } + } - if (itemProto == null && drawer instanceof ILockable && ((ILockable) drawer).isLocked(LockAttribute.LOCK_EMPTY)) - continue; + for (int i = 0, n = group.getDrawerCount(); i < n; i++) { + int slot = (order != null) ? order[i] : i; + if (!group.isDrawerEnabled(slot)) + continue; - if (itemProto == null) { - itemProto = input.getItemStack(); - if (drawer.canItemBeStored(itemProto)) { - drawer.setStoredItem(itemProto, 0); - itemsLeft = injectItemsIntoDrawer(drawer, itemsLeft, type); - if (drawer instanceof IVoidable && ((IVoidable) drawer).isVoid()) - itemsLeft = 0; - if (itemsLeft == 0) - return null; + if (group instanceof ILockable && ((ILockable) group).isLocked(LockAttribute.LOCK_EMPTY)) + continue; + + IDrawer drawer = group.getDrawer(slot); + ItemStack itemProto = drawer.getStoredItemPrototype(); + + if (itemProto == null && drawer instanceof ILockable && ((ILockable) drawer).isLocked(LockAttribute.LOCK_EMPTY)) + continue; + + if (itemProto == null) { + itemProto = input.getItemStack(); + if (drawer.canItemBeStored(itemProto)) { + drawer.setStoredItem(itemProto, 0); + itemsLeft = injectItemsIntoDrawer(drawer, itemsLeft, type); + if (drawer instanceof IVoidable && ((IVoidable) drawer).isVoid()) + itemsLeft = 0; + if (itemsLeft == 0) + return null; + } } } } @@ -110,18 +128,13 @@ public class DrawerMEInventory implements IMEInventory @Override public IAEItemStack extractItems (IAEItemStack request, Actionable mode, BaseActionSource src) { - int[] order = null; - if (group instanceof IPriorityGroup) - order = ((IPriorityGroup) group).getAccessibleDrawerSlots(); - long itemsLeft = request.getStackSize(); - for (int i = 0, n = group.getDrawerCount(); i < n; i++) { - int slot = (order != null) ? order[i] : i; - if (!group.isDrawerEnabled(slot)) - continue; + if (group instanceof ISmartGroup) { + for (int slot : ((ISmartGroup) group).enumerateDrawersForExtraction(request.getItemStack(), true)) { + if (itemsLeft == 0) + break; - IDrawer drawer = group.getDrawer(slot); - if (drawer.canItemBeExtracted(request.getItemStack())) { + IDrawer drawer = group.getDrawer(slot); int itemCount = drawer.getStoredItemCount(); if (itemsLeft > itemCount) { if (mode == Actionable.MODULATE) @@ -136,6 +149,33 @@ public class DrawerMEInventory implements IMEInventory } } } + else { + int[] order = null; + if (group instanceof IPriorityGroup) + order = ((IPriorityGroup) group).getAccessibleDrawerSlots(); + + + for (int i = 0, n = group.getDrawerCount(); i < n; i++) { + int slot = (order != null) ? order[i] : i; + if (!group.isDrawerEnabled(slot)) + continue; + + IDrawer drawer = group.getDrawer(slot); + if (drawer.canItemBeExtracted(request.getItemStack())) { + int itemCount = drawer.getStoredItemCount(); + if (itemsLeft > itemCount) { + if (mode == Actionable.MODULATE) + drawer.setStoredItemCount(0); + itemsLeft -= itemCount; + } else { + if (mode == Actionable.MODULATE) + drawer.setStoredItemCount(itemCount - (int) itemsLeft); + itemsLeft = 0; + break; + } + } + } + } if (itemsLeft < request.getStackSize()) { ItemStack fulfillment = request.getItemStack().copy(); diff --git a/src/com/jaquadro/minecraft/storagedrawers/integration/refinedrelocation/BlockSortingDrawers.java b/src/com/jaquadro/minecraft/storagedrawers/integration/refinedrelocation/BlockSortingDrawers.java index abcd94d..cdf0c18 100644 --- a/src/com/jaquadro/minecraft/storagedrawers/integration/refinedrelocation/BlockSortingDrawers.java +++ b/src/com/jaquadro/minecraft/storagedrawers/integration/refinedrelocation/BlockSortingDrawers.java @@ -1,6 +1,7 @@ package com.jaquadro.minecraft.storagedrawers.integration.refinedrelocation; import com.jaquadro.minecraft.storagedrawers.StorageDrawers; +import com.jaquadro.minecraft.storagedrawers.api.pack.BlockType; import com.jaquadro.minecraft.storagedrawers.block.BlockDrawers; import com.jaquadro.minecraft.storagedrawers.block.tile.TileEntityDrawersStandard; import com.jaquadro.minecraft.storagedrawers.integration.RefinedRelocation; @@ -54,6 +55,11 @@ public class BlockSortingDrawers extends BlockDrawers return true; } + @Override + public BlockType retrimType () { + return BlockType.DrawersSorting; + } + @Override public TileSortingDrawersStandard createNewTileEntity (World world, int meta) { return new TileSortingDrawersStandard(); diff --git a/src/com/jaquadro/minecraft/storagedrawers/integration/thermalfoundation/CoFHSecurityProvider.java b/src/com/jaquadro/minecraft/storagedrawers/integration/thermalfoundation/CoFHSecurityProvider.java new file mode 100644 index 0000000..0ffe93e --- /dev/null +++ b/src/com/jaquadro/minecraft/storagedrawers/integration/thermalfoundation/CoFHSecurityProvider.java @@ -0,0 +1,40 @@ +package com.jaquadro.minecraft.storagedrawers.integration.thermalfoundation; + +import com.jaquadro.minecraft.storagedrawers.api.security.ISecurityProvider; +import com.jaquadro.minecraft.storagedrawers.api.storage.attribute.IProtectable; +import com.jaquadro.minecraft.storagedrawers.integration.ThermalFoundation; +import com.jaquadro.minecraft.storagedrawers.security.DefaultSecurityProvider; +import com.mojang.authlib.GameProfile; +import net.minecraft.server.MinecraftServer; + +public class CoFHSecurityProvider implements ISecurityProvider +{ + ThermalFoundation foundation; + private DefaultSecurityProvider defaultProvider = new DefaultSecurityProvider(); + + public CoFHSecurityProvider (ThermalFoundation foundation) { + this.foundation = foundation; + } + + @Override + public String getProviderID () { + return "cofh"; + } + + @Override + public boolean hasOwnership (GameProfile profile, IProtectable target) { + return defaultProvider.hasOwnership(profile, target); + } + + @Override + public boolean hasAccess (GameProfile profile, IProtectable target) { + if (target.getOwner() == null) + return true; + + GameProfile ownerProfile = MinecraftServer.getServer().func_152358_ax().func_152652_a(target.getOwner()); + if (ownerProfile == null) + return false; + + return foundation.playerHasAccess(profile.getName(), ownerProfile); + } +} diff --git a/src/com/jaquadro/minecraft/storagedrawers/item/ItemPersonalKey.java b/src/com/jaquadro/minecraft/storagedrawers/item/ItemPersonalKey.java new file mode 100644 index 0000000..d3f8d5f --- /dev/null +++ b/src/com/jaquadro/minecraft/storagedrawers/item/ItemPersonalKey.java @@ -0,0 +1,97 @@ +package com.jaquadro.minecraft.storagedrawers.item; + +import com.google.common.collect.Multimap; +import com.jaquadro.minecraft.storagedrawers.StorageDrawers; +import com.jaquadro.minecraft.storagedrawers.core.ModCreativeTabs; +import com.jaquadro.minecraft.storagedrawers.integration.IntegrationRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.SharedMonsterAttributes; +import net.minecraft.entity.ai.attributes.AttributeModifier; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.IIcon; +import net.minecraft.util.MathHelper; +import net.minecraft.util.StatCollector; + +import java.util.List; + +public class ItemPersonalKey extends Item +{ + public static final String[] iconNames = new String[] { "default", "cofh" }; + + @SideOnly(Side.CLIENT) + private IIcon[] icons; + + public ItemPersonalKey (String name) { + setUnlocalizedName(name); + setCreativeTab(ModCreativeTabs.tabStorageDrawers); + setHasSubtypes(true); + setMaxDamage(0); + } + + @Override + @SideOnly(Side.CLIENT) + public IIcon getIconFromDamage (int meta) { + return icons[MathHelper.clamp_int(meta, 0, iconNames.length - 1)]; + } + + @Override + public String getUnlocalizedName (ItemStack itemStack) { + int meta = MathHelper.clamp_int(itemStack.getItemDamage(), 0, iconNames.length - 1); + if (iconNames[meta] == null) + return super.getUnlocalizedName(); + + return super.getUnlocalizedName() + "." + iconNames[meta]; + } + + @Override + @SideOnly(Side.CLIENT) + public void addInformation (ItemStack itemStack, EntityPlayer player, List list, boolean par4) { + String name = getUnlocalizedName(itemStack); + list.add(StatCollector.translateToLocalFormatted(name + ".description")); + } + + @SideOnly(Side.CLIENT) + public boolean isFull3D() + { + return true; + } + + @Override + public Multimap getAttributeModifiers (ItemStack item) { + Multimap multimap = super.getAttributeModifiers(item); + multimap.put(SharedMonsterAttributes.attackDamage.getAttributeUnlocalizedName(), new AttributeModifier(field_111210_e, "Weapon modifier", (double)2, 0)); + return multimap; + } + + @Override + @SideOnly(Side.CLIENT) + public void getSubItems (Item item, CreativeTabs creativeTabs, List list) { + list.add(new ItemStack(item, 1, 0)); + if (StorageDrawers.config.cache.enableThermalFoundationIntegration && IntegrationRegistry.instance().isModLoaded("ThermalFoundation")) + list.add(new ItemStack(item, 1, 1)); + } + + @Override + @SideOnly(Side.CLIENT) + public void registerIcons (IIconRegister register) { + icons = new IIcon[iconNames.length]; + + for (int i = 0, n = iconNames.length; i < n; i++) { + if (iconNames[i] != null) + icons[i] = register.registerIcon(StorageDrawers.MOD_ID + ":drawer_key_personal_" + iconNames[i]); + } + } + + public String getSecurityProviderKey (int meta) { + switch (meta) { + case 0: return null; + case 1: return "cofh"; + default: return null; + } + } +} diff --git a/src/com/jaquadro/minecraft/storagedrawers/item/ItemTape.java b/src/com/jaquadro/minecraft/storagedrawers/item/ItemTape.java index 1acedd1..73bd98c 100644 --- a/src/com/jaquadro/minecraft/storagedrawers/item/ItemTape.java +++ b/src/com/jaquadro/minecraft/storagedrawers/item/ItemTape.java @@ -1,8 +1,10 @@ package com.jaquadro.minecraft.storagedrawers.item; import com.jaquadro.minecraft.storagedrawers.StorageDrawers; +import com.jaquadro.minecraft.storagedrawers.api.storage.attribute.IProtectable; import com.jaquadro.minecraft.storagedrawers.api.storage.attribute.ISealable; import com.jaquadro.minecraft.storagedrawers.core.ModCreativeTabs; +import com.jaquadro.minecraft.storagedrawers.security.SecurityManager; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.entity.player.EntityPlayer; @@ -37,6 +39,11 @@ public class ItemTape extends Item return false; TileEntity tile = world.getTileEntity(x, y, z); + if (tile instanceof IProtectable) { + if (!SecurityManager.hasOwnership(player.getGameProfile(), (IProtectable)tile)) + return false; + } + if (tile instanceof ISealable) { ISealable tileseal = (ISealable) tile; if (tileseal.isSealed()) diff --git a/src/com/jaquadro/minecraft/storagedrawers/item/ItemTrim.java b/src/com/jaquadro/minecraft/storagedrawers/item/ItemTrim.java index d307233..5e86c71 100644 --- a/src/com/jaquadro/minecraft/storagedrawers/item/ItemTrim.java +++ b/src/com/jaquadro/minecraft/storagedrawers/item/ItemTrim.java @@ -1,8 +1,11 @@ package com.jaquadro.minecraft.storagedrawers.item; +import com.jaquadro.minecraft.storagedrawers.block.BlockDrawers; import net.minecraft.block.Block; import net.minecraft.block.BlockWood; +import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemMultiTexture; +import net.minecraft.world.World; public class ItemTrim extends ItemMultiTexture { @@ -13,4 +16,13 @@ public class ItemTrim extends ItemMultiTexture protected ItemTrim (Block block, String[] names) { super(block, block, names); } + + @Override + public boolean doesSneakBypassUse (World world, int x, int y, int z, EntityPlayer player) { + Block block = world.getBlock(x, y, z); + if (block instanceof BlockDrawers && ((BlockDrawers) block).retrimType() != null) + return true; + + return false; + } } diff --git a/src/com/jaquadro/minecraft/storagedrawers/security/DefaultSecurityProvider.java b/src/com/jaquadro/minecraft/storagedrawers/security/DefaultSecurityProvider.java new file mode 100644 index 0000000..832275f --- /dev/null +++ b/src/com/jaquadro/minecraft/storagedrawers/security/DefaultSecurityProvider.java @@ -0,0 +1,26 @@ +package com.jaquadro.minecraft.storagedrawers.security; + +import com.jaquadro.minecraft.storagedrawers.api.security.ISecurityProvider; +import com.jaquadro.minecraft.storagedrawers.api.storage.attribute.IProtectable; +import com.mojang.authlib.GameProfile; + +public class DefaultSecurityProvider implements ISecurityProvider +{ + @Override + public String getProviderID () { + return null; + } + + @Override + public boolean hasOwnership (GameProfile profile, IProtectable target) { + if (target == null || profile == null) + return false; + + return target.getOwner() == null || target.getOwner().equals(profile.getId()); + } + + @Override + public boolean hasAccess (GameProfile profile, IProtectable target) { + return hasOwnership(profile, target); + } +} diff --git a/src/com/jaquadro/minecraft/storagedrawers/security/SecurityManager.java b/src/com/jaquadro/minecraft/storagedrawers/security/SecurityManager.java new file mode 100644 index 0000000..f0e921a --- /dev/null +++ b/src/com/jaquadro/minecraft/storagedrawers/security/SecurityManager.java @@ -0,0 +1,32 @@ +package com.jaquadro.minecraft.storagedrawers.security; + +import com.jaquadro.minecraft.storagedrawers.api.security.ISecurityProvider; +import com.jaquadro.minecraft.storagedrawers.api.storage.attribute.IProtectable; +import com.mojang.authlib.GameProfile; + +public class SecurityManager +{ + private static ISecurityProvider defaultProvider = new DefaultSecurityProvider(); + + public static boolean hasOwnership (GameProfile profile, IProtectable target) { + if (target == null || profile == null) + return false; + + ISecurityProvider provider = target.getSecurityProvider(); + if (provider == null) + provider = defaultProvider; + + return provider.hasOwnership(profile, target); + } + + public static boolean hasAccess (GameProfile profile, IProtectable target) { + if (target == null || profile == null) + return false; + + ISecurityProvider provider = target.getSecurityProvider(); + if (provider == null) + provider = defaultProvider; + + return provider.hasAccess(profile, target); + } +} diff --git a/src/com/jaquadro/minecraft/storagedrawers/security/SecurityRegistry.java b/src/com/jaquadro/minecraft/storagedrawers/security/SecurityRegistry.java new file mode 100644 index 0000000..8c5a3da --- /dev/null +++ b/src/com/jaquadro/minecraft/storagedrawers/security/SecurityRegistry.java @@ -0,0 +1,19 @@ +package com.jaquadro.minecraft.storagedrawers.security; + +import com.jaquadro.minecraft.storagedrawers.api.security.ISecurityProvider; + +import java.util.HashMap; +import java.util.Map; + +public class SecurityRegistry +{ + private Map registry = new HashMap(); + + public void registerProvider (ISecurityProvider provider) { + registry.put(provider.getProviderID(), provider); + } + + public ISecurityProvider getProvider (String name) { + return registry.get(name); + } +} diff --git a/src/com/jaquadro/minecraft/storagedrawers/util/ItemMetaListRegistry.java b/src/com/jaquadro/minecraft/storagedrawers/util/ItemMetaListRegistry.java new file mode 100644 index 0000000..49e3240 --- /dev/null +++ b/src/com/jaquadro/minecraft/storagedrawers/util/ItemMetaListRegistry.java @@ -0,0 +1,63 @@ +package com.jaquadro.minecraft.storagedrawers.util; + +import net.minecraft.item.Item; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Set; + +public class ItemMetaListRegistry +{ + private ItemMetaRegistry> registry; + private boolean compactTopLevel; + + public ItemMetaListRegistry () { + this(false); + } + + public ItemMetaListRegistry (boolean compactTopLevel) { + this.registry = new ItemMetaRegistry>(compactTopLevel); + this.compactTopLevel = compactTopLevel; + } + + public void register (Item item, int meta, E entry) { + List list = registry.getEntry(item, meta); + if (list == null) { + list = new ArrayList(); + registry.register(item, meta, list); + } + + list.add(entry); + } + + public List getEntries (Item item, int meta) { + return registry.getEntry(item, meta); + } + + public void remove (Item item, int meta) { + registry.remove(item, meta); + } + + public void clear (Item item, int meta) { + List list = registry.getEntry(item, meta); + if (list != null) + list.clear(); + } + + public void clear (Item item) { + for (Map.Entry> map : registry.entrySet(item)) + map.getValue().clear(); + } + + public void clear () { + for (Map.Entry>> map : registry.entrySet()) { + for (List list : map.getValue().values()) + list.clear(); + } + } + + public Set>>> entrySet () { + return registry.entrySet(); + } +} diff --git a/src/com/jaquadro/minecraft/storagedrawers/util/ItemMetaRegistry.java b/src/com/jaquadro/minecraft/storagedrawers/util/ItemMetaRegistry.java new file mode 100644 index 0000000..9a02e22 --- /dev/null +++ b/src/com/jaquadro/minecraft/storagedrawers/util/ItemMetaRegistry.java @@ -0,0 +1,83 @@ +package com.jaquadro.minecraft.storagedrawers.util; + +import net.minecraft.item.Item; + +import java.util.HashMap; +import java.util.Map; +import java.util.Set; + +public class ItemMetaRegistry +{ + private Map> registry; + private boolean compactTopLevel; + + public ItemMetaRegistry () { + registry = new HashMap>(); + } + + public ItemMetaRegistry (boolean compactTopLevel) { + this(); + this.compactTopLevel = compactTopLevel; + } + + public void register (Item item, int meta, E entry) { + Map metamap = registry.get(item); + if (metamap == null) { + metamap = new HashMap(); + registry.put(item, metamap); + } + + metamap.put(meta, entry); + } + + public E getEntry (Item item, int meta) { + Map metamap = registry.get(item); + if (metamap == null) + return null; + + return metamap.get(meta); + } + + public void remove (Item item, int meta) { + Map metamap = registry.get(item); + if (metamap == null) + return; + + metamap.remove(meta); + if (compactTopLevel && metamap.isEmpty()) + registry.remove(item); + } + + public void clear (Item item) { + Map metamap = registry.get(item); + if (metamap == null) + return; + + metamap.clear(); + if (compactTopLevel) + registry.remove(item); + } + + public void clear () { + if (compactTopLevel) + registry.clear(); + else { + for (Item item : registry.keySet()) + clear(item); + } + } + + public Set>> entrySet () { + return registry.entrySet(); + } + + public Set> entrySet (Item item) { + Map metamap = registry.get(item); + if (metamap == null) { + metamap = new HashMap(); + registry.put(item, metamap); + } + + return metamap.entrySet(); + } +} diff --git a/src/com/jaquadro/minecraft/storagedrawers/util/UniqueMetaIdentifier.java b/src/com/jaquadro/minecraft/storagedrawers/util/UniqueMetaIdentifier.java new file mode 100644 index 0000000..2cbf2e8 --- /dev/null +++ b/src/com/jaquadro/minecraft/storagedrawers/util/UniqueMetaIdentifier.java @@ -0,0 +1,133 @@ +package com.jaquadro.minecraft.storagedrawers.util; + +import com.google.common.base.Objects; +import cpw.mods.fml.common.registry.GameData; +import cpw.mods.fml.common.registry.GameRegistry; +import net.minecraft.block.Block; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraftforge.oredict.OreDictionary; + +public final class UniqueMetaIdentifier +{ + public final String modId; + public final String name; + public final int meta; + + private GameRegistry.UniqueIdentifier cachedUID; + + public UniqueMetaIdentifier (String modId, String name) { + this.modId = modId; + this.name = name; + this.meta = OreDictionary.WILDCARD_VALUE; + } + + public UniqueMetaIdentifier (String modId, String name, int meta) { + this.modId = modId; + this.name = name; + this.meta = meta; + } + + public UniqueMetaIdentifier (String qualifiedName, int meta) { + String[] parts = qualifiedName.split(":"); + this.modId = parts[0]; + this.name = parts[1]; + this.meta = meta; + } + + public UniqueMetaIdentifier (String compoundName) { + String[] parts1 = compoundName.split(";"); + String[] parts2 = parts1[0].split(":"); + this.modId = parts2[0]; + + if (parts2.length >= 2) + this.name = parts2[1]; + else + this.name = ""; + + if (parts1.length >= 2) + this.meta = Integer.parseInt(parts1[1]); + else if (parts2.length > 2) + this.meta = Integer.parseInt(parts2[parts2.length - 1]); + else + this.meta = OreDictionary.WILDCARD_VALUE; + } + + public UniqueMetaIdentifier (String compoundName, char separator) { + String[] parts1 = compoundName.split("[ ]*" + separator + "[ ]*"); + String[] parts2 = parts1[0].split(":"); + this.modId = parts2[0]; + + if (parts2.length >= 2) + this.name = parts2[1]; + else + this.name = ""; + + if (parts1.length >= 2) + this.meta = Integer.parseInt(parts1[1]); + else + this.meta = OreDictionary.WILDCARD_VALUE; + } + + public GameRegistry.UniqueIdentifier getUniqueIdentifier () { + if (cachedUID == null) + cachedUID = new GameRegistry.UniqueIdentifier(modId + ":" + name); + return cachedUID; + } + + public Block getBlock () { + return GameRegistry.findBlock(modId, name); + } + + public Item getItem () { + return GameRegistry.findItem(modId, name); + } + + @Override + public boolean equals (Object obj) { + if (obj == null) + return false; + if (obj.getClass() != getClass()) + return false; + + final UniqueMetaIdentifier other = (UniqueMetaIdentifier) obj; + + return Objects.equal(modId, other.modId) + && Objects.equal(name, other.name) + && meta == other.meta; + } + + @Override + public int hashCode () { + return Objects.hashCode(modId, name) ^ (meta * 37); + } + + @Override + public String toString () { + return String.format("%s:%s;%d", modId, name, meta); + } + + public static UniqueMetaIdentifier createFor (ItemStack itemStack) { + if (itemStack.getItem() == null) + return null; + + String name = GameData.getItemRegistry().getNameForObject(itemStack.getItem()); + return new UniqueMetaIdentifier(name, itemStack.getItemDamage()); + } + + public static UniqueMetaIdentifier createFor (Block block, int meta) { + if (block == null) + return null; + + String name = GameData.getBlockRegistry().getNameForObject(block); + return new UniqueMetaIdentifier(name, meta); + } + + public static UniqueMetaIdentifier createFor (Block block) { + if (block == null) + return null; + + String name = GameData.getBlockRegistry().getNameForObject(block); + return new UniqueMetaIdentifier(name); + } +} diff --git a/src/com/jaquadro/minecraft/storagedrawers/util/UniqueMetaRegistry.java b/src/com/jaquadro/minecraft/storagedrawers/util/UniqueMetaRegistry.java new file mode 100644 index 0000000..6bc3c24 --- /dev/null +++ b/src/com/jaquadro/minecraft/storagedrawers/util/UniqueMetaRegistry.java @@ -0,0 +1,55 @@ +package com.jaquadro.minecraft.storagedrawers.util; + +import net.minecraftforge.oredict.OreDictionary; + +import java.util.HashMap; +import java.util.Map; +import java.util.Set; + +public class UniqueMetaRegistry +{ + private Map registry; + + public UniqueMetaRegistry () { + registry = new HashMap(); + } + + public void register (UniqueMetaIdentifier id, E entry) { + registry.put(id, entry); + } + + public E getEntry (UniqueMetaIdentifier id) { + if (id == null) + return null; + + if (registry.containsKey(id)) + return registry.get(id); + + if (id.meta != OreDictionary.WILDCARD_VALUE) { + id = new UniqueMetaIdentifier(id.modId, id.name); + if (registry.containsKey(id)) + return registry.get(id); + + if (!id.name.isEmpty()) { + id = new UniqueMetaIdentifier(id.modId); + if (registry.containsKey(id)) + return registry.get(id); + } + } + + return null; + } + + public void remove (UniqueMetaIdentifier id) { + if (id != null) + registry.remove(id); + } + + public Set> entrySet () { + return registry.entrySet(); + } + + public void clear () { + registry.clear(); + } +}