diff --git a/build.gradle b/build.gradle index b455be0c..c580c5a0 100644 --- a/build.gradle +++ b/build.gradle @@ -111,6 +111,14 @@ task exportJavadoc(type: Javadoc) { source = sourceSets.main.allSource } +if (JavaVersion.current().isJava8Compatible()) { + allprojects { + tasks.withType(Javadoc) { + options.addStringOption('Xdoclint:none', '-quiet') + } + } +} + build.dependsOn sourceJar, deobfJar, apiJar, exportJavadoc publishing { diff --git a/resources/assets/enderio/config/AlloySmelterRecipes_Core.xml b/resources/assets/enderio/config/AlloySmelterRecipes_Core.xml index 08d6164f..cf30500a 100644 --- a/resources/assets/enderio/config/AlloySmelterRecipes_Core.xml +++ b/resources/assets/enderio/config/AlloySmelterRecipes_Core.xml @@ -1,74 +1,68 @@ - - - - + + @@ -78,8 +72,7 @@ To write the contents of the ore dictionary to config/oreDictionaryRegistery.txt - - + @@ -89,8 +82,7 @@ To write the contents of the ore dictionary to config/oreDictionaryRegistery.txt - - + @@ -99,8 +91,7 @@ To write the contents of the ore dictionary to config/oreDictionaryRegistery.txt - - + @@ -109,8 +100,7 @@ To write the contents of the ore dictionary to config/oreDictionaryRegistery.txt - - + @@ -119,8 +109,7 @@ To write the contents of the ore dictionary to config/oreDictionaryRegistery.txt - - + @@ -129,8 +118,7 @@ To write the contents of the ore dictionary to config/oreDictionaryRegistery.txt - - + @@ -140,8 +128,7 @@ To write the contents of the ore dictionary to config/oreDictionaryRegistery.txt - - + @@ -150,8 +137,7 @@ To write the contents of the ore dictionary to config/oreDictionaryRegistery.txt - - + @@ -159,8 +145,7 @@ To write the contents of the ore dictionary to config/oreDictionaryRegistery.txt - - + @@ -169,8 +154,7 @@ To write the contents of the ore dictionary to config/oreDictionaryRegistery.txt - - + @@ -180,8 +164,7 @@ To write the contents of the ore dictionary to config/oreDictionaryRegistery.txt - - + @@ -189,8 +172,7 @@ To write the contents of the ore dictionary to config/oreDictionaryRegistery.txt - - + @@ -199,8 +181,7 @@ To write the contents of the ore dictionary to config/oreDictionaryRegistery.txt - - + @@ -210,9 +191,7 @@ To write the contents of the ore dictionary to config/oreDictionaryRegistery.txt - - - + @@ -221,8 +200,7 @@ To write the contents of the ore dictionary to config/oreDictionaryRegistery.txt - - + @@ -231,8 +209,7 @@ To write the contents of the ore dictionary to config/oreDictionaryRegistery.txt - - + @@ -241,8 +218,7 @@ To write the contents of the ore dictionary to config/oreDictionaryRegistery.txt - - + @@ -251,8 +227,7 @@ To write the contents of the ore dictionary to config/oreDictionaryRegistery.txt - - + @@ -260,8 +235,7 @@ To write the contents of the ore dictionary to config/oreDictionaryRegistery.txt - - + @@ -270,8 +244,7 @@ To write the contents of the ore dictionary to config/oreDictionaryRegistery.txt - - + @@ -280,8 +253,7 @@ To write the contents of the ore dictionary to config/oreDictionaryRegistery.txt - - + @@ -290,8 +262,7 @@ To write the contents of the ore dictionary to config/oreDictionaryRegistery.txt - - + @@ -300,9 +271,7 @@ To write the contents of the ore dictionary to config/oreDictionaryRegistery.txt - - - + @@ -311,8 +280,7 @@ To write the contents of the ore dictionary to config/oreDictionaryRegistery.txt - - + @@ -321,8 +289,7 @@ To write the contents of the ore dictionary to config/oreDictionaryRegistery.txt - - + @@ -331,9 +298,7 @@ To write the contents of the ore dictionary to config/oreDictionaryRegistery.txt - - - + @@ -342,8 +307,7 @@ To write the contents of the ore dictionary to config/oreDictionaryRegistery.txt - - + @@ -352,13 +316,10 @@ To write the contents of the ore dictionary to config/oreDictionaryRegistery.txt - - - - - + + @@ -367,8 +328,7 @@ To write the contents of the ore dictionary to config/oreDictionaryRegistery.txt - - + @@ -377,8 +337,7 @@ To write the contents of the ore dictionary to config/oreDictionaryRegistery.txt - - + @@ -387,19 +346,16 @@ To write the contents of the ore dictionary to config/oreDictionaryRegistery.txt - - + - + - - - + @@ -409,31 +365,27 @@ To write the contents of the ore dictionary to config/oreDictionaryRegistery.txt - - - + - + - - + - - + + - - + @@ -443,8 +395,7 @@ To write the contents of the ore dictionary to config/oreDictionaryRegistery.txt - - + @@ -454,8 +405,7 @@ To write the contents of the ore dictionary to config/oreDictionaryRegistery.txt - - + @@ -465,9 +415,15 @@ To write the contents of the ore dictionary to config/oreDictionaryRegistery.txt - - - - - - - - +--> \ No newline at end of file diff --git a/resources/assets/enderio/config/AlloySmelterRecipes_User.xml b/resources/assets/enderio/config/AlloySmelterRecipes_User.xml index 4cafc4cd..02fb561d 100644 --- a/resources/assets/enderio/config/AlloySmelterRecipes_User.xml +++ b/resources/assets/enderio/config/AlloySmelterRecipes_User.xml @@ -1,19 +1,18 @@ - + \ No newline at end of file diff --git a/resources/assets/enderio/config/EnchanterRecipes_Core.xml b/resources/assets/enderio/config/EnchanterRecipes_Core.xml index a2d06626..a277ee5e 100644 --- a/resources/assets/enderio/config/EnchanterRecipes_Core.xml +++ b/resources/assets/enderio/config/EnchanterRecipes_Core.xml @@ -1,137 +1,109 @@ + + level = enchantmentItem.stackSize + levelCost = Config.enchanterBaseLevelCost; + for (int i = 0; i < level; i++) { + levelCost += costPerLevel * level; + } + +--> - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + - - - + + + + + - - - - - + \ No newline at end of file diff --git a/resources/assets/enderio/config/EnchanterRecipes_User.xml b/resources/assets/enderio/config/EnchanterRecipes_User.xml index 152f3f8e..d6a9a39a 100644 --- a/resources/assets/enderio/config/EnchanterRecipes_User.xml +++ b/resources/assets/enderio/config/EnchanterRecipes_User.xml @@ -1,27 +1,27 @@ - - + +--> + + \ No newline at end of file diff --git a/resources/assets/enderio/config/OreDictionaryPreferences_Core.xml b/resources/assets/enderio/config/OreDictionaryPreferences_Core.xml index dac71171..64cf0b37 100644 --- a/resources/assets/enderio/config/OreDictionaryPreferences_Core.xml +++ b/resources/assets/enderio/config/OreDictionaryPreferences_Core.xml @@ -1,120 +1,100 @@ + - - + - - + - - + - - + - - + - - + - - + - - + - - + - - + - - + - - + - - + - - - + - - + - - + - - + - - + - - + + + + - - - - - - + \ No newline at end of file diff --git a/resources/assets/enderio/config/OreDictionaryPreferences_User.xml b/resources/assets/enderio/config/OreDictionaryPreferences_User.xml index f735f22b..c8581360 100644 --- a/resources/assets/enderio/config/OreDictionaryPreferences_User.xml +++ b/resources/assets/enderio/config/OreDictionaryPreferences_User.xml @@ -1,5 +1,7 @@ - +--> + + \ No newline at end of file diff --git a/resources/assets/enderio/config/PainterPaintSources_Core.xml b/resources/assets/enderio/config/PainterPaintSources_Core.xml index b8c72325..a158eeb9 100644 --- a/resources/assets/enderio/config/PainterPaintSources_Core.xml +++ b/resources/assets/enderio/config/PainterPaintSources_Core.xml @@ -1,28 +1,24 @@ - +--> @@ -30,13 +26,11 @@ For example, to remove Silverwood planks from the whitelist, the user file would - + - - \ No newline at end of file diff --git a/resources/assets/enderio/config/PainterPaintSources_User.xml b/resources/assets/enderio/config/PainterPaintSources_User.xml index fb46e182..be23cf84 100644 --- a/resources/assets/enderio/config/PainterPaintSources_User.xml +++ b/resources/assets/enderio/config/PainterPaintSources_User.xml @@ -1,9 +1,10 @@ - +--> + - + diff --git a/resources/assets/enderio/config/PoweredSpawnerConfig_Core.json b/resources/assets/enderio/config/PoweredSpawnerConfig_Core.json index 0f8a22e5..2bd70925 100644 --- a/resources/assets/enderio/config/PoweredSpawnerConfig_Core.json +++ b/resources/assets/enderio/config/PoweredSpawnerConfig_Core.json @@ -1,40 +1,40 @@ { - + // This is the CORE FILE. Do not edit. The RF cost per tick for spawners of each entity type is multiplied by these values "costMultiplier": { - + "Zombie" : "1", - "Creeper" : "1.5", + "Creeper" : "1.5", "Skeleton" : "2", "Spider" : "1", "CaveSpider" : "1", - "Silverfish" : "1", - "Witch" : "5", - "Slime" : "5", + "Silverfish" : "1", + "Witch" : "5", + "Slime" : "5", "Enderman" : "10", "SpecialMobs.SpecialEnderman" : "10", - + "LavaSlime" : "2", "PigZombie" : "5", "Ghast" : "10", "Blaze" : "5", - + "SnowMan" : "1", "VillagerGolem" : "10", "Villager" : "1", - + "Wolf" : "1", "Ozelot" : "1", "EntityHorse" : "1", "Bat" : "0.5", - - "Squid" : "0.5", - "Chicken" : "0.5", + + "Squid" : "0.5", + "Chicken" : "0.5", "Sheep" : "0.5", "Cow" : "0.5", - "Pig" : "0.5", + "Pig" : "0.5", "MushroomCow" : "1", - + "enderzoo.Enderminy" : "10", "enderzoo.ConcussionCreeper" : "1.5", "enderzoo.enderzoo.FallenKnight" : "1", @@ -42,9 +42,9 @@ "enderio.witherSkeleton" : "20" }, - + "blackList": [ "VillagerGolem", "Villager" ] -} +} \ No newline at end of file diff --git a/resources/assets/enderio/config/PoweredSpawnerConfig_User.json b/resources/assets/enderio/config/PoweredSpawnerConfig_User.json index 5430aa05..f8f2e222 100644 --- a/resources/assets/enderio/config/PoweredSpawnerConfig_User.json +++ b/resources/assets/enderio/config/PoweredSpawnerConfig_User.json @@ -3,7 +3,7 @@ // New entities are added, one already in _Core will have their values replaced with those in this file "costMultiplier": { } - + // Adding a blackList section will completely replace the one in the core file. } \ No newline at end of file diff --git a/resources/assets/enderio/config/SAGMillRecipes_Core.xml b/resources/assets/enderio/config/SAGMillRecipes_Core.xml index f466da70..50c76cc5 100644 --- a/resources/assets/enderio/config/SAGMillRecipes_Core.xml +++ b/resources/assets/enderio/config/SAGMillRecipes_Core.xml @@ -1,64 +1,59 @@ - - - + - + @@ -153,8 +151,7 @@ addOreDictionaryTooltips=true - - + @@ -162,121 +159,108 @@ addOreDictionaryTooltips=true - - + - + - - + - - - - + + + + - - + - + - + - - + - - - + + + - - + - + - - + - - + + - - + - + - - + - + - - - - + + - + - - + - + - - + - + - - + @@ -284,8 +268,7 @@ addOreDictionaryTooltips=true - - + @@ -294,20 +277,17 @@ addOreDictionaryTooltips=true - - + - + - - - + @@ -315,8 +295,7 @@ addOreDictionaryTooltips=true - - + @@ -326,8 +305,7 @@ addOreDictionaryTooltips=true - - + @@ -335,8 +313,7 @@ addOreDictionaryTooltips=true - - + @@ -345,8 +322,7 @@ addOreDictionaryTooltips=true - - + @@ -355,8 +331,7 @@ addOreDictionaryTooltips=true - - + @@ -365,8 +340,7 @@ addOreDictionaryTooltips=true - - + @@ -376,8 +350,7 @@ addOreDictionaryTooltips=true - - + @@ -386,8 +359,7 @@ addOreDictionaryTooltips=true - - + @@ -396,8 +368,7 @@ addOreDictionaryTooltips=true - - + @@ -408,8 +379,7 @@ addOreDictionaryTooltips=true - - + @@ -418,8 +388,7 @@ addOreDictionaryTooltips=true - - + @@ -428,8 +397,7 @@ addOreDictionaryTooltips=true - - + @@ -439,8 +407,7 @@ addOreDictionaryTooltips=true - - + @@ -449,8 +416,7 @@ addOreDictionaryTooltips=true - - + @@ -459,9 +425,7 @@ addOreDictionaryTooltips=true - - - + @@ -470,8 +434,7 @@ addOreDictionaryTooltips=true - - + @@ -480,51 +443,45 @@ addOreDictionaryTooltips=true - - - - + + - - + + - - + - + - - + - + - - + - + - - + @@ -534,8 +491,7 @@ addOreDictionaryTooltips=true - - + @@ -543,8 +499,7 @@ addOreDictionaryTooltips=true - - + @@ -553,8 +508,7 @@ addOreDictionaryTooltips=true - - + @@ -562,8 +516,7 @@ addOreDictionaryTooltips=true - - + @@ -571,8 +524,7 @@ addOreDictionaryTooltips=true - - + @@ -580,8 +532,7 @@ addOreDictionaryTooltips=true - - + @@ -590,8 +541,7 @@ addOreDictionaryTooltips=true - - + @@ -599,8 +549,7 @@ addOreDictionaryTooltips=true - - + @@ -608,8 +557,7 @@ addOreDictionaryTooltips=true - - + @@ -617,8 +565,7 @@ addOreDictionaryTooltips=true - - + @@ -626,8 +573,7 @@ addOreDictionaryTooltips=true - - + @@ -635,8 +581,7 @@ addOreDictionaryTooltips=true - - + @@ -644,12 +589,10 @@ addOreDictionaryTooltips=true - - - - + + @@ -657,12 +600,10 @@ addOreDictionaryTooltips=true - - - - + + @@ -673,8 +614,7 @@ addOreDictionaryTooltips=true - - + @@ -682,8 +622,7 @@ addOreDictionaryTooltips=true - - + @@ -691,8 +630,7 @@ addOreDictionaryTooltips=true - - + @@ -700,8 +638,7 @@ addOreDictionaryTooltips=true - - + @@ -709,8 +646,7 @@ addOreDictionaryTooltips=true - - + @@ -718,13 +654,10 @@ addOreDictionaryTooltips=true - - - - - + + @@ -733,8 +666,7 @@ addOreDictionaryTooltips=true - - + @@ -743,8 +675,7 @@ addOreDictionaryTooltips=true - - + @@ -752,8 +683,7 @@ addOreDictionaryTooltips=true - - + @@ -761,8 +691,7 @@ addOreDictionaryTooltips=true - - + @@ -770,8 +699,7 @@ addOreDictionaryTooltips=true - - + @@ -781,9 +709,8 @@ addOreDictionaryTooltips=true - - - + + @@ -791,8 +718,7 @@ addOreDictionaryTooltips=true - - + @@ -801,12 +727,10 @@ addOreDictionaryTooltips=true - - - - + + @@ -814,8 +738,7 @@ addOreDictionaryTooltips=true - - + @@ -823,8 +746,7 @@ addOreDictionaryTooltips=true - - + @@ -832,8 +754,7 @@ addOreDictionaryTooltips=true - - + @@ -841,8 +762,7 @@ addOreDictionaryTooltips=true - - + @@ -850,8 +770,7 @@ addOreDictionaryTooltips=true - - + @@ -859,8 +778,7 @@ addOreDictionaryTooltips=true - - + @@ -868,8 +786,7 @@ addOreDictionaryTooltips=true - - + @@ -877,8 +794,7 @@ addOreDictionaryTooltips=true - - + @@ -886,8 +802,7 @@ addOreDictionaryTooltips=true - - + @@ -895,8 +810,7 @@ addOreDictionaryTooltips=true - - + @@ -904,8 +818,7 @@ addOreDictionaryTooltips=true - - + @@ -913,8 +826,7 @@ addOreDictionaryTooltips=true - - + @@ -922,8 +834,7 @@ addOreDictionaryTooltips=true - - + @@ -931,8 +842,7 @@ addOreDictionaryTooltips=true - - + @@ -940,8 +850,7 @@ addOreDictionaryTooltips=true - - + @@ -949,8 +858,7 @@ addOreDictionaryTooltips=true - - + @@ -958,13 +866,10 @@ addOreDictionaryTooltips=true - - - - - + + @@ -972,8 +877,7 @@ addOreDictionaryTooltips=true - - + @@ -981,8 +885,7 @@ addOreDictionaryTooltips=true - - + @@ -990,100 +893,90 @@ addOreDictionaryTooltips=true - - + - + - - + - + - - + - + - - + - + - - + - + - - + - + - - + - + - - + - + - - - - + + @@ -1092,8 +985,7 @@ addOreDictionaryTooltips=true - - + @@ -1102,8 +994,7 @@ addOreDictionaryTooltips=true - - + @@ -1112,8 +1003,7 @@ addOreDictionaryTooltips=true - - + @@ -1122,8 +1012,7 @@ addOreDictionaryTooltips=true - - + @@ -1132,8 +1021,7 @@ addOreDictionaryTooltips=true - - + @@ -1142,8 +1030,7 @@ addOreDictionaryTooltips=true - - + @@ -1152,8 +1039,7 @@ addOreDictionaryTooltips=true - - + @@ -1162,8 +1048,7 @@ addOreDictionaryTooltips=true - - + @@ -1172,8 +1057,7 @@ addOreDictionaryTooltips=true - - + @@ -1182,8 +1066,7 @@ addOreDictionaryTooltips=true - - + @@ -1192,8 +1075,7 @@ addOreDictionaryTooltips=true - - + @@ -1202,8 +1084,7 @@ addOreDictionaryTooltips=true - - + @@ -1212,8 +1093,7 @@ addOreDictionaryTooltips=true - - + @@ -1222,8 +1102,7 @@ addOreDictionaryTooltips=true - - + @@ -1232,8 +1111,7 @@ addOreDictionaryTooltips=true - - + @@ -1242,8 +1120,7 @@ addOreDictionaryTooltips=true - - + @@ -1252,8 +1129,7 @@ addOreDictionaryTooltips=true - - + @@ -1262,8 +1138,7 @@ addOreDictionaryTooltips=true - - + @@ -1272,8 +1147,7 @@ addOreDictionaryTooltips=true - - + @@ -1282,8 +1156,7 @@ addOreDictionaryTooltips=true - - + @@ -1292,13 +1165,11 @@ addOreDictionaryTooltips=true - - - - + + - + @@ -1306,7 +1177,7 @@ addOreDictionaryTooltips=true - + @@ -1314,7 +1185,7 @@ addOreDictionaryTooltips=true - + @@ -1322,7 +1193,7 @@ addOreDictionaryTooltips=true - + @@ -1330,7 +1201,7 @@ addOreDictionaryTooltips=true - + @@ -1338,7 +1209,7 @@ addOreDictionaryTooltips=true - + @@ -1346,7 +1217,7 @@ addOreDictionaryTooltips=true - + @@ -1354,7 +1225,7 @@ addOreDictionaryTooltips=true - + @@ -1362,7 +1233,7 @@ addOreDictionaryTooltips=true - + @@ -1370,7 +1241,7 @@ addOreDictionaryTooltips=true - + @@ -1378,7 +1249,7 @@ addOreDictionaryTooltips=true - + @@ -1386,7 +1257,7 @@ addOreDictionaryTooltips=true - + @@ -1394,7 +1265,7 @@ addOreDictionaryTooltips=true - + @@ -1402,7 +1273,7 @@ addOreDictionaryTooltips=true - + @@ -1410,7 +1281,7 @@ addOreDictionaryTooltips=true - + @@ -1418,7 +1289,7 @@ addOreDictionaryTooltips=true - + @@ -1426,7 +1297,7 @@ addOreDictionaryTooltips=true - + @@ -1434,7 +1305,7 @@ addOreDictionaryTooltips=true - + @@ -1442,7 +1313,7 @@ addOreDictionaryTooltips=true - + @@ -1450,7 +1321,7 @@ addOreDictionaryTooltips=true - + @@ -1458,7 +1329,7 @@ addOreDictionaryTooltips=true - + @@ -1466,7 +1337,7 @@ addOreDictionaryTooltips=true - + @@ -1474,7 +1345,7 @@ addOreDictionaryTooltips=true - + @@ -1482,7 +1353,7 @@ addOreDictionaryTooltips=true - + @@ -1490,9 +1361,8 @@ addOreDictionaryTooltips=true - - + @@ -1500,7 +1370,7 @@ addOreDictionaryTooltips=true - + @@ -1508,7 +1378,7 @@ addOreDictionaryTooltips=true - + @@ -1516,7 +1386,7 @@ addOreDictionaryTooltips=true - + @@ -1524,7 +1394,7 @@ addOreDictionaryTooltips=true - + @@ -1532,7 +1402,7 @@ addOreDictionaryTooltips=true - + @@ -1540,7 +1410,7 @@ addOreDictionaryTooltips=true - + @@ -1548,7 +1418,7 @@ addOreDictionaryTooltips=true - + @@ -1556,7 +1426,7 @@ addOreDictionaryTooltips=true - + @@ -1564,7 +1434,7 @@ addOreDictionaryTooltips=true - + @@ -1572,7 +1442,7 @@ addOreDictionaryTooltips=true - + @@ -1580,7 +1450,7 @@ addOreDictionaryTooltips=true - + @@ -1588,7 +1458,7 @@ addOreDictionaryTooltips=true - + @@ -1596,7 +1466,7 @@ addOreDictionaryTooltips=true - + @@ -1604,7 +1474,7 @@ addOreDictionaryTooltips=true - + @@ -1612,7 +1482,7 @@ addOreDictionaryTooltips=true - + @@ -1620,7 +1490,7 @@ addOreDictionaryTooltips=true - + @@ -1628,7 +1498,7 @@ addOreDictionaryTooltips=true - + @@ -1636,7 +1506,7 @@ addOreDictionaryTooltips=true - + @@ -1644,7 +1514,7 @@ addOreDictionaryTooltips=true - + @@ -1652,7 +1522,7 @@ addOreDictionaryTooltips=true - + @@ -1660,7 +1530,7 @@ addOreDictionaryTooltips=true - + @@ -1668,7 +1538,7 @@ addOreDictionaryTooltips=true - + @@ -1676,7 +1546,7 @@ addOreDictionaryTooltips=true - + @@ -1684,7 +1554,7 @@ addOreDictionaryTooltips=true - + @@ -1692,7 +1562,7 @@ addOreDictionaryTooltips=true - + @@ -1700,7 +1570,7 @@ addOreDictionaryTooltips=true - + @@ -1708,7 +1578,7 @@ addOreDictionaryTooltips=true - + @@ -1716,7 +1586,7 @@ addOreDictionaryTooltips=true - + @@ -1724,7 +1594,7 @@ addOreDictionaryTooltips=true - + @@ -1732,7 +1602,7 @@ addOreDictionaryTooltips=true - + @@ -1740,7 +1610,7 @@ addOreDictionaryTooltips=true - + @@ -1748,7 +1618,7 @@ addOreDictionaryTooltips=true - + @@ -1756,7 +1626,7 @@ addOreDictionaryTooltips=true - + @@ -1764,7 +1634,7 @@ addOreDictionaryTooltips=true - + @@ -1772,7 +1642,7 @@ addOreDictionaryTooltips=true - + @@ -1780,7 +1650,7 @@ addOreDictionaryTooltips=true - + @@ -1788,7 +1658,7 @@ addOreDictionaryTooltips=true - + @@ -1796,7 +1666,7 @@ addOreDictionaryTooltips=true - + @@ -1804,9 +1674,8 @@ addOreDictionaryTooltips=true - - + @@ -1814,7 +1683,7 @@ addOreDictionaryTooltips=true - + @@ -1822,7 +1691,7 @@ addOreDictionaryTooltips=true - + @@ -1830,7 +1699,7 @@ addOreDictionaryTooltips=true - + @@ -1838,7 +1707,7 @@ addOreDictionaryTooltips=true - + @@ -1846,7 +1715,7 @@ addOreDictionaryTooltips=true - + @@ -1854,7 +1723,7 @@ addOreDictionaryTooltips=true - + @@ -1862,7 +1731,7 @@ addOreDictionaryTooltips=true - + @@ -1870,7 +1739,7 @@ addOreDictionaryTooltips=true - + @@ -1878,7 +1747,7 @@ addOreDictionaryTooltips=true - + @@ -1886,7 +1755,7 @@ addOreDictionaryTooltips=true - + @@ -1894,7 +1763,7 @@ addOreDictionaryTooltips=true - + @@ -1902,7 +1771,7 @@ addOreDictionaryTooltips=true - + @@ -1910,7 +1779,7 @@ addOreDictionaryTooltips=true - + @@ -1918,7 +1787,7 @@ addOreDictionaryTooltips=true - + @@ -1926,7 +1795,7 @@ addOreDictionaryTooltips=true - + @@ -1934,7 +1803,7 @@ addOreDictionaryTooltips=true - + @@ -1942,7 +1811,7 @@ addOreDictionaryTooltips=true - + @@ -1950,7 +1819,7 @@ addOreDictionaryTooltips=true - + @@ -1958,7 +1827,7 @@ addOreDictionaryTooltips=true - + @@ -1966,7 +1835,7 @@ addOreDictionaryTooltips=true - + @@ -1974,7 +1843,7 @@ addOreDictionaryTooltips=true - + @@ -1982,7 +1851,7 @@ addOreDictionaryTooltips=true - + @@ -1990,7 +1859,7 @@ addOreDictionaryTooltips=true - + @@ -1998,7 +1867,7 @@ addOreDictionaryTooltips=true - + @@ -2006,7 +1875,7 @@ addOreDictionaryTooltips=true - + @@ -2014,7 +1883,7 @@ addOreDictionaryTooltips=true - + @@ -2022,7 +1891,7 @@ addOreDictionaryTooltips=true - + @@ -2030,7 +1899,7 @@ addOreDictionaryTooltips=true - + @@ -2038,7 +1907,7 @@ addOreDictionaryTooltips=true - + @@ -2046,7 +1915,7 @@ addOreDictionaryTooltips=true - + @@ -2054,7 +1923,7 @@ addOreDictionaryTooltips=true - + @@ -2062,7 +1931,7 @@ addOreDictionaryTooltips=true - + @@ -2070,7 +1939,7 @@ addOreDictionaryTooltips=true - + @@ -2078,7 +1947,7 @@ addOreDictionaryTooltips=true - + @@ -2086,7 +1955,7 @@ addOreDictionaryTooltips=true - + @@ -2094,7 +1963,7 @@ addOreDictionaryTooltips=true - + @@ -2102,7 +1971,7 @@ addOreDictionaryTooltips=true - + @@ -2110,7 +1979,7 @@ addOreDictionaryTooltips=true - + @@ -2118,13 +1987,11 @@ addOreDictionaryTooltips=true - - - + - + @@ -2133,9 +2000,8 @@ addOreDictionaryTooltips=true - - + @@ -2143,10 +2009,8 @@ addOreDictionaryTooltips=true - - - + @@ -2154,13 +2018,11 @@ addOreDictionaryTooltips=true - - - + - + @@ -2169,9 +2031,8 @@ addOreDictionaryTooltips=true - - + @@ -2179,8 +2040,7 @@ addOreDictionaryTooltips=true - - + @@ -2188,8 +2048,7 @@ addOreDictionaryTooltips=true - - + @@ -2197,8 +2056,7 @@ addOreDictionaryTooltips=true - - + @@ -2206,13 +2064,11 @@ addOreDictionaryTooltips=true - - - + - + @@ -2220,8 +2076,7 @@ addOreDictionaryTooltips=true - - + @@ -2229,9 +2084,8 @@ addOreDictionaryTooltips=true - - + @@ -2239,8 +2093,7 @@ addOreDictionaryTooltips=true - - + @@ -2248,8 +2101,7 @@ addOreDictionaryTooltips=true - - + @@ -2257,8 +2109,7 @@ addOreDictionaryTooltips=true - - + @@ -2266,11 +2117,10 @@ addOreDictionaryTooltips=true - - - + + @@ -2278,8 +2128,7 @@ addOreDictionaryTooltips=true - - + @@ -2287,8 +2136,7 @@ addOreDictionaryTooltips=true - - + @@ -2296,8 +2144,7 @@ addOreDictionaryTooltips=true - - + @@ -2305,8 +2152,7 @@ addOreDictionaryTooltips=true - - + @@ -2314,8 +2160,7 @@ addOreDictionaryTooltips=true - - + @@ -2323,8 +2168,7 @@ addOreDictionaryTooltips=true - - + @@ -2332,8 +2176,7 @@ addOreDictionaryTooltips=true - - + @@ -2341,8 +2184,7 @@ addOreDictionaryTooltips=true - - + @@ -2350,8 +2192,7 @@ addOreDictionaryTooltips=true - - + @@ -2359,8 +2200,7 @@ addOreDictionaryTooltips=true - - + @@ -2368,8 +2208,7 @@ addOreDictionaryTooltips=true - - + @@ -2377,8 +2216,7 @@ addOreDictionaryTooltips=true - - + @@ -2386,8 +2224,7 @@ addOreDictionaryTooltips=true - - + @@ -2395,8 +2232,7 @@ addOreDictionaryTooltips=true - - + @@ -2404,8 +2240,7 @@ addOreDictionaryTooltips=true - - + @@ -2413,8 +2248,7 @@ addOreDictionaryTooltips=true - - + @@ -2422,8 +2256,7 @@ addOreDictionaryTooltips=true - - + @@ -2431,8 +2264,7 @@ addOreDictionaryTooltips=true - - + @@ -2440,8 +2272,7 @@ addOreDictionaryTooltips=true - - + @@ -2449,8 +2280,7 @@ addOreDictionaryTooltips=true - - + @@ -2458,8 +2288,7 @@ addOreDictionaryTooltips=true - - + @@ -2467,8 +2296,7 @@ addOreDictionaryTooltips=true - - + @@ -2476,8 +2304,7 @@ addOreDictionaryTooltips=true - - + @@ -2485,8 +2312,7 @@ addOreDictionaryTooltips=true - - + @@ -2494,8 +2320,7 @@ addOreDictionaryTooltips=true - - + @@ -2503,8 +2328,7 @@ addOreDictionaryTooltips=true - - + @@ -2512,8 +2336,7 @@ addOreDictionaryTooltips=true - - + @@ -2521,8 +2344,7 @@ addOreDictionaryTooltips=true - - + @@ -2530,8 +2352,7 @@ addOreDictionaryTooltips=true - - + @@ -2539,8 +2360,7 @@ addOreDictionaryTooltips=true - - + @@ -2548,8 +2368,7 @@ addOreDictionaryTooltips=true - - + @@ -2559,243 +2378,242 @@ addOreDictionaryTooltips=true - - - + + + - - - + + + - - + + - - - + + + - - + + - - - + + + - - + + - - - + + + - - + + - - - + + + - - + + - - - + + + - - + + - - - + + + - - + + - - - + + + - - + + - - - + + + - - + + - - - + + + - - + + - - - + + + - - + + - - - + + + - - + + - - - + + + - - + + - - - + + + - - + + - - - + + + - - + + - - - + + + - - + + - - - + + + - - + + - - - + + + - - + + - - - + + + - - + + - - - + + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - - + + @@ -2807,12 +2625,10 @@ addOreDictionaryTooltips=true - + - + @@ -2822,12 +2638,10 @@ addOreDictionaryTooltips=true - - - + \ No newline at end of file diff --git a/resources/assets/enderio/config/SAGMillRecipes_User.xml b/resources/assets/enderio/config/SAGMillRecipes_User.xml index fe870d9f..20ad9a48 100644 --- a/resources/assets/enderio/config/SAGMillRecipes_User.xml +++ b/resources/assets/enderio/config/SAGMillRecipes_User.xml @@ -1,107 +1,101 @@ + Disable all recipes in the group 'Vanilla': - + - + To disable individual recipes, simply provide an invalid recipe for them: - + Grinding Balls: + Adding a new grinding ball: - - - - - - - - - - +--> - + + + \ No newline at end of file diff --git a/resources/assets/enderio/config/SliceAndSpliceRecipes_Core.xml b/resources/assets/enderio/config/SliceAndSpliceRecipes_Core.xml index 2ab71020..75101bac 100644 --- a/resources/assets/enderio/config/SliceAndSpliceRecipes_Core.xml +++ b/resources/assets/enderio/config/SliceAndSpliceRecipes_Core.xml @@ -1,72 +1,67 @@ - - - + + - - - - - - + + + + + + - + - - + - - - - - - + + + + + + - + - - + - - - - - - + + + + + + - + - - + - - - - - - + + + + + + - + - - + \ No newline at end of file diff --git a/resources/assets/enderio/config/VatRecipes_Core.xml b/resources/assets/enderio/config/VatRecipes_Core.xml index b4f61cbe..e20c75d7 100644 --- a/resources/assets/enderio/config/VatRecipes_Core.xml +++ b/resources/assets/enderio/config/VatRecipes_Core.xml @@ -1,113 +1,96 @@ - - --> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + - - - - + + + + + + + + + + + + + - + - - - + - - - - + + + + + + + + - + + + + + + + + + + + + + + + + + + + + + - - - - - \ No newline at end of file + + \ No newline at end of file diff --git a/resources/assets/enderio/config/VatRecipes_User.xml b/resources/assets/enderio/config/VatRecipes_User.xml index f9d777e3..57f05f18 100644 --- a/resources/assets/enderio/config/VatRecipes_User.xml +++ b/resources/assets/enderio/config/VatRecipes_User.xml @@ -1,3 +1,3 @@ - + \ No newline at end of file diff --git a/resources/assets/enderio/textures/gui/painter.png b/resources/assets/enderio/textures/gui/painter.png index 3c79ee02..d47fa20c 100644 Binary files a/resources/assets/enderio/textures/gui/painter.png and b/resources/assets/enderio/textures/gui/painter.png differ diff --git a/src/api/java/com/jaquadro/minecraft/storagedrawers/api/IStorageDrawersApi.java b/src/api/java/com/jaquadro/minecraft/storagedrawers/api/IStorageDrawersApi.java new file mode 100644 index 00000000..5c73621e --- /dev/null +++ b/src/api/java/com/jaquadro/minecraft/storagedrawers/api/IStorageDrawersApi.java @@ -0,0 +1,20 @@ +package com.jaquadro.minecraft.storagedrawers.api; + +import com.jaquadro.minecraft.storagedrawers.api.pack.IPackBlockFactory; +import com.jaquadro.minecraft.storagedrawers.api.registry.IRecipeHandlerRegistry; +import com.jaquadro.minecraft.storagedrawers.api.registry.IRenderRegistry; +import com.jaquadro.minecraft.storagedrawers.api.registry.IWailaRegistry; + +public interface IStorageDrawersApi +{ + /** + * Recipe handlers are used to make custom recipes compatible with compacting drawers. + */ + IRecipeHandlerRegistry recipeHandlerRegistry (); + + IRenderRegistry renderRegistry (); + + IWailaRegistry wailaRegistry (); + + IPackBlockFactory packFactory (); +} diff --git a/src/api/java/com/jaquadro/minecraft/storagedrawers/api/StorageDrawersApi.java b/src/api/java/com/jaquadro/minecraft/storagedrawers/api/StorageDrawersApi.java new file mode 100644 index 00000000..70a15174 --- /dev/null +++ b/src/api/java/com/jaquadro/minecraft/storagedrawers/api/StorageDrawersApi.java @@ -0,0 +1,28 @@ +package com.jaquadro.minecraft.storagedrawers.api; + +/** + * Entry point for the public API. + */ +public class StorageDrawersApi +{ + private static IStorageDrawersApi instance; + + /** + * API entry point. + * + * @return The {@link IStorageDrawersApi} instance or null if the API or Storage Drawers is unavailable. + */ + public static IStorageDrawersApi instance () { + if (instance == null) { + try { + Class classApi = Class.forName( "com.jaquadro.minecraft.storagedrawers.core.Api" ); + instance = (IStorageDrawersApi) classApi.getField("instance").get(null); + } + catch (Throwable t) { + return null; + } + } + + return instance; + } +} diff --git a/src/api/java/com/jaquadro/minecraft/storagedrawers/api/event/DrawerPopulatedEvent.java b/src/api/java/com/jaquadro/minecraft/storagedrawers/api/event/DrawerPopulatedEvent.java new file mode 100644 index 00000000..f5dca193 --- /dev/null +++ b/src/api/java/com/jaquadro/minecraft/storagedrawers/api/event/DrawerPopulatedEvent.java @@ -0,0 +1,19 @@ +package com.jaquadro.minecraft.storagedrawers.api.event; + +import com.jaquadro.minecraft.storagedrawers.api.storage.IDrawer; +import cpw.mods.fml.common.eventhandler.Event; + +/** + * This event is called when a drawer has been bound to a new item. This is + * and opportunity for mods to cache extended data with the drawer. + * + * This event is also called when the drawer is changed to empty. + */ +public class DrawerPopulatedEvent extends Event +{ + public final IDrawer drawer; + + public DrawerPopulatedEvent (IDrawer drawer) { + this.drawer = drawer; + } +} diff --git a/src/api/java/com/jaquadro/minecraft/storagedrawers/api/inventory/IDrawerInventory.java b/src/api/java/com/jaquadro/minecraft/storagedrawers/api/inventory/IDrawerInventory.java new file mode 100644 index 00000000..47396c79 --- /dev/null +++ b/src/api/java/com/jaquadro/minecraft/storagedrawers/api/inventory/IDrawerInventory.java @@ -0,0 +1,35 @@ +package com.jaquadro.minecraft.storagedrawers.api.inventory; + +import net.minecraft.inventory.ISidedInventory; +import net.minecraft.item.ItemStack; + +public interface IDrawerInventory extends ISidedInventory +{ + /** + * Gets a drawer's group slot index from an IInventory slot index. + * + * @param inventorySlot An IInventory slot index returned from getInventorySlot. + */ + int getDrawerSlot (int inventorySlot); + + /** + * Gets an IInventory slot index suitable for operations for the given type. + * + * @param drawerSlot The index of the drawer within its group. + * @param type The type of IInventory slot to return an index for. + */ + int getInventorySlot (int drawerSlot, SlotType type); + + /** + * Gets the type associated with a given IInventory slot index. + * + * @param inventorySlot An IInventory slot index returned from getInventorySlot. + */ + SlotType getInventorySlotType (int inventorySlot); + + boolean canInsertItem (int slot, ItemStack stack); + + boolean canExtractItem (int slot, ItemStack stack); + + boolean syncInventoryIfNeeded (); +} diff --git a/src/api/java/com/jaquadro/minecraft/storagedrawers/api/inventory/IInventoryAdapter.java b/src/api/java/com/jaquadro/minecraft/storagedrawers/api/inventory/IInventoryAdapter.java new file mode 100644 index 00000000..71f55e3d --- /dev/null +++ b/src/api/java/com/jaquadro/minecraft/storagedrawers/api/inventory/IInventoryAdapter.java @@ -0,0 +1,16 @@ +package com.jaquadro.minecraft.storagedrawers.api.inventory; + +import net.minecraft.item.ItemStack; + +public interface IInventoryAdapter +{ + ItemStack getInventoryStack (SlotType slotType); + + void setInStack (ItemStack stack); + + void setOutStack (ItemStack stack); + + void syncInventory (); + + boolean syncInventoryIfNeeded (); +} diff --git a/src/api/java/com/jaquadro/minecraft/storagedrawers/api/inventory/SlotType.java b/src/api/java/com/jaquadro/minecraft/storagedrawers/api/inventory/SlotType.java new file mode 100644 index 00000000..dbb002ed --- /dev/null +++ b/src/api/java/com/jaquadro/minecraft/storagedrawers/api/inventory/SlotType.java @@ -0,0 +1,15 @@ +package com.jaquadro.minecraft.storagedrawers.api.inventory; + +/** + * Classifies different IInventory slots according to how they should be used. + */ +public enum SlotType +{ + /** An inventory slot for input-only operations; stack sizes artificially held low. */ + INPUT, + + /** An inventory slot for output-only operations; stack sizes artificially held high. */ + OUTPUT; + + public static final SlotType[] values = values(); +} diff --git a/src/api/java/com/jaquadro/minecraft/storagedrawers/api/pack/BlockConfiguration.java b/src/api/java/com/jaquadro/minecraft/storagedrawers/api/pack/BlockConfiguration.java new file mode 100644 index 00000000..502e46f3 --- /dev/null +++ b/src/api/java/com/jaquadro/minecraft/storagedrawers/api/pack/BlockConfiguration.java @@ -0,0 +1,49 @@ +package com.jaquadro.minecraft.storagedrawers.api.pack; + +public enum BlockConfiguration +{ + BasicFull1(BlockType.Drawers, 1, false), + BasicFull2(BlockType.Drawers, 2, false), + BasicFull4(BlockType.Drawers, 4, false), + BasicHalf2(BlockType.Drawers, 2, true), + BasicHalf4(BlockType.Drawers, 4, true), + + SortingFull1(BlockType.DrawersSorting, 1, false), + SortingFull2(BlockType.DrawersSorting, 2, false), + SortingFull4(BlockType.DrawersSorting, 4, false), + SortingHalf2(BlockType.DrawersSorting, 2, true), + SortingHalf4(BlockType.DrawersSorting, 4, true), + + Trim(BlockType.Trim, 0, false); + + private final BlockType type; + private final int drawerCount; + private final boolean halfDepth; + + BlockConfiguration (BlockType type, int count, boolean half) { + this.type = type; + this.drawerCount = count; + this.halfDepth = half; + } + + public BlockType getBlockType () { + return type; + } + + public int getDrawerCount () { + return drawerCount; + } + + public boolean isHalfDepth () { + return halfDepth; + } + + public static BlockConfiguration by (BlockType type, int drawerCount, boolean halfDepth) { + for (BlockConfiguration config : values()) { + if (config.type == type && config.drawerCount == drawerCount && config.halfDepth == halfDepth) + return config; + } + + return null; + } +} diff --git a/src/api/java/com/jaquadro/minecraft/storagedrawers/api/pack/BlockType.java b/src/api/java/com/jaquadro/minecraft/storagedrawers/api/pack/BlockType.java new file mode 100644 index 00000000..9487f6cd --- /dev/null +++ b/src/api/java/com/jaquadro/minecraft/storagedrawers/api/pack/BlockType.java @@ -0,0 +1,8 @@ +package com.jaquadro.minecraft.storagedrawers.api.pack; + +public enum BlockType +{ + Drawers, + DrawersSorting, + Trim +} diff --git a/src/api/java/com/jaquadro/minecraft/storagedrawers/api/pack/IPackBlockFactory.java b/src/api/java/com/jaquadro/minecraft/storagedrawers/api/pack/IPackBlockFactory.java new file mode 100644 index 00000000..d6ffe1f5 --- /dev/null +++ b/src/api/java/com/jaquadro/minecraft/storagedrawers/api/pack/IPackBlockFactory.java @@ -0,0 +1,11 @@ +package com.jaquadro.minecraft.storagedrawers.api.pack; + +import net.minecraft.block.Block; +import net.minecraft.item.ItemBlock; + +public interface IPackBlockFactory +{ + Block createBlock (BlockConfiguration blockConfig, IPackDataResolver dataResolver); + + void registerBlock (Block block, String name); +} diff --git a/src/api/java/com/jaquadro/minecraft/storagedrawers/api/pack/IPackDataResolver.java b/src/api/java/com/jaquadro/minecraft/storagedrawers/api/pack/IPackDataResolver.java new file mode 100644 index 00000000..bc9627bc --- /dev/null +++ b/src/api/java/com/jaquadro/minecraft/storagedrawers/api/pack/IPackDataResolver.java @@ -0,0 +1,18 @@ +package com.jaquadro.minecraft.storagedrawers.api.pack; + +import net.minecraft.creativetab.CreativeTabs; + +public interface IPackDataResolver +{ + String getPackModID (); + + String getBlockName (BlockConfiguration blockConfig); + + CreativeTabs getCreativeTabs (BlockType type); + + boolean isValidMetaValue (int meta); + + String getUnlocalizedName (int meta); + + String getTexturePath (TextureType type, int meta); +} diff --git a/src/api/java/com/jaquadro/minecraft/storagedrawers/api/pack/StandardDataResolver.java b/src/api/java/com/jaquadro/minecraft/storagedrawers/api/pack/StandardDataResolver.java new file mode 100644 index 00000000..212f2471 --- /dev/null +++ b/src/api/java/com/jaquadro/minecraft/storagedrawers/api/pack/StandardDataResolver.java @@ -0,0 +1,106 @@ +package com.jaquadro.minecraft.storagedrawers.api.pack; + +import net.minecraft.creativetab.CreativeTabs; + +public class StandardDataResolver implements IPackDataResolver +{ + private String modID; + private String[] unlocalizedNames; + private CreativeTabs creativeTab; + + public StandardDataResolver (String modID, String[] unlocalizedNames) { + this.modID = modID; + this.unlocalizedNames = unlocalizedNames; + } + + public StandardDataResolver (String modID, String[] unlocalizedNames, CreativeTabs creativeTab) { + this(modID, unlocalizedNames); + this.creativeTab = creativeTab; + } + + @Override + public String getPackModID () { + return modID; + } + + protected String makeBlockName (String name) { + return getPackModID().toLowerCase() + "." + name; + } + + @Override + public String getBlockName (BlockConfiguration blockConfig) { + switch (blockConfig.getBlockType()) { + case Drawers: + case DrawersSorting: + if (blockConfig.getDrawerCount() == 1) + return makeBlockName("fullDrawers1"); + if (blockConfig.getDrawerCount() == 2 && !blockConfig.isHalfDepth()) + return makeBlockName("fullDrawers2"); + if (blockConfig.getDrawerCount() == 4 && !blockConfig.isHalfDepth()) + return makeBlockName("fullDrawers4"); + if (blockConfig.getDrawerCount() == 2 && blockConfig.isHalfDepth()) + return makeBlockName("halfDrawers2"); + if (blockConfig.getDrawerCount() == 4 && blockConfig.isHalfDepth()) + return makeBlockName("halfDrawers4"); + break; + case Trim: + return makeBlockName("trim"); + } + return null; + } + + @Override + public CreativeTabs getCreativeTabs (BlockType type) { + return creativeTab; + } + + @Override + public boolean isValidMetaValue (int meta) { + if (meta < 0 || meta >= unlocalizedNames.length) + return false; + + return unlocalizedNames != null && unlocalizedNames[meta] != null; + } + + @Override + public String getUnlocalizedName (int meta) { + if (!isValidMetaValue(meta)) + return null; + + return unlocalizedNames[meta]; + } + + protected String getBaseTexturePath () { + return getPackModID() + ":"; + } + + protected String getTextureMetaName (int meta) { + return getUnlocalizedName(meta); + } + + @Override + public String getTexturePath (TextureType type, int meta) { + switch (type) { + case Front1: + return getBaseTexturePath() + "drawers_" + getTextureMetaName(meta) + "_front_1"; + case Front2: + return getBaseTexturePath() + "drawers_" + getTextureMetaName(meta) + "_front_2"; + case Front4: + return getBaseTexturePath() + "drawers_" + getTextureMetaName(meta) + "_front_4"; + case Side: + return getBaseTexturePath() + "drawers_" + getTextureMetaName(meta) + "_side"; + case SideSort: + return getBaseTexturePath() + "drawers_" + getTextureMetaName(meta) + "_sort"; + case SideVSplit: + return getBaseTexturePath() + "drawers_" + getTextureMetaName(meta) + "_side_v"; + case SideHSplit: + return getBaseTexturePath() + "drawers_" + getTextureMetaName(meta) + "_side_h"; + case TrimBorder: + return getBaseTexturePath() + "drawers_" + getTextureMetaName(meta) + "_trim"; + case TrimBlock: + return getBaseTexturePath() + "drawers_" + getTextureMetaName(meta) + "_side"; + default: + return ""; + } + } +} diff --git a/src/api/java/com/jaquadro/minecraft/storagedrawers/api/pack/TextureType.java b/src/api/java/com/jaquadro/minecraft/storagedrawers/api/pack/TextureType.java new file mode 100644 index 00000000..e1c9eb08 --- /dev/null +++ b/src/api/java/com/jaquadro/minecraft/storagedrawers/api/pack/TextureType.java @@ -0,0 +1,14 @@ +package com.jaquadro.minecraft.storagedrawers.api.pack; + +public enum TextureType +{ + Front1, + Front2, + Front4, + Side, + SideSort, + SideVSplit, + SideHSplit, + TrimBorder, + TrimBlock +} diff --git a/src/api/java/com/jaquadro/minecraft/storagedrawers/api/registry/IIngredientHandler.java b/src/api/java/com/jaquadro/minecraft/storagedrawers/api/registry/IIngredientHandler.java new file mode 100644 index 00000000..a7432b2b --- /dev/null +++ b/src/api/java/com/jaquadro/minecraft/storagedrawers/api/registry/IIngredientHandler.java @@ -0,0 +1,19 @@ +package com.jaquadro.minecraft.storagedrawers.api.registry; + +import net.minecraft.item.ItemStack; + +/** + * Ingredient handlers are used to get ItemStacks from ingredients in custom IRecipe implementations. If you have + * registered an IRecipeHandler that returns lists of objects that aren't ItemStacks, then you will need to + * implement an ingredient handler for those objects. + */ +public interface IIngredientHandler +{ + /** + * Gets an ItemStack from an object that represents an ingredient in an IRecipe. + * + * @param object An ingredient object. + * @return An ItemStack for the given ingredient. + */ + ItemStack getItemStack (Object object); +} diff --git a/src/api/java/com/jaquadro/minecraft/storagedrawers/api/registry/IRecipeHandler.java b/src/api/java/com/jaquadro/minecraft/storagedrawers/api/registry/IRecipeHandler.java new file mode 100644 index 00000000..d4311ea8 --- /dev/null +++ b/src/api/java/com/jaquadro/minecraft/storagedrawers/api/registry/IRecipeHandler.java @@ -0,0 +1,36 @@ +package com.jaquadro.minecraft.storagedrawers.api.registry; + +import net.minecraft.item.crafting.IRecipe; + +import java.util.List; + +/** + * Recipe handlers are used by compacting drawers to find more-compressed forms of blocks and items. If your recipe + * to craft compressed items is a custom IRecipe implementation, you will need to register a handler for it. + */ +public interface IRecipeHandler +{ + /** + * Get the recipe ingredient list as an array of objects (usually used for shaped recipes). + * If your array does not contain ItemStack objects, you will need to register an {@link IIngredientHandler} to + * get an ItemStack from them. + * + * If you would prefer to return a List, return null in this method and implement {@link #getInputAsList}. + * + * @param recipe An instance of a custom {@link IRecipe}. + * @return An array of ItemStacks or objects with a registered {@link IIngredientHandler}. + */ + Object[] getInputAsArray (IRecipe recipe); + + /** + * Get the recipe ingredient list as a list of objects (usually used for shapeless recipes). + * If your list does not contain ItemStack objects, you will need to register an {@link IIngredientHandler} to + * get an ItemStack from them. + * + * If you would prefer to return an array, return null in this method and implement {@link #getInputAsArray}. + * + * @param recipe An instance of a custom {@link IRecipe}. + * @return A list of ItemStacks or objects with a registered {@link IIngredientHandler}. + */ + List getInputAsList (IRecipe recipe); +} diff --git a/src/api/java/com/jaquadro/minecraft/storagedrawers/api/registry/IRecipeHandlerRegistry.java b/src/api/java/com/jaquadro/minecraft/storagedrawers/api/registry/IRecipeHandlerRegistry.java new file mode 100644 index 00000000..b83d5347 --- /dev/null +++ b/src/api/java/com/jaquadro/minecraft/storagedrawers/api/registry/IRecipeHandlerRegistry.java @@ -0,0 +1,12 @@ +package com.jaquadro.minecraft.storagedrawers.api.registry; + +public interface IRecipeHandlerRegistry +{ + void registerRecipeHandler (Class clazz, IRecipeHandler handler); + + void registerIngredientHandler (Class clazz, IIngredientHandler handler); + + IRecipeHandler getRecipeHandler (Class clazz); + + IIngredientHandler getIngredientHandler (Class clazz); +} diff --git a/src/api/java/com/jaquadro/minecraft/storagedrawers/api/registry/IRenderRegistry.java b/src/api/java/com/jaquadro/minecraft/storagedrawers/api/registry/IRenderRegistry.java new file mode 100644 index 00000000..cfa4543a --- /dev/null +++ b/src/api/java/com/jaquadro/minecraft/storagedrawers/api/registry/IRenderRegistry.java @@ -0,0 +1,8 @@ +package com.jaquadro.minecraft.storagedrawers.api.registry; + +import com.jaquadro.minecraft.storagedrawers.api.render.IRenderLabel; + +public interface IRenderRegistry +{ + void registerPreLabelRenderHandler (IRenderLabel renderHandler); +} diff --git a/src/api/java/com/jaquadro/minecraft/storagedrawers/api/registry/IWailaRegistry.java b/src/api/java/com/jaquadro/minecraft/storagedrawers/api/registry/IWailaRegistry.java new file mode 100644 index 00000000..a4ee9874 --- /dev/null +++ b/src/api/java/com/jaquadro/minecraft/storagedrawers/api/registry/IWailaRegistry.java @@ -0,0 +1,6 @@ +package com.jaquadro.minecraft.storagedrawers.api.registry; + +public interface IWailaRegistry +{ + void registerTooltipHandler (IWailaTooltipHandler handler); +} diff --git a/src/api/java/com/jaquadro/minecraft/storagedrawers/api/registry/IWailaTooltipHandler.java b/src/api/java/com/jaquadro/minecraft/storagedrawers/api/registry/IWailaTooltipHandler.java new file mode 100644 index 00000000..d0f3328c --- /dev/null +++ b/src/api/java/com/jaquadro/minecraft/storagedrawers/api/registry/IWailaTooltipHandler.java @@ -0,0 +1,8 @@ +package com.jaquadro.minecraft.storagedrawers.api.registry; + +import com.jaquadro.minecraft.storagedrawers.api.storage.IDrawer; + +public interface IWailaTooltipHandler +{ + String transformItemName (IDrawer drawer, String defaultName); +} diff --git a/src/api/java/com/jaquadro/minecraft/storagedrawers/api/render/IRenderLabel.java b/src/api/java/com/jaquadro/minecraft/storagedrawers/api/render/IRenderLabel.java new file mode 100644 index 00000000..500030aa --- /dev/null +++ b/src/api/java/com/jaquadro/minecraft/storagedrawers/api/render/IRenderLabel.java @@ -0,0 +1,9 @@ +package com.jaquadro.minecraft.storagedrawers.api.render; + +import com.jaquadro.minecraft.storagedrawers.api.storage.IDrawerGroup; +import net.minecraft.tileentity.TileEntity; + +public interface IRenderLabel +{ + void render (TileEntity tileEntity, IDrawerGroup drawerGroup, int slot, float brightness, float partialTickTime); +} diff --git a/src/api/java/com/jaquadro/minecraft/storagedrawers/api/storage/IDrawer.java b/src/api/java/com/jaquadro/minecraft/storagedrawers/api/storage/IDrawer.java new file mode 100644 index 00000000..c88556c0 --- /dev/null +++ b/src/api/java/com/jaquadro/minecraft/storagedrawers/api/storage/IDrawer.java @@ -0,0 +1,109 @@ +package com.jaquadro.minecraft.storagedrawers.api.storage; + +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; + +public interface IDrawer +{ + /** + * Gets an ItemStack of size 1 representing the type, metadata, and tags of the stored items. + * The returned ItemStack should not be modified for any reason. Make a copy if you need to store or modify it. + */ + ItemStack getStoredItemPrototype (); + + /** + * Gets an ItemStack initialized to the number of items stored in this drawer. + * The returned ItemStack is guaranteed to be a new copy and can be used for any purpose. Does not affect drawer contents. + */ + ItemStack getStoredItemCopy (); + + /** + * Sets the type of the stored item and initializes it to the given amount. Any existing item will be replaced. + * + * @param itemPrototype An ItemStack representing the type, metadata, and tags of the item to store. + * @param amount The amount to initialize the stored item count to. + */ + void setStoredItem (ItemStack itemPrototype, int amount); + + /** + * Gets the number of items stored in this drawer. + */ + int getStoredItemCount (); + + /** + * Sets the number of items stored in this drawer. Triggers syncing of inventories and client data. + * Setting a drawer's count to 0 may also result in the item type being cleared, depending in implementation. + * + * @param amount The new amount of items stored in this drawer. + */ + void setStoredItemCount (int amount); + + /** + * Gets the maximum number of items that can be stored in this drawer. + * This value will vary depending on the max stack size of the stored item type. + */ + int getMaxCapacity (); + + /** + * Gets the maximum number of items that could be stored in this drawer if it held the given item. + * + * @param itemPrototype The item type to query. + */ + int getMaxCapacity (ItemStack itemPrototype); + + /** + * Gets the number of items that could still be added to this drawer before it is full. + */ + int getRemainingCapacity (); + + /** + * Gets the max stack size of the item type stored in this drawer. Convenience method. + */ + int getStoredItemStackSize (); + + /** + * Gets whether or not an item of the given type and data can be stored in this drawer. + * + * Stack size and available capacity are not considered. For drawers that are not empty, this + * method can allow ore-dictionary compatible items to be accepted into the drawer, as defined by what + * the drawer considers to be an equivalent item. + * + * @param itemPrototype An ItemStack representing the type, metadata, and tags of an item. + */ + boolean canItemBeStored (ItemStack itemPrototype); + + /** + * Gets whether or not an item of the given type and data can be extracted from this drawer. + * + * This is intended to allow outbound ore-dictionary conversions of compatible items, as defined by what + * the drawer considers to be an equivalent item. + * + * @param itemPrototype An ItemStack representing the type, metadata, and tags of an item. + */ + boolean canItemBeExtracted (ItemStack itemPrototype); + + /** + * Gets whether or not the drawer has items. + * A drawer set with an item type and 0 count is not considered empty. + */ + boolean isEmpty (); + + /** + * Gets auxiliary data that has been associated with this drawer. + * + * @param key The key used to identify the data. + * @return An opaque object that was previously stored. + */ + Object getExtendedData (String key); + + /** + * Stores auxiliary data with this drawer, mainly for use in integration. + * @param key The key to identify the data with. + * @param data The data to store. + */ + void setExtendedData (String key, Object data); + + void writeToNBT (NBTTagCompound tag); + + void readFromNBT (NBTTagCompound tag); +} diff --git a/src/api/java/com/jaquadro/minecraft/storagedrawers/api/storage/IDrawerGroup.java b/src/api/java/com/jaquadro/minecraft/storagedrawers/api/storage/IDrawerGroup.java new file mode 100644 index 00000000..1f1eefef --- /dev/null +++ b/src/api/java/com/jaquadro/minecraft/storagedrawers/api/storage/IDrawerGroup.java @@ -0,0 +1,25 @@ +package com.jaquadro.minecraft.storagedrawers.api.storage; + +import com.jaquadro.minecraft.storagedrawers.api.inventory.IDrawerInventory; + +public interface IDrawerGroup +{ + /** + * Gets the number of drawers contained within this group. + */ + int getDrawerCount (); + + /** + * Gets the drawer at the given slot within this group. + */ + IDrawer getDrawer (int slot); + + /** + * Gets whether the drawer in the given slot is usable. + */ + boolean isDrawerEnabled (int slot); + + IDrawerInventory getDrawerInventory (); + + boolean markDirtyIfNeeded (); +} diff --git a/src/api/java/com/jaquadro/minecraft/storagedrawers/api/storage/IDrawerGroupInteractive.java b/src/api/java/com/jaquadro/minecraft/storagedrawers/api/storage/IDrawerGroupInteractive.java new file mode 100644 index 00000000..bd8a0ea7 --- /dev/null +++ b/src/api/java/com/jaquadro/minecraft/storagedrawers/api/storage/IDrawerGroupInteractive.java @@ -0,0 +1,15 @@ +package com.jaquadro.minecraft.storagedrawers.api.storage; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; + +public interface IDrawerGroupInteractive extends IDrawerGroup +{ + ItemStack takeItemsFromSlot (int slot, int count); + + int putItemsIntoSlot (int slot, ItemStack stack, int count); + + int interactPutCurrentItemIntoSlot (int slot, EntityPlayer player); + + int interactPutCurrentInventoryIntoSlot (int slot, EntityPlayer player); +} diff --git a/src/api/java/com/jaquadro/minecraft/storagedrawers/api/storage/IFractionalDrawer.java b/src/api/java/com/jaquadro/minecraft/storagedrawers/api/storage/IFractionalDrawer.java new file mode 100644 index 00000000..bd87a808 --- /dev/null +++ b/src/api/java/com/jaquadro/minecraft/storagedrawers/api/storage/IFractionalDrawer.java @@ -0,0 +1,28 @@ +package com.jaquadro.minecraft.storagedrawers.api.storage; + +/** + * Represents a drawer with items that are a fractional component of another item within the drawer group. Compacting + * Drawers are a primary example of this drawer type. + */ +public interface IFractionalDrawer extends IDrawer +{ + /** + * Gets the storage ratio between the held item and the most compressed item within the drawer group. + * + * For example, most ingots have a conversion rate of 9 compared to metal blocks, and nuggets a rate of 81. + * Actual conversion rates are implementation-defined. + */ + int getConversionRate (); + + /** + * Gets the number of items left in the drawer if the maximum number of equivalent compressed items had been removed. + * The equivalency is determined by the next compression tier, and not necessarily the conversion rate. + */ + int getStoredItemRemainder (); + + /** + * Gets whether or not the stored item represents the smallest granularity of material that can be stored within + * the drawer group. + */ + boolean isSmallestUnit (); +} diff --git a/src/api/java/com/jaquadro/minecraft/storagedrawers/api/storage/INetworked.java b/src/api/java/com/jaquadro/minecraft/storagedrawers/api/storage/INetworked.java new file mode 100644 index 00000000..fba20d40 --- /dev/null +++ b/src/api/java/com/jaquadro/minecraft/storagedrawers/api/storage/INetworked.java @@ -0,0 +1,5 @@ +package com.jaquadro.minecraft.storagedrawers.api.storage; + +public interface INetworked +{ +} diff --git a/src/api/java/com/jaquadro/minecraft/storagedrawers/api/storage/attribute/ILockable.java b/src/api/java/com/jaquadro/minecraft/storagedrawers/api/storage/attribute/ILockable.java new file mode 100644 index 00000000..7645c83a --- /dev/null +++ b/src/api/java/com/jaquadro/minecraft/storagedrawers/api/storage/attribute/ILockable.java @@ -0,0 +1,21 @@ +package com.jaquadro.minecraft.storagedrawers.api.storage.attribute; + +public interface ILockable +{ + /** + * Gets whether or not a drawer or group is locked for the given lock attribute. + */ + boolean isLocked (LockAttribute attr); + + /** + * Gets whether or not the lock state can be changed for the given lock attribute. + * If this method returns false, isLocked may still return true. + */ + boolean canLock (LockAttribute attr); + + /** + * Sets the lock state of a drawer or group for the given lock attribute. + * If canLock returns false, this is a no-op. + */ + void setLocked (LockAttribute attr, boolean isLocked); +} diff --git a/src/api/java/com/jaquadro/minecraft/storagedrawers/api/storage/attribute/IShroudable.java b/src/api/java/com/jaquadro/minecraft/storagedrawers/api/storage/attribute/IShroudable.java new file mode 100644 index 00000000..b7f0bf03 --- /dev/null +++ b/src/api/java/com/jaquadro/minecraft/storagedrawers/api/storage/attribute/IShroudable.java @@ -0,0 +1,16 @@ +package com.jaquadro.minecraft.storagedrawers.api.storage.attribute; + +public interface IShroudable +{ + /** + * Gets whether or not the drawer has the shrouded attribute. + * The shrouded attribute instructs the drawer to not render its item label. + */ + boolean isShrouded (); + + /** + * Sets whether or not the drawer is currently shrouded. + * @return false if the operation is not supported, true otherwise. + */ + boolean setIsShrouded (boolean state); +} diff --git a/src/api/java/com/jaquadro/minecraft/storagedrawers/api/storage/attribute/IVoidable.java b/src/api/java/com/jaquadro/minecraft/storagedrawers/api/storage/attribute/IVoidable.java new file mode 100644 index 00000000..9fc58063 --- /dev/null +++ b/src/api/java/com/jaquadro/minecraft/storagedrawers/api/storage/attribute/IVoidable.java @@ -0,0 +1,9 @@ +package com.jaquadro.minecraft.storagedrawers.api.storage.attribute; + +public interface IVoidable +{ + /** + * Gets whether or not the drawer has a voiding attribute. + */ + boolean isVoid (); +} diff --git a/src/api/java/com/jaquadro/minecraft/storagedrawers/api/storage/attribute/LockAttribute.java b/src/api/java/com/jaquadro/minecraft/storagedrawers/api/storage/attribute/LockAttribute.java new file mode 100644 index 00000000..cb726b41 --- /dev/null +++ b/src/api/java/com/jaquadro/minecraft/storagedrawers/api/storage/attribute/LockAttribute.java @@ -0,0 +1,37 @@ +package com.jaquadro.minecraft.storagedrawers.api.storage.attribute; + +import java.util.EnumSet; + +public enum LockAttribute +{ + LOCK_POPULATED, + LOCK_EMPTY; + + public int getFlagValue () { + return 1 << ordinal(); + } + + public static int getBitfield (EnumSet attributes) { + int value = 0; + if (attributes == null) + return value; + + for (LockAttribute attr : attributes) + value |= attr.getFlagValue(); + + return value; + } + + public static EnumSet getEnumSet (int bitfield) { + if (bitfield == 0) + return null; + + EnumSet set = EnumSet.noneOf(LockAttribute.class); + for (LockAttribute attr : values()) { + if ((bitfield & attr.getFlagValue()) != 0) + set.add(attr); + } + + return set; + } +} diff --git a/src/main/java/cofh/api/CoFHAPIProps.java b/src/main/java/cofh/api/CoFHAPIProps.java index 775d8d22..06b5b183 100644 --- a/src/main/java/cofh/api/CoFHAPIProps.java +++ b/src/main/java/cofh/api/CoFHAPIProps.java @@ -6,6 +6,6 @@ public class CoFHAPIProps { } - public static final String VERSION = "1.7.10R1.0.3"; + public static final String VERSION = "1.7.10R1.0.12"; } diff --git a/src/main/java/cofh/api/block/IBlockAppearance.java b/src/main/java/cofh/api/block/IBlockAppearance.java new file mode 100644 index 00000000..558d348e --- /dev/null +++ b/src/main/java/cofh/api/block/IBlockAppearance.java @@ -0,0 +1,51 @@ +package cofh.api.block; + +import net.minecraft.block.Block; +import net.minecraft.world.IBlockAccess; +import net.minecraftforge.common.util.ForgeDirection; + +/** + * Implement this interface on blocks that can mimic the appearance of other blocks. Note that this is meant to be available server-side, so ensure the code is + * server-safe and doesn't use client-side code. + * + */ +public interface IBlockAppearance { + + /** + * This function returns the block that is being shown on a given side. + * + * @param world + * Reference to the world. + * @param x + * X coordinate of the block. + * @param y + * Y coordinate of the block. + * @param z + * Z coordinate of the block. + * @param side + * The side of the block. + */ + public Block getVisualBlock(IBlockAccess world, int x, int y, int z, ForgeDirection side); + + /** + * This function returns metadata of the block that is being shown on a given side. + * + * @param world + * Reference to the world. + * @param x + * X coordinate of the block. + * @param y + * Y coordinate of the block. + * @param z + * Z coordinate of the block. + * @param side + * The side of the block. + */ + public int getVisualMeta(IBlockAccess world, int x, int y, int z, ForgeDirection side); + + /** + * This function returns whether the block's renderer will visually connect to other blocks implementing IBlockAppearance. + */ + public boolean supportsVisualConnections(); + +} diff --git a/src/main/java/cofh/api/block/IBlockConfigGui.java b/src/main/java/cofh/api/block/IBlockConfigGui.java new file mode 100644 index 00000000..9e00c87d --- /dev/null +++ b/src/main/java/cofh/api/block/IBlockConfigGui.java @@ -0,0 +1,31 @@ +package cofh.api.block; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.world.IBlockAccess; +import net.minecraftforge.common.util.ForgeDirection; + +/** + * Implement this interface on blocks which have a GUI that needs a tool (e.g., multimeter) to open. + * + */ +public interface IBlockConfigGui { + + /** + * This function will open a GUI if the player has permission. + * + * @param world + * Reference to the world. + * @param x + * X coordinate of the block. + * @param y + * Y coordinate of the block. + * @param z + * Z coordinate of the block. + * @param side + * The side of the block. + * @param player + * Player doing the configuring. + * @return True if the GUI was opened. + */ + public boolean openConfigGui(IBlockAccess world, int x, int y, int z, ForgeDirection side, EntityPlayer player); +} diff --git a/src/main/java/cofh/api/block/IBlockDebug.java b/src/main/java/cofh/api/block/IBlockDebug.java index 091831c9..dc02f7f7 100644 --- a/src/main/java/cofh/api/block/IBlockDebug.java +++ b/src/main/java/cofh/api/block/IBlockDebug.java @@ -6,15 +6,15 @@ import net.minecraftforge.common.util.ForgeDirection; /** * Implement this interface on blocks which have some debug method which can be activated via a tool or other means. - * + * * @author King Lemming - * + * */ public interface IBlockDebug { /** * This function debugs a block. - * + * * @param world * Reference to the world. * @param x diff --git a/src/main/java/cofh/api/block/IBlockInfo.java b/src/main/java/cofh/api/block/IBlockInfo.java index 12d96f0b..8494243c 100644 --- a/src/main/java/cofh/api/block/IBlockInfo.java +++ b/src/main/java/cofh/api/block/IBlockInfo.java @@ -12,15 +12,15 @@ import net.minecraftforge.common.util.ForgeDirection; /** * Implement this interface on blocks which can provide information about themselves. If the block contains Tile Entities, then it is recommended that this * function serve as a passthrough for {@link ITileInfo}. - * + * * @author King Lemming - * + * */ public interface IBlockInfo { /** * This function appends information to a list provided to it. - * + * * @param world * Reference to the world. * @param x diff --git a/src/main/java/cofh/api/block/IDismantleable.java b/src/main/java/cofh/api/block/IDismantleable.java index 0e530a65..12c09e3a 100644 --- a/src/main/java/cofh/api/block/IDismantleable.java +++ b/src/main/java/cofh/api/block/IDismantleable.java @@ -8,9 +8,9 @@ import net.minecraft.world.World; /** * Implemented on Blocks which have some method of being instantly dismantled. - * + * * @author King Lemming - * + * */ public interface IDismantleable { diff --git a/src/main/java/cofh/api/energy/EnergyStorage.java b/src/main/java/cofh/api/energy/EnergyStorage.java index 1674c189..25e0126a 100644 --- a/src/main/java/cofh/api/energy/EnergyStorage.java +++ b/src/main/java/cofh/api/energy/EnergyStorage.java @@ -4,9 +4,9 @@ import net.minecraft.nbt.NBTTagCompound; /** * Reference implementation of {@link IEnergyStorage}. Use/extend this or implement your own. - * + * * @author King Lemming - * + * */ public class EnergyStorage implements IEnergyStorage { @@ -89,7 +89,7 @@ public class EnergyStorage implements IEnergyStorage { /** * This function is included to allow for server -> client sync. Do not call this externally to the containing Tile Entity, as not all IEnergyHandlers * are guaranteed to have it. - * + * * @param energy */ public void setEnergyStored(int energy) { @@ -106,7 +106,7 @@ public class EnergyStorage implements IEnergyStorage { /** * This function is included to allow the containing tile to directly and efficiently modify the energy contained in the EnergyStorage. Do not rely on this * externally, as not all IEnergyHandlers are guaranteed to have it. - * + * * @param energy */ public void modifyEnergyStored(int energy) { diff --git a/src/main/java/cofh/api/energy/IEnergyConnection.java b/src/main/java/cofh/api/energy/IEnergyConnection.java index 79bdf77a..301271e5 100644 --- a/src/main/java/cofh/api/energy/IEnergyConnection.java +++ b/src/main/java/cofh/api/energy/IEnergyConnection.java @@ -7,9 +7,9 @@ import net.minecraftforge.common.util.ForgeDirection; * accept it; otherwise just use IEnergyHandler. *

* Note that {@link IEnergyHandler} is an extension of this. - * + * * @author King Lemming - * + * */ public interface IEnergyConnection { diff --git a/src/main/java/cofh/api/energy/IEnergyContainerItem.java b/src/main/java/cofh/api/energy/IEnergyContainerItem.java index c28455b1..3ef72576 100644 --- a/src/main/java/cofh/api/energy/IEnergyContainerItem.java +++ b/src/main/java/cofh/api/energy/IEnergyContainerItem.java @@ -6,15 +6,15 @@ import net.minecraft.item.ItemStack; * Implement this interface on Item classes that support external manipulation of their internal energy storages. *

* A reference implementation is provided {@link ItemEnergyContainer}. - * + * * @author King Lemming - * + * */ public interface IEnergyContainerItem { /** * Adds energy to a container item. Returns the quantity of energy that was accepted. This should always return 0 if the item cannot be externally charged. - * + * * @param container * ItemStack to be charged. * @param maxReceive @@ -28,7 +28,7 @@ public interface IEnergyContainerItem { /** * Removes energy from a container item. Returns the quantity of energy that was removed. This should always return 0 if the item cannot be externally * discharged. - * + * * @param container * ItemStack to be discharged. * @param maxExtract diff --git a/src/main/java/cofh/api/energy/IEnergyHandler.java b/src/main/java/cofh/api/energy/IEnergyHandler.java index 22f2dbc6..6a4600a4 100644 --- a/src/main/java/cofh/api/energy/IEnergyHandler.java +++ b/src/main/java/cofh/api/energy/IEnergyHandler.java @@ -42,7 +42,6 @@ public interface IEnergyHandler extends IEnergyProvider, IEnergyReceiver { @Override int extractEnergy(ForgeDirection from, int maxExtract, boolean simulate); - /** * Returns the amount of energy currently stored. */ diff --git a/src/main/java/cofh/api/energy/IEnergyStorage.java b/src/main/java/cofh/api/energy/IEnergyStorage.java index bc206560..414b2656 100644 --- a/src/main/java/cofh/api/energy/IEnergyStorage.java +++ b/src/main/java/cofh/api/energy/IEnergyStorage.java @@ -5,15 +5,15 @@ package cofh.api.energy; * This is not to be implemented on TileEntities. This is for internal use only. *

* A reference implementation can be found at {@link EnergyStorage}. - * + * * @author King Lemming - * + * */ public interface IEnergyStorage { /** * Adds energy to the storage. Returns quantity of energy that was accepted. - * + * * @param maxReceive * Maximum amount of energy to be inserted. * @param simulate @@ -24,7 +24,7 @@ public interface IEnergyStorage { /** * Removes energy from the storage. Returns quantity of energy that was removed. - * + * * @param maxExtract * Maximum amount of energy to be extracted. * @param simulate diff --git a/src/main/java/cofh/api/energy/ItemEnergyContainer.java b/src/main/java/cofh/api/energy/ItemEnergyContainer.java index 055ae45b..2d3659cb 100644 --- a/src/main/java/cofh/api/energy/ItemEnergyContainer.java +++ b/src/main/java/cofh/api/energy/ItemEnergyContainer.java @@ -6,9 +6,9 @@ import net.minecraft.nbt.NBTTagCompound; /** * Reference implementation of {@link IEnergyContainerItem}. Use/extend this or implement your own. - * + * * @author King Lemming - * + * */ public class ItemEnergyContainer extends Item implements IEnergyContainerItem { diff --git a/src/main/java/cofh/api/inventory/IInventoryHandler.java b/src/main/java/cofh/api/inventory/IInventoryHandler.java index 4cb753c9..344e8153 100644 --- a/src/main/java/cofh/api/inventory/IInventoryHandler.java +++ b/src/main/java/cofh/api/inventory/IInventoryHandler.java @@ -7,18 +7,18 @@ import net.minecraftforge.common.util.ForgeDirection; /** * Implement this interface on TileEntities which should handle items. - * + * * A reference implementation is provided {@link TileInventoryHandler}. - * + * * @author King Lemming - * + * */ public interface IInventoryHandler extends IInventoryConnection { /** * Insert an ItemStack into the IInventoryHandler, internal distribution is left entirely to the IInventoryHandler. This returns what is remaining of the * original stack - a null return means that the entire stack was accepted! - * + * * @param from * Orientation the item is inserted from. * @param item @@ -32,7 +32,7 @@ public interface IInventoryHandler extends IInventoryConnection { /** * Extract an ItemStack from an IInventoryHandler, internal distribution is left entirely to the IInventoryHandler. This returns the resulting stack - a * null return means that nothing was extracted! - * + * * @param from * Orientation the item is extracted from. * @param item @@ -47,7 +47,7 @@ public interface IInventoryHandler extends IInventoryConnection { /** * Extract an ItemStack from an IInventoryHandler, internal distribution is left entirely to the IInventoryHandler. This returns the resulting stack - a * null return means that nothing was extracted! - * + * * @param from * Orientation the item is extracted from. * @param maxExtract diff --git a/src/main/java/cofh/api/inventory/IInventoryRetainer.java b/src/main/java/cofh/api/inventory/IInventoryRetainer.java index 30309fb2..df79681e 100644 --- a/src/main/java/cofh/api/inventory/IInventoryRetainer.java +++ b/src/main/java/cofh/api/inventory/IInventoryRetainer.java @@ -2,9 +2,9 @@ package cofh.api.inventory; /** * Marks a block which will retain its inventory when broken. - * + * * @author King Lemming - * + * */ public interface IInventoryRetainer { diff --git a/src/main/java/cofh/api/item/IAugmentItem.java b/src/main/java/cofh/api/item/IAugmentItem.java index 497bace9..e17fa8de 100644 --- a/src/main/java/cofh/api/item/IAugmentItem.java +++ b/src/main/java/cofh/api/item/IAugmentItem.java @@ -8,7 +8,7 @@ public interface IAugmentItem { /** * Get the augmentation level for a given Augment and Augment Type. - * + * * @param stack * ItemStack representing the Augment. * @param type @@ -19,7 +19,7 @@ public interface IAugmentItem { /** * Get the Augment Types for a given Augment. Set ensure that there are no duplicates. - * + * * @param stack * ItemStack representing the Augment. * @return Set of the Augmentation Types. Should return an empty set if there are none (but this would be really stupid to make). DO NOT RETURN NULL. diff --git a/src/main/java/cofh/api/item/IEmpowerableItem.java b/src/main/java/cofh/api/item/IEmpowerableItem.java index f77c71f6..42877110 100644 --- a/src/main/java/cofh/api/item/IEmpowerableItem.java +++ b/src/main/java/cofh/api/item/IEmpowerableItem.java @@ -6,9 +6,9 @@ import net.minecraft.item.ItemStack; /** * Implement this interface on Item classes which may be "Empowered" - what that means is completely up to you. This just provides a uniform way of dealing with * them. - * + * * @author King Lemming - * + * */ public interface IEmpowerableItem { @@ -19,7 +19,7 @@ public interface IEmpowerableItem { /** * Attempt to set the empowered state of the item. - * + * * @param stack * ItemStack to be empowered/disempowered. * @param state @@ -30,7 +30,7 @@ public interface IEmpowerableItem { /** * Callback method for reacting to a state change. Useful in KeyBinding handlers. - * + * * @param player * Player holding the item, if applicable. * @param stack diff --git a/src/main/java/cofh/api/item/IInventoryContainerItem.java b/src/main/java/cofh/api/item/IInventoryContainerItem.java index b87896cc..adadf10a 100644 --- a/src/main/java/cofh/api/item/IInventoryContainerItem.java +++ b/src/main/java/cofh/api/item/IInventoryContainerItem.java @@ -4,11 +4,11 @@ import net.minecraft.item.ItemStack; /** * Implement this interface on Item classes that are themselves inventories. - * + * * A reference implementation is provided {@link ItemInventoryContainer}. - * + * * @author King Lemming - * + * */ public interface IInventoryContainerItem { diff --git a/src/main/java/cofh/api/item/IMultiModeItem.java b/src/main/java/cofh/api/item/IMultiModeItem.java new file mode 100644 index 00000000..c236bbfb --- /dev/null +++ b/src/main/java/cofh/api/item/IMultiModeItem.java @@ -0,0 +1,56 @@ +package cofh.api.item; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; + +/** + * Implement this interface on Item classes which may be "Empowered" - what that means is completely up to you. This just provides a uniform way of dealing with + * them. + * + * @author King Lemming + * + */ +public interface IMultiModeItem { + + /** + * Get the current mode of an item. + */ + int getMode(ItemStack stack); + + /** + * Attempt to set the empowered state of the item. + * + * @param stack + * ItemStack to set the mode on. + * @param mode + * Desired mode. + * @return TRUE if the operation was successful, FALSE if it was not. + */ + boolean setMode(ItemStack stack, int mode); + + /** + * Increment the current mode of an item. + */ + boolean incrMode(ItemStack stack); + + /** + * Decrement the current mode of an item. + */ + boolean decrMode(ItemStack stack); + + /** + * Returns the number of possible modes. + */ + int getNumModes(ItemStack stack); + + /** + * Callback method for reacting to a state change. Useful in KeyBinding handlers. + * + * @param player + * Player holding the item, if applicable. + * @param stack + * The item being held. + */ + void onModeChange(EntityPlayer player, ItemStack stack); + +} diff --git a/src/main/java/cofh/api/item/IToolHammer.java b/src/main/java/cofh/api/item/IToolHammer.java index 1ffefe72..f7b3918f 100644 --- a/src/main/java/cofh/api/item/IToolHammer.java +++ b/src/main/java/cofh/api/item/IToolHammer.java @@ -10,7 +10,7 @@ public interface IToolHammer { /** * Called to ensure that the wrench can be used. - * + * * @param item * The itemstack for the tool. Not required to match equipped item (e.g., multi-tools that contain other tools) * @param user @@ -27,7 +27,7 @@ public interface IToolHammer { /** * Callback for when the tool has been used reactively. - * + * * @param item * The ItemStack for the tool. Not required to match equipped item (e.g., multi-tools that contain other tools) * @param user diff --git a/src/main/java/cofh/api/tileentity/IAugmentable.java b/src/main/java/cofh/api/tileentity/IAugmentable.java index 735ade14..5a99c598 100644 --- a/src/main/java/cofh/api/tileentity/IAugmentable.java +++ b/src/main/java/cofh/api/tileentity/IAugmentable.java @@ -4,9 +4,9 @@ import net.minecraft.item.ItemStack; /** * Implemented on objects which support Augments. - * + * * @author King Lemming - * + * */ public interface IAugmentable { diff --git a/src/main/java/cofh/api/tileentity/IEnergyInfo.java b/src/main/java/cofh/api/tileentity/IEnergyInfo.java index 72d553b3..6277a34c 100644 --- a/src/main/java/cofh/api/tileentity/IEnergyInfo.java +++ b/src/main/java/cofh/api/tileentity/IEnergyInfo.java @@ -2,11 +2,11 @@ package cofh.api.tileentity; /** * Implement this interface on objects which can report information about their energy usage. - * + * * This is used for reporting purposes - Energy transactions are handled through IEnergyHandler! - * + * * @author King Lemming - * + * */ public interface IEnergyInfo { diff --git a/src/main/java/cofh/api/tileentity/IPlacedTile.java b/src/main/java/cofh/api/tileentity/IPlacedTile.java deleted file mode 100644 index df54a969..00000000 --- a/src/main/java/cofh/api/tileentity/IPlacedTile.java +++ /dev/null @@ -1,13 +0,0 @@ -package cofh.api.tileentity; - -/** - * Implement this interface on Tile Entities which need to know when they are placed into the world. - * - * @author Zeldo - * - */ -public interface IPlacedTile { - - public void tilePlaced(); - -} diff --git a/src/main/java/cofh/api/tileentity/IPortableData.java b/src/main/java/cofh/api/tileentity/IPortableData.java index 13134dbd..81d42964 100644 --- a/src/main/java/cofh/api/tileentity/IPortableData.java +++ b/src/main/java/cofh/api/tileentity/IPortableData.java @@ -5,18 +5,18 @@ import net.minecraft.nbt.NBTTagCompound; /** * Implement this interface on Tile Entities which can write a limited amount of data about themselves. - * + * * This is typically for the purposes of being transferred to a similar tile entity. - * + * * @author King Lemming - * + * */ public interface IPortableData { /** * Data identifier of the Tile Entity/Block. Used for display as well as verification purposes. Tiles with completely interchangeable data should return the * same type. - * + * * @return */ String getDataType(); diff --git a/src/main/java/cofh/api/tileentity/IReconfigurableFacing.java b/src/main/java/cofh/api/tileentity/IReconfigurableFacing.java index 40efe7c3..e6972091 100644 --- a/src/main/java/cofh/api/tileentity/IReconfigurableFacing.java +++ b/src/main/java/cofh/api/tileentity/IReconfigurableFacing.java @@ -2,11 +2,11 @@ package cofh.api.tileentity; /** * Implement this interface on Tile Entities which allow for reconfiguration of their facing. - * + * * Coordination with the containing block is required. - * + * * @author King Lemming - * + * */ public interface IReconfigurableFacing { @@ -22,14 +22,14 @@ public interface IReconfigurableFacing { /** * Attempt to rotate the block. Arbitrary based on implementation. - * + * * @return True if rotation was successful, false otherwise. */ boolean rotateBlock(); /** * Set the facing of the block. - * + * * @param side * The side to set the facing to. * @return True if the facing was set, false otherwise. diff --git a/src/main/java/cofh/api/tileentity/IReconfigurableSides.java b/src/main/java/cofh/api/tileentity/IReconfigurableSides.java index 79c0f5bc..e3a708dd 100644 --- a/src/main/java/cofh/api/tileentity/IReconfigurableSides.java +++ b/src/main/java/cofh/api/tileentity/IReconfigurableSides.java @@ -2,17 +2,17 @@ package cofh.api.tileentity; /** * Implement this interface on Tile Entities which allow for reconfiguration of their sides. - * + * * Coordination with the containing block is required. - * + * * @author King Lemming - * + * */ public interface IReconfigurableSides { /** * Decrement the config for a given side. - * + * * @param side * The side to decrement. * @return True if config was changed, false otherwise. @@ -21,7 +21,7 @@ public interface IReconfigurableSides { /** * Increment the config for a given side. - * + * * @param side * The side to decrement. * @return True if config was changed, false otherwise. @@ -30,7 +30,7 @@ public interface IReconfigurableSides { /** * Set the config for a given side. - * + * * @param side * The side to set. * @param config @@ -41,7 +41,7 @@ public interface IReconfigurableSides { /** * Reset configs on all sides to their base values. - * + * * @return True if reset was successful, false otherwise. */ boolean resetSides(); diff --git a/src/main/java/cofh/api/tileentity/IRedstoneCache.java b/src/main/java/cofh/api/tileentity/IRedstoneCache.java index f1254d8d..1d873e53 100644 --- a/src/main/java/cofh/api/tileentity/IRedstoneCache.java +++ b/src/main/java/cofh/api/tileentity/IRedstoneCache.java @@ -2,11 +2,11 @@ package cofh.api.tileentity; /** * Implement this interface on Tile Entities which cache their redstone status. - * + * * Note that {@link IRedstoneControl} is an extension of this. - * + * * @author King Lemming - * + * */ public interface IRedstoneCache { diff --git a/src/main/java/cofh/api/tileentity/IRedstoneControl.java b/src/main/java/cofh/api/tileentity/IRedstoneControl.java index 11060325..f868affb 100644 --- a/src/main/java/cofh/api/tileentity/IRedstoneControl.java +++ b/src/main/java/cofh/api/tileentity/IRedstoneControl.java @@ -3,9 +3,9 @@ package cofh.api.tileentity; /** * Implement this interface on Tile Entities which have Redstone Control functionality. This means that a tile can be set to ignore redstone entirely, or * respond to a low or high redstone state. - * + * * @author King Lemming - * + * */ public interface IRedstoneControl extends IRedstoneCache { diff --git a/src/main/java/cofh/api/tileentity/ISecurable.java b/src/main/java/cofh/api/tileentity/ISecurable.java index 06018fa6..fd29f1e6 100644 --- a/src/main/java/cofh/api/tileentity/ISecurable.java +++ b/src/main/java/cofh/api/tileentity/ISecurable.java @@ -1,18 +1,22 @@ package cofh.api.tileentity; +import com.mojang.authlib.GameProfile; + +import net.minecraft.entity.player.EntityPlayer; + /** * Implement this interface on Tile Entities which can have access restrictions. - * + * * @author King Lemming - * + * */ public interface ISecurable { /** * Enum for Access Modes - Restricted is Friends Only, Private is Owner only. - * + * * @author King Lemming - * + * */ public static enum AccessMode { PUBLIC, RESTRICTED, PRIVATE; @@ -47,10 +51,14 @@ public interface ISecurable { boolean setOwnerName(String name); + boolean setOwner(GameProfile name); + AccessMode getAccess(); String getOwnerName(); - boolean canPlayerAccess(String name); + GameProfile getOwner(); + + boolean canPlayerAccess(EntityPlayer player); } diff --git a/src/main/java/cofh/api/tileentity/ISidedTexture.java b/src/main/java/cofh/api/tileentity/ISidedTexture.java index 1d5884f4..20be6dd6 100644 --- a/src/main/java/cofh/api/tileentity/ISidedTexture.java +++ b/src/main/java/cofh/api/tileentity/ISidedTexture.java @@ -5,15 +5,15 @@ import net.minecraft.util.IIcon; /** * Implement this interface on Tile Entities which can change their block's texture based on the current render pass. The block must defer the call to its Tile * Entity. - * + * * @author Zeldo Kavira - * + * */ public interface ISidedTexture { /** * Returns the icon to use for a given side and render pass. - * + * * @param side * Block side to get the texture for. * @param pass diff --git a/src/main/java/cofh/api/tileentity/ITileInfo.java b/src/main/java/cofh/api/tileentity/ITileInfo.java index f040694a..87e4ce8f 100644 --- a/src/main/java/cofh/api/tileentity/ITileInfo.java +++ b/src/main/java/cofh/api/tileentity/ITileInfo.java @@ -8,15 +8,15 @@ import net.minecraftforge.common.util.ForgeDirection; /** * Implement this interface on Tile Entities which can provide information about themselves. - * + * * @author King Lemming - * + * */ public interface ITileInfo { /** * This function appends information to a list provided to it. - * + * * @param info * The list that the information should be appended to. * @param side diff --git a/src/main/java/cofh/api/transport/IEnderDestination.java b/src/main/java/cofh/api/transport/IEnderDestination.java new file mode 100644 index 00000000..30153c0d --- /dev/null +++ b/src/main/java/cofh/api/transport/IEnderDestination.java @@ -0,0 +1,17 @@ +package cofh.api.transport; + +public interface IEnderDestination extends IEnderAttuned { + + public boolean isNotValid(); + + public int x(); + public int y(); + public int z(); + public int dimension(); + + public int getDestination(); + + public boolean setDestination(int frequency); + + public boolean clearDestination(); +} diff --git a/src/main/java/cofh/api/transport/IEnderEnergyHandler.java b/src/main/java/cofh/api/transport/IEnderEnergyHandler.java index 0886be76..892a5c66 100644 --- a/src/main/java/cofh/api/transport/IEnderEnergyHandler.java +++ b/src/main/java/cofh/api/transport/IEnderEnergyHandler.java @@ -2,9 +2,9 @@ package cofh.api.transport; /** * This interface is implemented on Ender Attuned objects which can receive Energy (Redstone Flux). - * + * * @author King Lemming - * + * */ public interface IEnderEnergyHandler extends IEnderAttuned { @@ -15,7 +15,7 @@ public interface IEnderEnergyHandler extends IEnderAttuned { /** * This should be checked to see if the Ender Attuned object can currently receive energy (Redstone Flux). - * + * * Note: In practice, this can (and should) be used to ensure that something does not send to itself. */ boolean canReceiveEnergy(); @@ -23,7 +23,7 @@ public interface IEnderEnergyHandler extends IEnderAttuned { /** * This tells the Ender Attuned object to receive energy. This returns the amount remaining, *not* the amount received - a return of 0 means that all energy * was received! - * + * * @param energy * Amount of energy to be received. * @param simulate diff --git a/src/main/java/cofh/api/transport/IEnderFluidHandler.java b/src/main/java/cofh/api/transport/IEnderFluidHandler.java index 3927fe1b..2f509e81 100644 --- a/src/main/java/cofh/api/transport/IEnderFluidHandler.java +++ b/src/main/java/cofh/api/transport/IEnderFluidHandler.java @@ -4,9 +4,9 @@ import net.minecraftforge.fluids.FluidStack; /** * This interface is implemented on Ender Attuned objects which can receive Fluid. - * + * * @author King Lemming - * + * */ public interface IEnderFluidHandler extends IEnderAttuned { @@ -17,7 +17,7 @@ public interface IEnderFluidHandler extends IEnderAttuned { /** * This should be checked to see if the Ender Attuned object can currently receive a FluidStack. - * + * * Note: In practice, this can (and should) be used to ensure that something does not send to itself. */ boolean canReceiveFluid(); @@ -25,7 +25,7 @@ public interface IEnderFluidHandler extends IEnderAttuned { /** * This tells the Ender Attuned object to receive a FluidStack. This returns what remains of the original stack, *not* the amount received - a null return * means that the entire stack was received! - * + * * @param fluid * FluidStack to be received. * @param simulate diff --git a/src/main/java/cofh/api/transport/IEnderItemHandler.java b/src/main/java/cofh/api/transport/IEnderItemHandler.java index 2944a001..d5dad8f3 100644 --- a/src/main/java/cofh/api/transport/IEnderItemHandler.java +++ b/src/main/java/cofh/api/transport/IEnderItemHandler.java @@ -4,9 +4,9 @@ import net.minecraft.item.ItemStack; /** * This interface is implemented on Ender Attuned objects which can receive Items. - * + * * @author King Lemming - * + * */ public interface IEnderItemHandler extends IEnderAttuned { @@ -17,7 +17,7 @@ public interface IEnderItemHandler extends IEnderAttuned { /** * This should be checked to see if the Ender Attuned object can currently receive an ItemStack. - * + * * Note: In practice, this can (and should) be used to ensure that something does not send to itself. */ boolean canReceiveItems(); @@ -25,10 +25,10 @@ public interface IEnderItemHandler extends IEnderAttuned { /** * This tells the Ender Attuned object to receive an ItemStack. This returns what remains of the original stack, *not* the amount received - a null return * means that the entire stack was received! - * + * * This function does not support simulation because Inventory manipulation in Minecraft is an absolute mess and it would be a computational liability to do * so. - * + * * @param item * ItemStack to be received. * @return An ItemStack representing how much is remaining. diff --git a/src/main/java/cofh/api/transport/IItemDuct.java b/src/main/java/cofh/api/transport/IItemDuct.java index 4c50c856..67338346 100644 --- a/src/main/java/cofh/api/transport/IItemDuct.java +++ b/src/main/java/cofh/api/transport/IItemDuct.java @@ -5,16 +5,16 @@ import net.minecraftforge.common.util.ForgeDirection; /** * This interface is implemented on ItemDucts. Use it to attempt to eject items into an entry point. - * + * * @author Zeldo Kavira, King Lemming - * + * */ public interface IItemDuct { /** * Insert an ItemStack into the IItemDuct. Will only accept items if there is a valid destination. This returns what is remaining of the original stack - a * null return means that the entire stack was accepted/routed! - * + * * @param from * Orientation the item is inserted from. * @param item diff --git a/src/main/java/cofh/api/transport/RegistryEnderAttuned.java b/src/main/java/cofh/api/transport/RegistryEnderAttuned.java index 0f91b215..9213d95f 100644 --- a/src/main/java/cofh/api/transport/RegistryEnderAttuned.java +++ b/src/main/java/cofh/api/transport/RegistryEnderAttuned.java @@ -1,7 +1,5 @@ package cofh.api.transport; -import gnu.trove.map.hash.THashMap; - import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; @@ -10,23 +8,69 @@ import java.util.LinkedHashMap; import java.util.List; import java.util.Map; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.world.WorldServer; +import net.minecraftforge.common.DimensionManager; import net.minecraftforge.common.config.Configuration; public final class RegistryEnderAttuned { - public static Map>> inputItem = new THashMap>>(); - public static Map>> inputFluid = new THashMap>>(); - public static Map>> inputEnergy = new THashMap>>(); + public static Map>> inputItem = new HashMap>>(); + public static Map>> inputFluid = new HashMap>>(); + public static Map>> inputEnergy = new HashMap>>(); - public static Map>> outputItem = new THashMap>>(); - public static Map>> outputFluid = new THashMap>>(); - public static Map>> outputEnergy = new THashMap>>(); + public static Map>> outputItem = new HashMap>>(); + public static Map>> outputFluid = new HashMap>>(); + public static Map>> outputEnergy = new HashMap>>(); + + public static Map> outputTeleport = new HashMap>(); public static Configuration linkConf; public static Map clientFrequencyNames = new LinkedHashMap(); public static Map clientFrequencyNamesReversed = new LinkedHashMap(); + private static class EnderDestination { + + private final int dimension; + private final int x, y, z; + private IEnderDestination output; + + public EnderDestination(IEnderDestination output) { + + x = output.x(); + y = output.y(); + z = output.z(); + dimension = output.dimension(); + this.output = output; + } + + public boolean hasOutput() { + + return DimensionManager.isDimensionRegistered(dimension); + } + + public IEnderDestination getOutput() { + + if (output == null || output.isNotValid()) { + output = null; + if (!DimensionManager.isDimensionRegistered(dimension)) { + return null; + } + WorldServer world = DimensionManager.getWorld(dimension); + if (world == null) { + DimensionManager.initDimension(dimension); + world = DimensionManager.getWorld(dimension); + } + TileEntity te = world.getTileEntity(x, y, z); + if (te instanceof IEnderDestination) { + output = (IEnderDestination) te; + } + } + return output; + } + } + public static void clear() { inputItem.clear(); @@ -85,6 +129,31 @@ public final class RegistryEnderAttuned { return outputEnergy.get(theAttuned.getChannelString()).get(theAttuned.getFrequency()); } + public static boolean hasDestination(IEnderDestination theAttuned) { + + return hasDestination(theAttuned, true); + } + + public static boolean hasDestination(IEnderDestination theAttuned, boolean to) { + + Map map = outputTeleport.get(theAttuned.getChannelString()); + if (map == null) { + return false; + } + EnderDestination dest = map.get(to ? theAttuned.getDestination() : theAttuned.getFrequency()); + return dest == null ? false : dest.hasOutput(); + } + + public static IEnderDestination getDestination(IEnderDestination theAttuned) { + + Map map = outputTeleport.get(theAttuned.getChannelString()); + if (map == null) { + return null; + } + EnderDestination dest = map.get(theAttuned.getDestination()); + return dest == null ? null : dest.getOutput(); + } + /* HELPER FUNCTIONS */ public static void addItemHandler(IEnderItemHandler theAttuned) { @@ -164,6 +233,16 @@ public final class RegistryEnderAttuned { } } + public static void addDestination(IEnderDestination theAttuned) { + + if (!hasDestination(theAttuned, false)) { + if (outputTeleport.get(theAttuned.getChannelString()) == null) { + outputTeleport.put(theAttuned.getChannelString(), new HashMap()); + } + outputTeleport.get(theAttuned.getChannelString()).put(theAttuned.getFrequency(), new EnderDestination(theAttuned)); + } + } + public static void removeItemHandler(IEnderItemHandler theAttuned) { if (inputItem.get(theAttuned.getChannelString()) != null) { @@ -224,6 +303,23 @@ public final class RegistryEnderAttuned { } } + public static void removeDestination(IEnderDestination theAttuned) { + + Map map = outputTeleport.get(theAttuned.getChannelString()); + if (map == null) { + return; + } + EnderDestination dest = map.get(theAttuned.getFrequency()); + if (dest == null) { + return; + } + if (dest.dimension == theAttuned.dimension()) { + if (dest.x == theAttuned.x() && dest.y == theAttuned.x() && dest.z == theAttuned.x()) { + map.remove(theAttuned.getFrequency()); + } + } + } + public static void add(IEnderAttuned theAttuned) { if (theAttuned instanceof IEnderItemHandler) { @@ -235,6 +331,9 @@ public final class RegistryEnderAttuned { if (theAttuned instanceof IEnderEnergyHandler) { addEnergyHandler((IEnderEnergyHandler) theAttuned); } + if (theAttuned instanceof IEnderDestination) { + addDestination((IEnderDestination) theAttuned); + } } public static void remove(IEnderAttuned theAttuned) { @@ -248,6 +347,9 @@ public final class RegistryEnderAttuned { if (theAttuned instanceof IEnderEnergyHandler) { removeEnergyHandler((IEnderEnergyHandler) theAttuned); } + if (theAttuned instanceof IEnderDestination) { + removeDestination((IEnderDestination) theAttuned); + } } public static void sortClientNames() { diff --git a/src/main/java/crazypants/enderio/EnderIO.java b/src/main/java/crazypants/enderio/EnderIO.java index ae23c82f..9cc4bbb5 100644 --- a/src/main/java/crazypants/enderio/EnderIO.java +++ b/src/main/java/crazypants/enderio/EnderIO.java @@ -570,13 +570,15 @@ public class EnderIO { SkeletonHandler.registerSkeleton(this); } + MaterialRecipes.registerDependantOresInDictionary(); + EnderfaceRecipes.addRecipes(); MaterialRecipes.addRecipes(); ConduitRecipes.addRecipes(); MachineRecipes.addRecipes(); ItemRecipes.addRecipes(); TeleportRecipes.addRecipes(); - + proxy.load(); } @@ -587,16 +589,10 @@ public class EnderIO { //Regsiter the enchants Enchantments.getInstance(); - - MaterialRecipes.registerDependantOresInDictionary(); - + //This must be loaded before parsing the recipes so we get the preferred outputs OreDictionaryPreferences.loadConfig(); - MaterialRecipes.addOreDictionaryRecipes(); - MachineRecipes.addOreDictionaryRecipes(); - ItemRecipes.addOreDictionaryRecipes(); - CrusherRecipeManager.getInstance().loadRecipesFromConfig(); AlloyRecipeManager.getInstance().loadRecipesFromConfig(); SliceAndSpliceRecipeManager.getInstance().loadRecipesFromConfig(); diff --git a/src/main/java/crazypants/enderio/conduit/AbstractItemConduit.java b/src/main/java/crazypants/enderio/conduit/AbstractItemConduit.java index 52d83b9c..29f6c69e 100644 --- a/src/main/java/crazypants/enderio/conduit/AbstractItemConduit.java +++ b/src/main/java/crazypants/enderio/conduit/AbstractItemConduit.java @@ -5,6 +5,7 @@ import java.util.List; import net.minecraft.block.Block; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; @@ -15,6 +16,7 @@ import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; import com.enderio.core.common.util.BlockCoord; +import com.enderio.core.common.util.ItemUtil; import com.enderio.core.common.util.Util; import cpw.mods.fml.common.registry.GameRegistry; @@ -104,6 +106,31 @@ public abstract class AbstractItemConduit extends Item implements IConduitItem { } } return true; + } else { + // There's not really any good way to compare conduits... + IConduit existingConduit = bundle.getConduit(getBaseConduitType()); + ItemStack existingConduitAsItemStack = existingConduit.createItem(); + if (!ItemUtil.areStacksEqual(existingConduitAsItemStack, stack)) { + if (!world.isRemote) { + IConduit newConduit = createConduit(stack, player); + if (newConduit == null) { + System.out.println("AbstractItemConduit.onItemUse: Conduit null."); + return false; + } + bundle.removeConduit(existingConduit); + bundle.addConduit(newConduit); + if (!player.capabilities.isCreativeMode) { + stack.stackSize--; + for (ItemStack drop : existingConduit.getDrops()) { + EntityItem entityitem = new EntityItem(world, x + hitX, y + hitY, z + hitZ, drop); + entityitem.delayBeforeCanPickup = 10; + world.spawnEntityInWorld(entityitem); + } + } + } + return true; + } + } } } diff --git a/src/main/java/crazypants/enderio/conduit/BlockConduitBundle.java b/src/main/java/crazypants/enderio/conduit/BlockConduitBundle.java index 69ea5a4a..b162d116 100644 --- a/src/main/java/crazypants/enderio/conduit/BlockConduitBundle.java +++ b/src/main/java/crazypants/enderio/conduit/BlockConduitBundle.java @@ -964,6 +964,21 @@ public class BlockConduitBundle extends BlockEio implements IGuiHandler, IFacade return res; } + @Override + public Block getVisualBlock(IBlockAccess world, int x, int y, int z, ForgeDirection side) { + return getFacade(world, x, y, z, side.ordinal()); + } + + @Override + public int getVisualMeta(IBlockAccess world, int x, int y, int z, ForgeDirection side) { + return getFacadeMetadata(world, x, y, z, side.ordinal()); + } + + @Override + public boolean supportsVisualConnections() { + return true; + } + @Override public void onInputsChanged(World world, int x, int y, int z, ForgeDirection side, int[] inputValues) { IRedstoneConduit conduit = getRedstoneConduit(world, x, y, z); diff --git a/src/main/java/crazypants/enderio/conduit/ConduitRecipes.java b/src/main/java/crazypants/enderio/conduit/ConduitRecipes.java index b2f91d04..eea50252 100644 --- a/src/main/java/crazypants/enderio/conduit/ConduitRecipes.java +++ b/src/main/java/crazypants/enderio/conduit/ConduitRecipes.java @@ -16,12 +16,14 @@ import crazypants.enderio.conduit.item.filter.CopyFilterRecipe; import crazypants.enderio.conduit.me.MEUtil; import crazypants.enderio.config.Config; import crazypants.enderio.machine.MachineRecipeRegistry; -import crazypants.enderio.material.Alloy; import crazypants.enderio.material.BlockFusedQuartz; import crazypants.enderio.material.FrankenSkull; import crazypants.enderio.material.Material; import static crazypants.enderio.ModObject.blockPainter; +import static crazypants.enderio.material.Alloy.*; +import static crazypants.enderio.material.Material.*; +import static crazypants.util.RecipeUtil.addShaped; public class ConduitRecipes { @@ -29,62 +31,61 @@ public class ConduitRecipes { //Crafting Components ItemStack redstoneConduit = new ItemStack(EnderIO.itemRedstoneConduit, 1, 0); - ItemStack conduitBinder = new ItemStack(EnderIO.itemMaterial, 1, Material.CONDUIT_BINDER.ordinal()); ItemStack fusedQuartz = new ItemStack(EnderIO.blockFusedQuartz, 1, 0); ItemStack fusedGlass = new ItemStack(EnderIO.blockFusedQuartz, 1, BlockFusedQuartz.Type.GLASS.ordinal()); - ItemStack conductiveIron = new ItemStack(EnderIO.itemAlloy, 1, Alloy.CONDUCTIVE_IRON.ordinal()); - ItemStack energeticGold = new ItemStack(EnderIO.itemAlloy, 1, Alloy.ENERGETIC_ALLOY.ordinal()); - ItemStack phasedGold = new ItemStack(EnderIO.itemAlloy, 1, Alloy.PHASED_GOLD.ordinal()); - ItemStack phasedIron = new ItemStack(EnderIO.itemAlloy, 1, Alloy.PHASED_IRON.ordinal()); - ItemStack phasedIronNugget = new ItemStack(EnderIO.itemMaterial, 1, Material.PHASED_IRON_NUGGET.ordinal()); - ItemStack redstoneAlloy = new ItemStack(EnderIO.itemAlloy, 1, Alloy.REDSTONE_ALLOY.ordinal()); - ItemStack electricalSteel = new ItemStack(EnderIO.itemAlloy, 1, Alloy.ELECTRICAL_STEEL.ordinal()); + String electricalSteel = ELECTRICAL_STEEL.oreIngot; + String phasedGold = PHASED_GOLD.oreIngot; + String conductiveIron = CONDUCTIVE_IRON.oreIngot; + String energeticGold = ENERGETIC_ALLOY.oreIngot; + String phasedIronNugget = PHASED_IRON_NUGGET.oreDict; + String redstoneAlloy = REDSTONE_ALLOY.oreIngot; + + String binder = CONDUIT_BINDER.oreDict; + ItemStack zombieController = new ItemStack(EnderIO.itemFrankenSkull, 1, FrankenSkull.ZOMBIE_CONTROLLER.ordinal()); //Recipes - GameRegistry.addShapedRecipe(new ItemStack(EnderIO.itemConduitFacade, 1, FacadeType.BASIC.ordinal()), "bbb", "b b", "bbb", 'b', conduitBinder); - GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(EnderIO.itemConduitFacade, 1, FacadeType.HARDENED.ordinal()), " o ", "oFo", " o ", 'F', EnderIO.itemConduitFacade, 'o', "dustObsidian")); + addShaped(new ItemStack(EnderIO.itemConduitFacade, 1, FacadeType.BASIC.ordinal()), "bbb", "b b", "bbb", 'b', binder); + GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(EnderIO.itemConduitFacade, 1, FacadeType.HARDENED.ordinal()), " o ", "oFo", " o ", 'F', + EnderIO.itemConduitFacade, 'o', "dustObsidian")); int numConduits = Config.numConduitsPerRecipe; - GameRegistry.addShapedRecipe(new ItemStack(EnderIO.itemLiquidConduit, numConduits, 0), "bbb", "###", "bbb", 'b', conduitBinder, '#', fusedGlass); - GameRegistry.addShapedRecipe(new ItemStack(EnderIO.itemLiquidConduit, numConduits, 1), "bbb", "###", "bbb", 'b', conduitBinder, '#', fusedQuartz); - GameRegistry.addShapedRecipe(new ItemStack(EnderIO.itemLiquidConduit, numConduits, 2), "bbb", "#p#", "bbb", 'b', conduitBinder, '#', fusedQuartz, 'p', phasedGold); - GameRegistry.addShapedRecipe(new ItemStack(EnderIO.itemPowerConduit, numConduits, 0), "bbb", "###", "bbb", 'b', conduitBinder, '#', conductiveIron); - GameRegistry.addShapedRecipe(new ItemStack(EnderIO.itemPowerConduit, numConduits, 1), "bbb", "###", "bbb", 'b', conduitBinder, '#', energeticGold); - GameRegistry.addShapedRecipe(new ItemStack(EnderIO.itemPowerConduit, numConduits, 2), "bbb", "###", "bbb", 'b', conduitBinder, '#', phasedGold); - GameRegistry.addShapedRecipe(new ItemStack(EnderIO.itemRedstoneConduit, numConduits, 0), "###", '#', redstoneAlloy); - GameRegistry.addShapedRecipe(new ItemStack(EnderIO.itemRedstoneConduit, 1, 1), "lbl", "bcb", "lbl", 'b', conduitBinder, 'c', redstoneConduit, 'l', - Blocks.lever); - GameRegistry.addShapedRecipe(new ItemStack(EnderIO.itemRedstoneConduit, numConduits, 2), "bbb", "###", "bbb", 'b', conduitBinder, '#', - redstoneAlloy); + addShaped(new ItemStack(EnderIO.itemLiquidConduit, numConduits, 0), "bbb", "###", "bbb", 'b', binder, '#', fusedGlass); + addShaped(new ItemStack(EnderIO.itemLiquidConduit, numConduits, 1), "bbb", "###", "bbb", 'b', binder, '#', fusedQuartz); + addShaped(new ItemStack(EnderIO.itemLiquidConduit, numConduits, 2), "bbb", "#p#", "bbb", 'b', binder, '#', fusedQuartz, 'p', phasedGold); + addShaped(new ItemStack(EnderIO.itemPowerConduit, numConduits, 0), "bbb", "###", "bbb", 'b', binder, '#', conductiveIron); + addShaped(new ItemStack(EnderIO.itemPowerConduit, numConduits, 1), "bbb", "###", "bbb", 'b', binder, '#', energeticGold); + addShaped(new ItemStack(EnderIO.itemPowerConduit, numConduits, 2), "bbb", "###", "bbb", 'b', binder, '#', phasedGold); + addShaped(new ItemStack(EnderIO.itemRedstoneConduit, numConduits, 0), "###", '#', redstoneAlloy); + addShaped(new ItemStack(EnderIO.itemRedstoneConduit, 1, 1), "lbl", "bcb", "lbl", 'b', binder, 'c', redstoneConduit, 'l', Blocks.lever); + addShaped(new ItemStack(EnderIO.itemRedstoneConduit, numConduits, 2), "bbb", "###", "bbb", 'b', binder, '#', redstoneAlloy); if (GasUtil.isGasConduitEnabled()) { - GameRegistry.addShapedRecipe(new ItemStack(EnderIO.itemGasConduit, numConduits, 0), "bbb", "#g#", "bbb", 'b', conduitBinder, '#', electricalSteel, 'g', - fusedGlass); + addShaped(new ItemStack(EnderIO.itemGasConduit, numConduits, 0), "bbb", "#g#", "bbb", 'b', binder, '#', electricalSteel, 'g', fusedGlass); } ItemStack itemConduit = new ItemStack(EnderIO.itemItemConduit, numConduits, 0); - GameRegistry.addShapedRecipe(itemConduit, "bbb", "###", "bbb", 'b', conduitBinder, '#', phasedIronNugget); + addShaped(itemConduit, "bbb", "###", "bbb", 'b', binder, '#', phasedIronNugget); MachineRecipeRegistry.instance.registerRecipe(blockPainter.unlocalisedName, EnderIO.itemConduitFacade.new FacadePainterRecipe()); //Filter Recipes ItemStack basicFilter = new ItemStack(EnderIO.itemBasicFilterUpgrade, 1, 0); - GameRegistry.addShapedRecipe(basicFilter, " p ", "php", " p ", 'p', Items.paper, 'h', Blocks.hopper); + addShaped(basicFilter, " p ", "php", " p ", 'p', Items.paper, 'h', Blocks.hopper); ItemStack advFilter = new ItemStack(EnderIO.itemBasicFilterUpgrade, 1, 1); - GameRegistry.addRecipe(new ShapedOreRecipe(advFilter, "rpr", "pzp", "rpr", 'p', Items.paper, 'z', zombieController, 'r', Items.redstone)); + addShaped(advFilter, "rpr", "pzp", "rpr", 'p', Items.paper, 'z', zombieController, 'r', "dustRedstone"); ItemStack modFilter = new ItemStack(EnderIO.itemModItemFilter, 1, 0); - GameRegistry.addShapedRecipe(modFilter, " p ", "pwp", " p ", 'p', Items.paper, 'w', EnderIO.itemYetaWench); + addShaped(modFilter, " p ", "pwp", " p ", 'p', Items.paper, 'w', EnderIO.itemYetaWench); ItemStack exFilt = new ItemStack(EnderIO.itemExistingItemFilter); - GameRegistry.addShapedRecipe(exFilt, " r ", "rfr", " c ", 'c', new ItemStack(Items.comparator, 1, 0), 'r', Items.redstone, 'f', advFilter); + addShaped(exFilt, " r ", "rfr", " c ", 'c', new ItemStack(Items.comparator, 1, 0), 'r', "dustRedstone", 'f', advFilter); ItemStack powerFilt = new ItemStack(EnderIO.itemPowerItemFilter); - GameRegistry.addShapedRecipe(powerFilt, " p ", "pcp", " p ", 'p', Items.paper, 'c', EnderIO.itemConduitProbe); + addShaped(powerFilt, " p ", "pcp", " p ", 'p', Items.paper, 'c', EnderIO.itemConduitProbe); ClearFilterRecipe clearRec = new ClearFilterRecipe(); MinecraftForge.EVENT_BUS.register(clearRec); @@ -94,11 +95,11 @@ public class ConduitRecipes { GameRegistry.addRecipe(copyRec); ItemStack speedUpgrade = new ItemStack(EnderIO.itemExtractSpeedUpgrade, 1, 0); - GameRegistry.addShapedRecipe(speedUpgrade, "iii","epe","ere", 'p', Blocks.piston, 'e', electricalSteel, 'r', Blocks.redstone_torch, 'i', Items.iron_ingot); + addShaped(speedUpgrade, "iii", "epe", "ere", 'p', Blocks.piston, 'e', electricalSteel, 'r', Blocks.redstone_torch, 'i', "ingotIron"); ItemStack speedDowngrade = new ItemStack(EnderIO.itemExtractSpeedUpgrade, 1, 1); - GameRegistry.addRecipe(new ShapedOreRecipe(speedDowngrade, "iii","ese","ete", 's', "slimeball", 'e', electricalSteel, 't', "stickWood", 'i', Items.iron_ingot)); - GameRegistry.addRecipe(new ShapedOreRecipe(speedDowngrade, "iii","ese","ete", 's', "slimeball", 'e', electricalSteel, 't', "woodStick", 'i', Items.iron_ingot)); + addShaped(speedDowngrade, "iii", "ese", "ete", 's', "slimeball", 'e', electricalSteel, 't', "stickWood", 'i', "ingotIron"); + addShaped(speedDowngrade, "iii", "ese", "ete", 's', "slimeball", 'e', electricalSteel, 't', "woodStick", 'i', "ingotIron"); if (MEUtil.isMEEnabled()) { addAeRecipes(); @@ -109,15 +110,15 @@ public class ConduitRecipes { private static void addAeRecipes() { String fluix = "crystalFluix"; String pureFluix = "crystalPureFluix"; - + ItemStack quartzFiber = AEApi.instance().parts().partQuartzFiber.stack(1).copy(); ItemStack conduitBinder = new ItemStack(EnderIO.itemMaterial, 1, Material.CONDUIT_BINDER.ordinal()); ItemStack res = new ItemStack(EnderIO.itemMEConduit, Config.numConduitsPerRecipe / 2); - GameRegistry.addRecipe(new ShapedOreRecipe(res.copy(), "bbb", "fqf", "bbb", 'b', conduitBinder, 'f', fluix, 'q', quartzFiber)); - GameRegistry.addRecipe(new ShapedOreRecipe(res.copy(), "bbb", "fqf", "bbb", 'b', conduitBinder, 'f', pureFluix, 'q', quartzFiber)); + addShaped(res.copy(), "bbb", "fqf", "bbb", 'b', conduitBinder, 'f', fluix, 'q', quartzFiber); + addShaped(res.copy(), "bbb", "fqf", "bbb", 'b', conduitBinder, 'f', pureFluix, 'q', quartzFiber); res.stackSize = 1; - GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(EnderIO.itemMEConduit, 1, 1), "bCb", "CbC", "bCb", 'b', conduitBinder, 'C', res)); + addShaped(new ItemStack(EnderIO.itemMEConduit, 1, 1), "bCb", "CbC", "bCb", 'b', conduitBinder, 'C', res); } } diff --git a/src/main/java/crazypants/enderio/conduit/gui/ExternalConnectionContainer.java b/src/main/java/crazypants/enderio/conduit/gui/ExternalConnectionContainer.java index 862c5db0..37fdf9a2 100644 --- a/src/main/java/crazypants/enderio/conduit/gui/ExternalConnectionContainer.java +++ b/src/main/java/crazypants/enderio/conduit/gui/ExternalConnectionContainer.java @@ -115,7 +115,6 @@ public class ExternalConnectionContainer extends Container { } protected void filterChanged() { - System.out.println("filterChanged " + filterListeners.size()); for (FilterChangeListener list : filterListeners) { list.onFilterChanged(); } diff --git a/src/main/java/crazypants/enderio/conduit/gui/item/BasicItemFilterGui.java b/src/main/java/crazypants/enderio/conduit/gui/item/BasicItemFilterGui.java index fa3b6804..36efe903 100644 --- a/src/main/java/crazypants/enderio/conduit/gui/item/BasicItemFilterGui.java +++ b/src/main/java/crazypants/enderio/conduit/gui/item/BasicItemFilterGui.java @@ -53,7 +53,6 @@ public class BasicItemFilterGui implements IItemFilterGui { this.yOffset = yOffset; this.buttonIdOffset = buttonIdOffset; - filter = filterContainer.getItemFilter(); isAdvanced = filter.isAdvanced(); diff --git a/src/main/java/crazypants/enderio/conduit/item/ItemConduitNetwork.java b/src/main/java/crazypants/enderio/conduit/item/ItemConduitNetwork.java index d1e0f984..1f987e3e 100644 --- a/src/main/java/crazypants/enderio/conduit/item/ItemConduitNetwork.java +++ b/src/main/java/crazypants/enderio/conduit/item/ItemConduitNetwork.java @@ -12,7 +12,6 @@ import net.minecraftforge.common.util.ForgeDirection; import com.enderio.core.common.util.BlockCoord; -import crazypants.enderio.EnderIO; import crazypants.enderio.conduit.AbstractConduitNetwork; import crazypants.enderio.conduit.item.NetworkedInventory.Target; import crazypants.enderio.conduit.item.filter.IItemFilter; @@ -182,7 +181,7 @@ public class ItemConduitNetwork extends AbstractConduitNetwork { NetworkedInventory inv; int distance; @@ -421,4 +433,4 @@ public class NetworkedInventory { } } -} \ No newline at end of file +} diff --git a/src/main/java/crazypants/enderio/conduit/item/filter/CopyFilterRecipe.java b/src/main/java/crazypants/enderio/conduit/item/filter/CopyFilterRecipe.java index 8e3f7d5b..d3d36c74 100644 --- a/src/main/java/crazypants/enderio/conduit/item/filter/CopyFilterRecipe.java +++ b/src/main/java/crazypants/enderio/conduit/item/filter/CopyFilterRecipe.java @@ -19,30 +19,30 @@ public class CopyFilterRecipe implements IRecipe{ @Override public boolean matches(InventoryCrafting inv, World world) { - ItemStack blankInput = null; + int blankCount = 0; ItemStack filterInput = null; for (int i = 0; i < inv.getSizeInventory(); i++) { ItemStack checkStack = inv.getStackInSlot(i); if (checkStack != null && checkStack.getItem() instanceof IItemFilterUpgrade) { if(FilterRegister.isFilterSet(checkStack)) { - if(filterInput != null || !isSameTypeOrNull(blankInput, checkStack)) { - return false; - } - filterInput = checkStack; - } else { - if(blankInput != null || !isSameTypeOrNull(filterInput, checkStack)) { + if(filterInput != null) { return false; } - blankInput = checkStack; + filterInput = checkStack; + } else { + if(!isSameTypeOrNull(filterInput, checkStack)) { + return false; + } + blankCount++; } } } - if(blankInput == null || filterInput == null) { + if(blankCount == 0 || filterInput == null) { return false; } output = filterInput.copy(); - output.stackSize = 2; + output.stackSize = blankCount + 1; return true; } diff --git a/src/main/java/crazypants/enderio/conduit/liquid/EnderLiquidConduit.java b/src/main/java/crazypants/enderio/conduit/liquid/EnderLiquidConduit.java index 234ce983..86908396 100644 --- a/src/main/java/crazypants/enderio/conduit/liquid/EnderLiquidConduit.java +++ b/src/main/java/crazypants/enderio/conduit/liquid/EnderLiquidConduit.java @@ -298,6 +298,38 @@ public class EnderLiquidConduit extends AbstractLiquidConduit { } return network.getTankInfo(this, from); } + + @Override + protected void readTypeSettings(ForgeDirection dir, NBTTagCompound dataRoot) { + super.readTypeSettings(dir, dataRoot); + if (dataRoot.hasKey("outputFilters")) { + FluidFilter out = new FluidFilter(); + out.readFromNBT(dataRoot.getCompoundTag("outputFilters")); + outputFilters.put(dir, out); + } + if (dataRoot.hasKey("inputFilters")) { + FluidFilter in = new FluidFilter(); + in.readFromNBT(dataRoot.getCompoundTag("inputFilters")); + inputFilters.put(dir, in); + } + } + + @Override + protected void writeTypeSettingsToNbt(ForgeDirection dir, NBTTagCompound dataRoot) { + super.writeTypeSettingsToNbt(dir, dataRoot); + FluidFilter out = outputFilters.get(dir); + if (out != null) { + NBTTagCompound outTag = new NBTTagCompound(); + out.writeToNBT(outTag); + dataRoot.setTag("outputFilters", outTag); + } + FluidFilter in = inputFilters.get(dir); + if (in != null) { + NBTTagCompound inTag = new NBTTagCompound(); + in.writeToNBT(inTag); + dataRoot.setTag("inputFilters", inTag); + } + } @Override public void writeToNBT(NBTTagCompound nbtRoot) { @@ -322,7 +354,6 @@ public class EnderLiquidConduit extends AbstractLiquidConduit { } } } - } @Override diff --git a/src/main/java/crazypants/enderio/config/Config.java b/src/main/java/crazypants/enderio/config/Config.java index fbe37134..b4759a1c 100644 --- a/src/main/java/crazypants/enderio/config/Config.java +++ b/src/main/java/crazypants/enderio/config/Config.java @@ -106,6 +106,7 @@ public final class Config { public static File configDirectory; public static boolean useHardRecipes = false; + public static boolean addPeacefulRecipes = false; public static boolean allowExternalTickSpeedup = true; public static boolean useSteelInChassi = false; @@ -345,6 +346,10 @@ public final class Config { public static int poweredSpawnerLevelThreePowerPerTickRF = 1500; public static int poweredSpawnerMaxPlayerDistance = 0; public static int poweredSpawnerDespawnTimeSeconds = 120; + public static int poweredSpawnerSpawnCount = 4; + public static int poweredSpawnerSpawnRange = 4; + public static int poweredSpawnerMaxNearbyEntities = 6; + public static int poweredSpawnerMaxSpawnTries = 3; public static boolean poweredSpawnerUseVanillaSpawChecks = false; public static double brokenSpawnerDropChance = 1; public static String[] brokenSpawnerToolBlacklist = new String[] { @@ -584,6 +589,8 @@ public final class Config { useHardRecipes = config.get(sectionRecipe.name, "useHardRecipes", useHardRecipes, "When enabled machines cost significantly more.") .getBoolean(useHardRecipes); + addPeacefulRecipes = config.get(sectionRecipe.name, "addPeacefulRecipes", addPeacefulRecipes, "When enabled peaceful recipes are added for soulbinder based crafting components.") + .getBoolean(addPeacefulRecipes); soulBinderRequiresEndermanSkull = config.getBoolean("soulBinderRequiresEndermanSkull", sectionRecipe.name, soulBinderRequiresEndermanSkull, "When true the Soul Binder requires an Enderman Skull to craft"); allowTileEntitiesAsPaintSource = config.get(sectionRecipe.name, "allowTileEntitiesAsPaintSource", allowTileEntitiesAsPaintSource, @@ -1097,6 +1104,14 @@ public final class Config { "Max distance of the closest player for the spawner to be active. A zero value will remove the player check").getInt(poweredSpawnerMaxPlayerDistance); poweredSpawnerDespawnTimeSeconds = config.get(sectionSpawner.name, "poweredSpawnerDespawnTimeSeconds" , poweredSpawnerDespawnTimeSeconds, "Number of seconds in which spawned entities are protected from despawning").getInt(poweredSpawnerDespawnTimeSeconds); + poweredSpawnerSpawnCount = config.get(sectionSpawner.name, "poweredSpawnerSpawnCount" , poweredSpawnerSpawnCount, + "Number of entities to spawn each time").getInt(poweredSpawnerSpawnCount); + poweredSpawnerSpawnRange = config.get(sectionSpawner.name, "poweredSpawnerSpawnRange" , poweredSpawnerSpawnRange, + "Spawning range in X/Z").getInt(poweredSpawnerSpawnRange); + poweredSpawnerMaxNearbyEntities = config.get(sectionSpawner.name, "poweredSpawnerMaxNearbyEntities" , poweredSpawnerMaxNearbyEntities, + "Max number of entities in the nearby area until no more are spawned. A zero value will remove this check").getInt(poweredSpawnerMaxNearbyEntities); + poweredSpawnerMaxSpawnTries = config.get(sectionSpawner.name, "poweredSpawnerMaxSpawnTries" , poweredSpawnerMaxSpawnTries, + "Number of tries to find a suitable spawning location").getInt(poweredSpawnerMaxSpawnTries); poweredSpawnerUseVanillaSpawChecks = config.get(sectionSpawner.name, "poweredSpawnerUseVanillaSpawChecks", poweredSpawnerUseVanillaSpawChecks, "If true, regular spawn checks such as lighting level and dimension will be made before spawning mobs").getBoolean(poweredSpawnerUseVanillaSpawChecks); brokenSpawnerDropChance = (float) config.get(sectionSpawner.name, "brokenSpawnerDropChance", brokenSpawnerDropChance, diff --git a/src/main/java/crazypants/enderio/enderface/EnderfaceRecipes.java b/src/main/java/crazypants/enderio/enderface/EnderfaceRecipes.java index 8033c457..14877eda 100644 --- a/src/main/java/crazypants/enderio/enderface/EnderfaceRecipes.java +++ b/src/main/java/crazypants/enderio/enderface/EnderfaceRecipes.java @@ -2,19 +2,17 @@ package crazypants.enderio.enderface; import net.minecraft.init.Items; import net.minecraft.item.ItemStack; -import cpw.mods.fml.common.registry.GameRegistry; import crazypants.enderio.EnderIO; import crazypants.enderio.material.Alloy; +import crazypants.util.RecipeUtil; public class EnderfaceRecipes { public static void addRecipes() { - ItemStack phasedGold = new ItemStack(EnderIO.itemAlloy, 1, Alloy.PHASED_GOLD.ordinal()); ItemStack fusedQuartz = new ItemStack(EnderIO.blockFusedQuartz, 1, 0); - ItemStack electricalSteel = new ItemStack(EnderIO.itemAlloy, 1, Alloy.ELECTRICAL_STEEL.ordinal()); - GameRegistry.addRecipe(new ItemStack(EnderIO.blockEnderIo), "sqs", "qeq", "sqs", 's', electricalSteel, 'q', fusedQuartz, 'e', new ItemStack( - Items.ender_eye)); + String electricalSteel = Alloy.ELECTRICAL_STEEL.oreIngot; + RecipeUtil.addShaped(new ItemStack(EnderIO.blockEnderIo), "sqs", "qeq", "sqs", 's', electricalSteel, 'q', fusedQuartz, 'e', new ItemStack(Items.ender_eye)); } } diff --git a/src/main/java/crazypants/enderio/item/ItemRecipes.java b/src/main/java/crazypants/enderio/item/ItemRecipes.java index 9b6e2d81..9e1a0bd6 100644 --- a/src/main/java/crazypants/enderio/item/ItemRecipes.java +++ b/src/main/java/crazypants/enderio/item/ItemRecipes.java @@ -7,64 +7,63 @@ import net.minecraftforge.oredict.ShapedOreRecipe; import cpw.mods.fml.common.registry.GameRegistry; import crazypants.enderio.EnderIO; import crazypants.enderio.item.darksteel.DarkSteelItems; -import crazypants.enderio.material.Alloy; import crazypants.enderio.material.MachinePart; -import crazypants.enderio.material.Material; + +import static crazypants.enderio.material.Alloy.*; +import static crazypants.enderio.material.Material.VIBRANT_CYSTAL; +import static crazypants.util.RecipeUtil.addShaped; public class ItemRecipes { public static void addRecipes() { ItemStack basicGear = new ItemStack(EnderIO.itemMachinePart, 1, MachinePart.BASIC_GEAR.ordinal()); - ItemStack electricalSteel = new ItemStack(EnderIO.itemAlloy, 1, Alloy.ELECTRICAL_STEEL.ordinal()); - ItemStack conductiveIron = new ItemStack(EnderIO.itemAlloy, 1, Alloy.CONDUCTIVE_IRON.ordinal()); - ItemStack vibCry = new ItemStack(EnderIO.itemMaterial, 1, Material.VIBRANT_CYSTAL.ordinal()); - ItemStack vibAlloy = new ItemStack(EnderIO.itemAlloy, 1, Alloy.PHASED_GOLD.ordinal()); - ItemStack enAlloy = new ItemStack(EnderIO.itemAlloy, 1, Alloy.ENERGETIC_ALLOY.ordinal()); - ItemStack darkSteel = new ItemStack(EnderIO.itemAlloy, 1, Alloy.DARK_STEEL.ordinal()); - ItemStack soularium = new ItemStack(EnderIO.itemAlloy, 1, Alloy.SOULARIUM.ordinal()); + String electricalSteel = ELECTRICAL_STEEL.oreIngot; + String conductiveIron = CONDUCTIVE_IRON.oreIngot; + String vibCry = VIBRANT_CYSTAL.oreDict; + String enAlloy = ENERGETIC_ALLOY.oreIngot; + String darkSteel = DARK_STEEL.oreIngot; + String soularium = SOULARIUM.oreIngot; // Wrench ItemStack wrench = new ItemStack(EnderIO.itemYetaWench, 1, 0); - GameRegistry.addShapedRecipe(wrench, "s s", " b ", " s ", 's', electricalSteel, 'b', basicGear); + addShaped(wrench, "s s", " b ", " s ", 's', electricalSteel, 'b', basicGear); //Magnet ItemStack magnet = new ItemStack(EnderIO.itemMagnet, 1, 0); EnderIO.itemMagnet.setEnergy(magnet, 0); - GameRegistry.addShapedRecipe(magnet, "scc", " v", "scc", 's', electricalSteel, 'c', conductiveIron, 'v', vibCry); + addShaped(magnet, "scc", " v", "scc", 's', electricalSteel, 'c', conductiveIron, 'v', vibCry); //Dark Steel - GameRegistry.addShapedRecipe(DarkSteelItems.itemDarkSteelHelmet.createItemStack(), "sss", "s s", 's', darkSteel); - GameRegistry.addShapedRecipe(DarkSteelItems.itemDarkSteelChestplate.createItemStack(), "s s", "sss", "sss", 's', darkSteel); - GameRegistry.addShapedRecipe(DarkSteelItems.itemDarkSteelLeggings.createItemStack(), "sss", "s s", "s s", 's', darkSteel); - GameRegistry.addShapedRecipe(DarkSteelItems.itemDarkSteelBoots.createItemStack(), "s s", "s s", 's', darkSteel); + addShaped(DarkSteelItems.itemDarkSteelHelmet.createItemStack(), "sss", "s s", 's', darkSteel); + addShaped(DarkSteelItems.itemDarkSteelChestplate.createItemStack(), "s s", "sss", "sss", 's', darkSteel); + addShaped(DarkSteelItems.itemDarkSteelLeggings.createItemStack(), "sss", "s s", "s s", 's', darkSteel); + addShaped(DarkSteelItems.itemDarkSteelBoots.createItemStack(), "s s", "s s", 's', darkSteel); - ItemStack wing = new ItemStack(DarkSteelItems.itemGliderWing,1,0); - GameRegistry.addShapedRecipe(wing, " s", " sl", "sll", 's', darkSteel, 'l', Items.leather); - GameRegistry.addShapedRecipe(new ItemStack(DarkSteelItems.itemGliderWing,1,1), " s ", "wsw", " ", 's', darkSteel, 'w', wing); + ItemStack wing = new ItemStack(DarkSteelItems.itemGliderWing, 1, 0); + addShaped(wing, " s", " sl", "sll", 's', darkSteel, 'l', Items.leather); + addShaped(new ItemStack(DarkSteelItems.itemGliderWing, 1, 1), " s ", "wsw", " ", 's', darkSteel, 'w', wing); - GameRegistry.addShapedRecipe(DarkSteelItems.itemDarkSteelShears.createItemStack(), " s", "s ", 's', darkSteel); + addShaped(DarkSteelItems.itemDarkSteelShears.createItemStack(), " s", "s ", 's', darkSteel); ItemStack dspp = new ItemStack(EnderIO.blockDarkSteelPressurePlate); - GameRegistry.addShapedRecipe(dspp, "ss", 's', darkSteel); + addShaped(dspp, "ss", 's', darkSteel); ItemStack dsppSilent = new ItemStack(EnderIO.blockDarkSteelPressurePlate, 1, 1); GameRegistry.addShapedRecipe(dsppSilent, "p", "w", 'p', dspp, 'w', Blocks.wool); //Soul Vessel - GameRegistry.addShapedRecipe(new ItemStack(EnderIO.itemSoulVessel), " s ", "q q", " q ", 's', soularium, 'q', new ItemStack(EnderIO.blockFusedQuartz,1,0)); + GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(EnderIO.itemSoulVessel), " s ", "q q", " q ", 's', soularium, 'q', new ItemStack( + EnderIO.blockFusedQuartz, 1, 0))); //XP Rod - GameRegistry.addShapedRecipe(new ItemStack(EnderIO.itemXpTransfer), " s", " v ", "s ", 's', soularium, 'v', enAlloy); + addShaped(new ItemStack(EnderIO.itemXpTransfer), " s", " v ", "s ", 's', soularium, 'v', enAlloy); - } - - public static void addOreDictionaryRecipes() { - ItemStack darkSteel = new ItemStack(EnderIO.itemAlloy, 1, Alloy.DARK_STEEL.ordinal()); - GameRegistry.addRecipe(new ShapedOreRecipe(DarkSteelItems.itemDarkSteelSword.createItemStack(), " s ", " s ", " w ", 's', darkSteel, 'w', "stickWood")); - GameRegistry.addRecipe(new ShapedOreRecipe(DarkSteelItems.itemDarkSteelSword.createItemStack(), " s ", " s ", " w ", 's', darkSteel, 'w', "woodStick")); - GameRegistry.addRecipe(new ShapedOreRecipe(DarkSteelItems.itemDarkSteelPickaxe.createItemStack(), "sss", " w ", " w ", 's', darkSteel, 'w', "stickWood")); - GameRegistry.addRecipe(new ShapedOreRecipe(DarkSteelItems.itemDarkSteelPickaxe.createItemStack(), "sss", " w ", " w ", 's', darkSteel, 'w', "woodStick")); - GameRegistry.addRecipe(new ShapedOreRecipe(DarkSteelItems.itemDarkSteelAxe.createItemStack(), "ss ", "sw ", " w ", 's', darkSteel, 'w', "woodStick")); - GameRegistry.addRecipe(new ShapedOreRecipe(DarkSteelItems.itemDarkSteelAxe.createItemStack(), "ss ", "sw ", " w ", 's', darkSteel, 'w', "stickWood")); + // DS Tools + addShaped(DarkSteelItems.itemDarkSteelSword.createItemStack(), " s ", " s ", " w ", 's', darkSteel, 'w', "stickWood"); + addShaped(DarkSteelItems.itemDarkSteelSword.createItemStack(), " s ", " s ", " w ", 's', darkSteel, 'w', "woodStick"); + addShaped(DarkSteelItems.itemDarkSteelPickaxe.createItemStack(), "sss", " w ", " w ", 's', darkSteel, 'w', "stickWood"); + addShaped(DarkSteelItems.itemDarkSteelPickaxe.createItemStack(), "sss", " w ", " w ", 's', darkSteel, 'w', "woodStick"); + addShaped(DarkSteelItems.itemDarkSteelAxe.createItemStack(), "ss ", "sw ", " w ", 's', darkSteel, 'w', "woodStick"); + addShaped(DarkSteelItems.itemDarkSteelAxe.createItemStack(), "ss ", "sw ", " w ", 's', darkSteel, 'w', "stickWood"); } } diff --git a/src/main/java/crazypants/enderio/machine/FakePlayerEIO.java b/src/main/java/crazypants/enderio/machine/FakePlayerEIO.java new file mode 100644 index 00000000..8186cb44 --- /dev/null +++ b/src/main/java/crazypants/enderio/machine/FakePlayerEIO.java @@ -0,0 +1,40 @@ +package crazypants.enderio.machine; + +import net.minecraft.item.ItemStack; +import net.minecraft.potion.PotionEffect; +import net.minecraft.server.MinecraftServer; +import net.minecraft.util.IChatComponent; +import net.minecraft.world.World; +import net.minecraftforge.common.util.FakePlayer; + +import com.enderio.core.common.util.BlockCoord; +import com.mojang.authlib.GameProfile; + +public class FakePlayerEIO extends FakePlayer { + + ItemStack prevWeapon; + + public FakePlayerEIO(World world, BlockCoord pos, GameProfile profile) { + super(MinecraftServer.getServer().worldServerForDimension(world.provider.dimensionId), profile); + posX = pos.x + 0.5; + posY = pos.y + 0.5; + posZ = pos.z + 0.5; + } + + // These do things with packets...which crash since the net handler is null. Potion effects are not needed anyways. + @Override + protected void onNewPotionEffect(PotionEffect p_70670_1_) { + } + + @Override + protected void onChangedPotionEffect(PotionEffect p_70695_1_, boolean p_70695_2_) { + } + + @Override + protected void onFinishedPotionEffect(PotionEffect p_70688_1_) { + } + + @Override + public void addChatMessage(IChatComponent p_145747_1_) { + } +} diff --git a/src/main/java/crazypants/enderio/machine/MachineRecipes.java b/src/main/java/crazypants/enderio/machine/MachineRecipes.java index 62d1d118..eb5d09e7 100644 --- a/src/main/java/crazypants/enderio/machine/MachineRecipes.java +++ b/src/main/java/crazypants/enderio/machine/MachineRecipes.java @@ -4,8 +4,6 @@ import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.item.ItemStack; import net.minecraftforge.common.MinecraftForge; -import net.minecraftforge.oredict.ShapedOreRecipe; -import net.minecraftforge.oredict.ShapelessOreRecipe; import cpw.mods.fml.common.registry.GameRegistry; import crazypants.enderio.EnderIO; import crazypants.enderio.conduit.item.FunctionUpgrade; @@ -16,134 +14,136 @@ import crazypants.enderio.machine.capbank.BlockItemCapBank; import crazypants.enderio.machine.capbank.CapBankType; import crazypants.enderio.machine.capbank.ConvertOldRecipe; import crazypants.enderio.machine.light.BlockItemElectricLight; -import crazypants.enderio.material.Alloy; import crazypants.enderio.material.FrankenSkull; import crazypants.enderio.material.MachinePart; import crazypants.enderio.material.Material; import crazypants.enderio.power.Capacitors; import static crazypants.enderio.EnderIO.itemBasicCapacitor; +import static crazypants.enderio.material.Alloy.*; +import static crazypants.enderio.material.Material.*; +import static crazypants.util.RecipeUtil.*; public class MachineRecipes { public static void addRecipes() { //Common ingredients - ItemStack conduitBinder = new ItemStack(EnderIO.itemMaterial, 4, Material.CONDUIT_BINDER.ordinal()); ItemStack capacitor = new ItemStack(itemBasicCapacitor, 1, 0); ItemStack capacitor2 = new ItemStack(itemBasicCapacitor, 1, 1); ItemStack capacitor3 = new ItemStack(itemBasicCapacitor, 1, 2); ItemStack enderCapacitor = new ItemStack(itemBasicCapacitor, 1, Capacitors.ENDER_CAPACITOR.ordinal()); - ItemStack basicGear = new ItemStack(EnderIO.itemMachinePart, 1, MachinePart.BASIC_GEAR.ordinal()); - ItemStack machineChassi = new ItemStack(EnderIO.itemMachinePart, 1, MachinePart.MACHINE_CHASSI.ordinal()); - ItemStack silicon = new ItemStack(EnderIO.itemMaterial, 1, Material.SILICON.ordinal()); - ItemStack pulCry = new ItemStack(EnderIO.itemMaterial, 1, Material.PULSATING_CYSTAL.ordinal()); - ItemStack vibCry = new ItemStack(EnderIO.itemMaterial, 1, Material.VIBRANT_CYSTAL.ordinal()); - ItemStack endCry = new ItemStack(EnderIO.itemMaterial, 1, Material.ENDER_CRYSTAL.ordinal()); - ItemStack electricSteel = new ItemStack(EnderIO.itemAlloy, 1, Alloy.ELECTRICAL_STEEL.ordinal()); - ItemStack darkSteel = new ItemStack(EnderIO.itemAlloy, 1, Alloy.DARK_STEEL.ordinal()); - ItemStack phasedGold = new ItemStack(EnderIO.itemAlloy, 1, Alloy.PHASED_GOLD.ordinal()); - ItemStack phasedIron = new ItemStack(EnderIO.itemAlloy, 1, Alloy.PHASED_IRON.ordinal()); - ItemStack energeticAlloy = new ItemStack(EnderIO.itemAlloy, 1, Alloy.ENERGETIC_ALLOY.ordinal()); + String basicGear = MachinePart.BASIC_GEAR.oreDict; + String machineChassi = MachinePart.MACHINE_CHASSI.oreDict; ItemStack fusedQuartz = new ItemStack(EnderIO.blockFusedQuartz, 1, 0); - ItemStack clearGlass = new ItemStack(EnderIO.blockFusedQuartz, 1, 1); ItemStack enlightedQuartz = new ItemStack(EnderIO.blockFusedQuartz, 1, 2); - ItemStack fusedGlass = new ItemStack(EnderIO.blockFusedQuartz, 1, 1); - ItemStack soularium = new ItemStack(EnderIO.itemAlloy, 1, Alloy.SOULARIUM.ordinal()); ItemStack zombieController = new ItemStack(EnderIO.itemFrankenSkull, 1, FrankenSkull.ZOMBIE_CONTROLLER.ordinal()); ItemStack frankenZombie = new ItemStack(EnderIO.itemFrankenSkull, 1, FrankenSkull.FRANKEN_ZOMBIE.ordinal()); ItemStack enderRes = new ItemStack(EnderIO.itemFrankenSkull, 1, FrankenSkull.ENDER_RESONATOR.ordinal()); ItemStack sentientEnder = new ItemStack(EnderIO.itemFrankenSkull, 1, FrankenSkull.SENTIENT_ENDER.ordinal()); ItemStack obsidian = new ItemStack(Blocks.obsidian); + String electricalSteel = ELECTRICAL_STEEL.oreIngot; + String darkSteel = DARK_STEEL.oreIngot; + String energeticAlloy = ENERGETIC_ALLOY.oreIngot; + String phasedGold = PHASED_GOLD.oreIngot; + String phasedIron = PHASED_IRON.oreIngot; + String soularium = SOULARIUM.oreIngot; + + String vibCry = VIBRANT_CYSTAL.oreDict; + String pulCry = PULSATING_CYSTAL.oreDict; + String endCry = ENDER_CRYSTAL.oreDict; + String binder = CONDUIT_BINDER.oreDict; + String silicon = SILICON.oreDict; + + if (Config.addPeacefulRecipes) { + addShaped(frankenZombie, "gdg", "dzd", "gdg", 'g', Items.gold_ingot, 'd', Items.diamond, 'z', zombieController); + addShaped(sentientEnder, "ddd", "ded", "dgd", 'g', Blocks.gold_block, 'd', Items.diamond, 'e', enderRes); + } + //stirling gen ItemStack stirlingGen = new ItemStack(EnderIO.blockStirlingGenerator, 1, 0); - GameRegistry.addShapedRecipe(stirlingGen, "bbb", "bfb", "gpg", 'b', Blocks.stonebrick, 'f', Blocks.furnace, 'p', Blocks.piston, 'g', basicGear); + addShaped(stirlingGen, "bbb", "bfb", "gpg", 'b', Blocks.stonebrick, 'f', Blocks.furnace, 'p', Blocks.piston, 'g', basicGear); //Combustion Gen ItemStack res = new ItemStack(EnderIO.blockTank, 1, 0); ItemStack comGen = new ItemStack(EnderIO.blockCombustionGenerator, 1, 0); - GameRegistry.addShapedRecipe(comGen, "eee", "rmr", "gpg", 'e', electricSteel, 'r', res, 'm', machineChassi, 'g', basicGear, 'p', Blocks.piston); + addShaped(comGen, "eee", "rmr", "gpg", 'e', electricalSteel, 'r', res, 'm', machineChassi, 'g', basicGear, 'p', Blocks.piston); //ZombieGen ItemStack zg = new ItemStack(EnderIO.blockZombieGenerator, 1, 0); - GameRegistry.addShapedRecipe(zg, "eee", "qzq", "qqq", 'e', electricSteel, 'q', fusedQuartz, 'z', new ItemStack(EnderIO.itemFrankenSkull, 1, 0)); + addShaped(zg, "eee", "qzq", "qqq", 'e', electricalSteel, 'q', fusedQuartz, 'z', new ItemStack(EnderIO.itemFrankenSkull, 1, 0)); //KillerJoe ItemStack kj = new ItemStack(EnderIO.blockKillerJoe, 1, 0); - GameRegistry.addShapedRecipe(kj, "sss", "qzq", "qqq", 's', darkSteel, 'q', fusedQuartz, 'z', frankenZombie); + addShaped(kj, "sss", "qzq", "qqq", 's', darkSteel, 'q', fusedQuartz, 'z', frankenZombie); //Wireless charger ItemStack wirelessCharger = new ItemStack(EnderIO.blockWirelessCharger); - //GameRegistry.addShapedRecipe(wirelessCharger, "svs", "imi", "scs", 's', electricSteel, 'i', silicon, 'm', machineChassi, 'c', capacitor3, 'v', vibCry); - GameRegistry.addShapedRecipe(wirelessCharger, "sss", "ses", "scs", 's', electricSteel, 'c', capacitor3, 'e', enderRes); + //addShaped(wirelessCharger, "svs", "imi", "scs", 's', electricSteel, 'i', silicon, 'm', machineChassi, 'c', capacitor3, 'v', vibCry); + addShaped(wirelessCharger, "sss", "ses", "scs", 's', electricalSteel, 'c', capacitor3, 'e', enderRes); //Crafter ItemStack crafter = new ItemStack(EnderIO.blockCrafter, 1, 0); - GameRegistry.addShapedRecipe(crafter, "iti", "imi", "izi", 'i', Items.iron_ingot, 't', Blocks.crafting_table, 'm', machineChassi, 'z', zombieController); + addShaped(crafter, "iti", "imi", "izi", 'i', Items.iron_ingot, 't', Blocks.crafting_table, 'm', machineChassi, 'z', zombieController); //Powered Spawner ItemStack poweredSpawner = new ItemStack(EnderIO.blockPoweredSpawner); ItemStack zombieBit; - if(Config.useHardRecipes) { + if (Config.useHardRecipes) { zombieBit = frankenZombie; } else { zombieBit = zombieController; } - GameRegistry.addRecipe(new ShapedOreRecipe(poweredSpawner, "ese", "eme", "vzv", 'e', electricSteel, 's', "itemSkull", 'v', vibCry, 'm', machineChassi, 'z', - zombieBit)); + addShaped(poweredSpawner, "ese", "eme", "vzv", 'e', electricalSteel, 's', "itemSkull", 'v', vibCry, 'm', machineChassi, 'z', zombieBit); - if(Config.reservoirEnabled) { + if (Config.reservoirEnabled) { //reservoir ItemStack reservoir = new ItemStack(EnderIO.blockReservoir, 2, 0); Object glassSides; - if(Config.useHardRecipes) { + if (Config.useHardRecipes) { glassSides = "blockGlassHardened"; } else { glassSides = "glass"; } - GameRegistry.addRecipe(new ShapedOreRecipe(reservoir, "gfg", "gcg", "gfg", 'g', glassSides, 'c', Items.cauldron, 'f', fusedQuartz)); + addShaped(reservoir, "gfg", "gcg", "gfg", 'g', glassSides, 'c', Items.cauldron, 'f', fusedQuartz); } //Tanks ItemStack basicTank = new ItemStack(EnderIO.blockTank, 1, 0); - GameRegistry.addRecipe(new ShapedOreRecipe(basicTank, "ibi", "bgb", "ibi", 'g', "glass", 'i', Items.iron_ingot, 'b', Blocks.iron_bars)); + addShaped(basicTank, "ibi", "bgb", "ibi", 'g', "glass", 'i', Items.iron_ingot, 'b', Blocks.iron_bars); ItemStack advTank = new ItemStack(EnderIO.blockTank, 1, 1); - GameRegistry.addRecipe(new ShapedOreRecipe(advTank, "ibi", "bgb", "ibi", 'g', "blockGlassHardened", 'i', darkSteel, 'b', EnderIO.blockDarkIronBars)); + addShaped(advTank, "ibi", "bgb", "ibi", 'g', "blockGlassHardened", 'i', darkSteel, 'b', EnderIO.blockDarkIronBars); //mill ItemStack crusher = new ItemStack(EnderIO.blockCrusher, 1, 0); - if(Config.useHardRecipes) { - GameRegistry.addShapedRecipe(crusher, "ooo", "fmf", "pip", 'f', Items.flint, 'm', machineChassi, 'i', Items.iron_ingot, 'p', - Blocks.piston, - 'o', Blocks.obsidian); + if (Config.useHardRecipes) { + addShaped(crusher, "ooo", "fmf", "pip", 'f', Items.flint, 'm', machineChassi, 'i', Items.iron_ingot, 'p', Blocks.piston, 'o', Blocks.obsidian); } else { - GameRegistry.addShapedRecipe(crusher, "fff", "imi", "ipi", 'f', Items.flint, 'm', machineChassi, 'i', Items.iron_ingot, 'p', Blocks.piston); + addShaped(crusher, "fff", "imi", "ipi", 'f', Items.flint, 'm', machineChassi, 'i', Items.iron_ingot, 'p', Blocks.piston); } //alloy smelter ItemStack alloySmelter = new ItemStack(EnderIO.blockAlloySmelter, 1, 0); - if(Config.useHardRecipes) { - GameRegistry.addRecipe(new ShapedOreRecipe(alloySmelter, "bfb", "fmf", "bcb", 'c', Items.cauldron, 'm', machineChassi, 'b', Blocks.iron_block, 'f', - Blocks.furnace)); + if (Config.useHardRecipes) { + addShaped(alloySmelter, "bfb", "fmf", "bcb", 'c', Items.cauldron, 'm', machineChassi, 'b', Blocks.iron_block, 'f', Blocks.furnace); } else { - GameRegistry.addRecipe(new ShapedOreRecipe(alloySmelter, "bfb", "fmf", "bcb", 'c', Items.cauldron, 'm', machineChassi, 'b', Items.iron_ingot, 'f', - Blocks.furnace)); + addShaped(alloySmelter, "bfb", "fmf", "bcb", 'c', Items.cauldron, 'm', machineChassi, 'b', Items.iron_ingot, 'f', Blocks.furnace); } //Vat ItemStack still = new ItemStack(EnderIO.blockVat, 1, 0); - GameRegistry.addShapedRecipe(still, "eve", "tmt", "efe", 'v', Items.cauldron, 'm', machineChassi, 'e', electricSteel, 'f', Blocks.furnace, 't', basicTank); + addShaped(still, "eve", "tmt", "efe", 'v', Items.cauldron, 'm', machineChassi, 'e', electricalSteel, 'f', Blocks.furnace, 't', basicTank); //capacitor bank ItemStack capBank1 = BlockItemCapBank.createItemStackWithPower(CapBankType.getMetaFromType(CapBankType.SIMPLE), 0); - GameRegistry.addShapedRecipe(capBank1, "bcb", "cmc", "bcb", 'b', Items.iron_ingot, 'c', capacitor, 'm', Blocks.redstone_block); + addShaped(capBank1, "bcb", "cmc", "bcb", 'b', Items.iron_ingot, 'c', capacitor, 'm', Blocks.redstone_block); ItemStack capBank2 = BlockItemCapBank.createItemStackWithPower(CapBankType.getMetaFromType(CapBankType.ACTIVATED), 0); - GameRegistry.addShapedRecipe(capBank2, "bcb", "cmc", "bcb", 'b', electricSteel, 'c', capacitor2, 'm', Blocks.redstone_block); + addShaped(capBank2, "bcb", "cmc", "bcb", 'b', electricalSteel, 'c', capacitor2, 'm', Blocks.redstone_block); ItemStack capBank3 = BlockItemCapBank.createItemStackWithPower(CapBankType.getMetaFromType(CapBankType.VIBRANT), 0); - GameRegistry.addShapedRecipe(capBank3, "bcb", "cmc", "bcb", 'b', electricSteel, 'c', capacitor3, 'm', vibCry); + addShaped(capBank3, "bcb", "cmc", "bcb", 'b', electricalSteel, 'c', capacitor3, 'm', vibCry); ConvertOldRecipe convertRecipe = new ConvertOldRecipe(); GameRegistry.addRecipe(convertRecipe); @@ -153,54 +153,46 @@ public class MachineRecipes { //painter ItemStack painter = new ItemStack(EnderIO.blockPainter, 1, 0); - if(Config.useHardRecipes) { - GameRegistry.addRecipe(new ShapedOreRecipe(painter, "qqq", "mdm", "mMm", 'm', electricSteel, 'M', machineChassi, 'q', Items.quartz, 'd', Items.diamond, - 'd', Items.diamond)); + if (Config.useHardRecipes) { + addShaped(painter, "qqq", "mdm", "mMm", 'm', electricalSteel, 'M', machineChassi, 'q', Items.quartz, 'd', Items.diamond, 'd', Items.diamond); } else { - GameRegistry.addRecipe(new ShapedOreRecipe(painter, "qdq", "mMm", "mmm", 'm', electricSteel, 'M', machineChassi, 'q', Items.quartz, 'd', Items.diamond, - 'd', Items.diamond)); + addShaped(painter, "qdq", "mMm", "mmm", 'm', electricalSteel, 'M', machineChassi, 'q', Items.quartz, 'd', Items.diamond, 'd', Items.diamond); } //Farm ItemStack farm = new ItemStack(EnderIO.blockFarmStation, 1, 0); - if(Config.useHardRecipes) { + if (Config.useHardRecipes) { zombieBit = frankenZombie; } else { zombieBit = zombieController; } - GameRegistry.addShapedRecipe(farm, "ehe", "eme", "pzp", 'h', Items.diamond_hoe, 'm', machineChassi, 'e', electricSteel, 'z', zombieController, 'p', pulCry); + addShaped(farm, "ehe", "eme", "pzp", 'h', Items.diamond_hoe, 'm', machineChassi, 'e', electricalSteel, 'z', zombieController, 'p', pulCry); - if(Config.transceiverEnabled) { + if (Config.transceiverEnabled) { //transceiver ItemStack transceiver = new ItemStack(EnderIO.blockTransceiver, 1, 0); - if(Config.transceiverUseEasyRecipe) { - GameRegistry - .addShapedRecipe(transceiver, "oeo", "pdp", "oco", 'o', obsidian, 'e', Items.ender_eye, 'c', enderCapacitor, 'p', phasedGold, 'd', Items.diamond); + if (Config.transceiverUseEasyRecipe) { + addShaped(transceiver, "oeo", "pdp", "oco", 'o', obsidian, 'e', Items.ender_eye, 'c', enderCapacitor, 'p', phasedGold, 'd', + Items.diamond); } else { - GameRegistry - .addShapedRecipe(transceiver, "oeo", "pdp", "oco", 'o', electricSteel, 'e', enderRes, 'c', enderCapacitor, 'p', fusedQuartz, 'd', endCry); - GameRegistry.addShapelessRecipe(transceiver, new ItemStack(EnderIO.blockHyperCube, 1, 0)); + addShaped(transceiver, "oeo", "pdp", "oco", 'o', electricalSteel, 'e', enderRes, 'c', enderCapacitor, 'p', fusedQuartz, 'd', endCry); + addShapeless(transceiver, new ItemStack(EnderIO.blockHyperCube, 1, 0)); } } //solar panel - if(Config.photovoltaicCellEnabled) { + if (Config.photovoltaicCellEnabled) { ItemStack solarPanel = new ItemStack(EnderIO.blockSolarPanel, 1, 0); ItemStack advSolarPanel = new ItemStack(EnderIO.blockSolarPanel, 1, 1); - if(Config.useHardRecipes) { - GameRegistry.addRecipe(new ShapedOreRecipe(solarPanel, "efe", "pfp", "cdc", 'd', Blocks.daylight_detector, 'f', "blockGlassHardened", 'c', capacitor, - 'e', - energeticAlloy, 'p', phasedGold)); - GameRegistry.addRecipe(new ShapedOreRecipe(advSolarPanel, "efe", "pfp", "cdc", 'd', Blocks.daylight_detector, 'f', enlightedQuartz, 'c', capacitor2, - 'e', - phasedIron, 'p', phasedGold)); + if (Config.useHardRecipes) { + addShaped(solarPanel, "efe", "pfp", "cdc", 'd', Blocks.daylight_detector, 'f', "blockGlassHardened", 'c', capacitor, 'e', energeticAlloy, 'p', + phasedGold); + addShaped(advSolarPanel, "efe", "pfp", "cdc", 'd', Blocks.daylight_detector, 'f', enlightedQuartz, 'c', capacitor2, 'e', phasedIron, 'p', phasedGold); } else { - GameRegistry.addRecipe(new ShapedOreRecipe(solarPanel, "efe", "pfp", "cdc", 'd', Blocks.daylight_detector, 'f', "blockGlassHardened", 'p', silicon, - 'e', - energeticAlloy, 'c', electricSteel)); - GameRegistry.addRecipe(new ShapedOreRecipe(advSolarPanel, "efe", "pfp", "cdc", 'd', Blocks.daylight_detector, 'f', enlightedQuartz, 'p', vibCry, 'e', - phasedGold, 'c', phasedIron)); + addShaped(solarPanel, "efe", "pfp", "cdc", 'd', Blocks.daylight_detector, 'f', "blockGlassHardened", 'p', silicon, 'e', energeticAlloy, 'c', + electricalSteel); + addShaped(advSolarPanel, "efe", "pfp", "cdc", 'd', Blocks.daylight_detector, 'f', enlightedQuartz, 'p', vibCry, 'e', phasedGold, 'c', phasedIron); } } @@ -209,20 +201,19 @@ public class MachineRecipes { ItemStack powerConduit = new ItemStack(EnderIO.itemPowerConduit, 1, 0); ItemStack redstoneConduit = new ItemStack(EnderIO.itemRedstoneConduit, 1, 2); ItemStack mJMonitor = new ItemStack(EnderIO.blockPowerMonitor, 1, 0); - GameRegistry.addShapedRecipe(mJMonitor, "sms", "sMs", "sps", 's', electricSteel, 'M', machineChassi, 'm', mJReader, 'p', powerConduit, - 'r', redstoneConduit); + addShaped(mJMonitor, "sms", "sMs", "sps", 's', electricalSteel, 'M', machineChassi, 'm', mJReader, 'p', powerConduit, 'r', redstoneConduit); //Enchanter ItemStack enchanter = new ItemStack(EnderIO.blockEnchanter); - GameRegistry.addShapedRecipe(enchanter, "dbd", "sss", " s ", 'd', Items.diamond, 'b', Items.book, 's', darkSteel); + addShaped(enchanter, "dbd", "sss", " s ", 'd', Items.diamond, 'b', Items.book, 's', darkSteel); //Vacuum Chest ItemStack vacuumChest = new ItemStack(EnderIO.blockVacuumChest); - GameRegistry.addShapedRecipe(vacuumChest, "iii", "ici", "ipi", 'i', Items.iron_ingot, 'c', Blocks.chest, 'p', pulCry); + addShaped(vacuumChest, "iii", "ici", "ipi", 'i', Items.iron_ingot, 'c', Blocks.chest, 'p', pulCry); //Soul Binder - ItemStack enderBit; - if(Config.soulBinderRequiresEndermanSkull) { + Object enderBit; + if (Config.soulBinderRequiresEndermanSkull) { enderBit = new ItemStack(EnderIO.blockEndermanSkull); } else { enderBit = pulCry; @@ -231,29 +222,28 @@ public class MachineRecipes { ItemStack zombieSkull = new ItemStack(Items.skull, 1, 4); ItemStack skeletonSkull = new ItemStack(Items.skull, 1, 0); ItemStack soulBinder = new ItemStack(EnderIO.blockSoulFuser); - GameRegistry.addShapedRecipe(soulBinder, "ses", "zmc", "sks", 's', soularium, 'm', machineChassi, 'e', enderBit, 'z', zombieSkull, 'c', creeperSkull, 'k', - skeletonSkull); + addShaped(soulBinder, "ses", "zmc", "sks", 's', soularium, 'm', machineChassi, 'e', enderBit, 'z', zombieSkull, 'c', creeperSkull, 'k', skeletonSkull); //Attractor ItemStack attractor = new ItemStack(EnderIO.blockAttractor); ItemStack attractorCrystal = new ItemStack(EnderIO.itemMaterial, 1, Material.ATTRACTOR_CRYSTAL.ordinal()); - GameRegistry.addShapedRecipe(attractor, " c ", "ese", "sms", 's', soularium, 'm', machineChassi, 'c', attractorCrystal, 'e', energeticAlloy); + addShaped(attractor, " c ", "ese", "sms", 's', soularium, 'm', machineChassi, 'c', attractorCrystal, 'e', energeticAlloy); //Aversion ItemStack aversion = new ItemStack(EnderIO.blockSpawnGuard); ItemStack tormentedEnderman = new ItemStack(EnderIO.blockEndermanSkull, 1, BlockEndermanSkull.SkullType.TORMENTED.ordinal()); - GameRegistry.addShapedRecipe(aversion, " c ", "ese", "sms", 's', soularium, 'm', machineChassi, 'c', tormentedEnderman, 'e', energeticAlloy); + addShaped(aversion, " c ", "ese", "sms", 's', soularium, 'm', machineChassi, 'c', tormentedEnderman, 'e', energeticAlloy); //Experience ItemStack xp = new ItemStack(EnderIO.blockExperianceOblisk); ItemStack xpItem = new ItemStack(EnderIO.itemXpTransfer); - GameRegistry.addShapedRecipe(xp, " x ", " s ", "sms", 's', soularium, 'm', machineChassi, 'x', xpItem); + addShaped(xp, " x ", " s ", "sms", 's', soularium, 'm', machineChassi, 'x', xpItem); //Weather ItemStack weather = new ItemStack(EnderIO.blockWeatherObelisk); ItemStack weatherItem = new ItemStack(EnderIO.itemMaterial, 1, Material.WEATHER_CRYSTAL.ordinal()); - GameRegistry.addShapedRecipe(weather, " x ", "ese", "sbs", 'x', weatherItem, 'e', energeticAlloy, 's', soularium, 'b', new ItemStack(EnderIO.blockCapBank, - 1, CapBankType.getMetaFromType(CapBankType.SIMPLE))); + addShaped(weather, " x ", "ese", "sbs", 'x', weatherItem, 'e', energeticAlloy, 's', soularium, 'b', + new ItemStack(EnderIO.blockCapBank, 1, CapBankType.getMetaFromType(CapBankType.SIMPLE))); ClearConfigRecipe inst = new ClearConfigRecipe(); MinecraftForge.EVENT_BUS.register(inst); @@ -264,65 +254,52 @@ public class MachineRecipes { ItemStack poweredLampInv = new ItemStack(EnderIO.blockElectricLight, 1, BlockItemElectricLight.Type.ELECTRIC_INV.ordinal()); ItemStack wirelessLamp = new ItemStack(EnderIO.blockElectricLight, 1, BlockItemElectricLight.Type.WIRELESS.ordinal()); ItemStack wirelessLampInv = new ItemStack(EnderIO.blockElectricLight, 1, BlockItemElectricLight.Type.WIRELESS_INV.ordinal()); - GameRegistry.addShapelessRecipe(wirelessLamp, poweredLamp, enderRes); - GameRegistry.addShapelessRecipe(wirelessLamp, wirelessLampInv, Blocks.redstone_torch); - GameRegistry.addShapelessRecipe(wirelessLampInv, poweredLampInv, enderRes); - GameRegistry.addShapelessRecipe(wirelessLampInv, wirelessLamp, Blocks.redstone_torch); + addShapeless(wirelessLamp, poweredLamp, enderRes); + addShapeless(wirelessLamp, wirelessLampInv, Blocks.redstone_torch); + addShapeless(wirelessLampInv, poweredLampInv, enderRes); + addShapeless(wirelessLampInv, wirelessLamp, Blocks.redstone_torch); //inventory panel ItemStack awareness = new ItemStack(EnderIO.itemFunctionUpgrade, 1, FunctionUpgrade.INVENTORY_PANEL.ordinal()); - GameRegistry.addRecipe(new ShapedOreRecipe(awareness, "bsb", "ses", "bib", 'b', conduitBinder, 's', silicon, 'e', Items.ender_eye, 'i', electricSteel)); + addShaped(awareness, "bsb", "ses", "bib", 'b', binder, 's', silicon, 'e', Items.ender_eye, 'i', electricalSteel); ItemStack invPanel = new ItemStack(EnderIO.blockInventoryPanel); - GameRegistry.addShapedRecipe(invPanel, "dad", "psp", "dtd", 'd', darkSteel, 'a', awareness, 'p', pulCry, 's', sentientEnder, 't', basicTank); - } + addShaped(invPanel, "dad", "psp", "dtd", 'd', darkSteel, 'a', awareness, 'p', pulCry, 's', sentientEnder, 't', basicTank); - public static void addOreDictionaryRecipes() { - ItemStack capacitor = new ItemStack(itemBasicCapacitor, 1, 0); ItemStack machineChassis = new ItemStack(EnderIO.itemMachinePart, 1, MachinePart.MACHINE_CHASSI.ordinal()); - ItemStack fusedQuartz = new ItemStack(EnderIO.blockFusedQuartz, 1, 0); //powered light - ItemStack poweredLamp = new ItemStack(EnderIO.blockElectricLight, 1, 0); ItemStack glowstone = new ItemStack(Items.glowstone_dust); - if(Config.useHardRecipes) { - GameRegistry.addRecipe(new ShapedOreRecipe(poweredLamp, "ggg", "sds", "scs", 'g', fusedQuartz, 'd', glowstone, 's', "itemSilicon", 'c', capacitor)); + if (Config.useHardRecipes) { + addShaped(poweredLamp, "ggg", "sds", "scs", 'g', fusedQuartz, 'd', glowstone, 's', "itemSilicon", 'c', capacitor); } else { - GameRegistry.addRecipe(new ShapedOreRecipe(poweredLamp, "ggg", "sds", "scs", 'g', "glass", 'd', glowstone, 's', "itemSilicon", 'c', capacitor)); + addShaped(poweredLamp, "ggg", "sds", "scs", 'g', "glass", 'd', glowstone, 's', "itemSilicon", 'c', capacitor); } ItemStack invPoweredLamp = new ItemStack(EnderIO.blockElectricLight, 1, 1); - GameRegistry.addShapelessRecipe(invPoweredLamp, poweredLamp, Blocks.redstone_torch); - GameRegistry.addShapelessRecipe(poweredLamp, invPoweredLamp, Blocks.redstone_torch); + addShapeless(invPoweredLamp, poweredLamp, Blocks.redstone_torch); + addShapeless(poweredLamp, invPoweredLamp, Blocks.redstone_torch); //light ItemStack lamp = new ItemStack(EnderIO.blockElectricLight, 1, 2); - GameRegistry.addRecipe(new ShapedOreRecipe(lamp, " ", "ggg", "isi", 'g', "glass", 's', Blocks.glowstone, 'i', Items.iron_ingot)); + addShaped(lamp, " ", "ggg", "isi", 'g', "glass", 's', Blocks.glowstone, 'i', Items.iron_ingot); ItemStack invLamp = new ItemStack(EnderIO.blockElectricLight, 1, 3); - GameRegistry.addShapelessRecipe(invLamp, lamp, Blocks.redstone_torch); - GameRegistry.addShapelessRecipe(lamp, invLamp, Blocks.redstone_torch); + addShapeless(invLamp, lamp, Blocks.redstone_torch); + addShapeless(lamp, invLamp, Blocks.redstone_torch); //MJ Reader - ItemStack mJReader = new ItemStack(EnderIO.itemConduitProbe, 1, 0); - ItemStack electricalSteel = new ItemStack(EnderIO.itemAlloy, 1, Alloy.ELECTRICAL_STEEL.ordinal()); - ItemStack powerConduit = new ItemStack(EnderIO.itemPowerConduit, 1, 0); - ItemStack redstoneConduit = new ItemStack(EnderIO.itemRedstoneConduit, 1, 2); - GameRegistry.addRecipe(new ShapedOreRecipe(mJReader, "epe", "gcg", "srs", 'p', powerConduit, 'r', redstoneConduit, 'c', Items.comparator, 'g', - Blocks.glass_pane, 's', "itemSilicon", 'e', - electricalSteel)); + addShaped(mJReader, "epe", "gcg", "srs", 'p', powerConduit, 'r', redstoneConduit, 'c', Items.comparator, 'g', Blocks.glass_pane, 's', "itemSilicon", 'e', + electricalSteel); //Slice'N'Splice - ItemStack soularium = new ItemStack(EnderIO.itemAlloy, 1, Alloy.SOULARIUM.ordinal()); ItemStack sns = new ItemStack(EnderIO.blockSliceAndSplice); - GameRegistry.addRecipe(new ShapedOreRecipe(sns, "iki", "ams", "iii", 'i', soularium, 'm', machineChassis, 'k', "itemSkull", 'a', Items.iron_axe, 's', - Items.shears)); - - //Buffer - ItemStack itemBuffer = Type.getStack(Type.ITEM); - ItemStack powerBuffer = Type.getStack(Type.POWER); - ItemStack omniBuffer = Type.getStack(Type.OMNI); - GameRegistry.addRecipe(new ShapedOreRecipe(itemBuffer, "isi", "scs", "isi", 'i', "ingotIron", 's', "ingotElectricalSteel", 'c', Blocks.chest)); - GameRegistry.addRecipe(new ShapedOreRecipe(powerBuffer, "isi", "sfs", "isi", 'i', "ingotIron", 's', "ingotElectricalSteel", 'f', machineChassis)); - GameRegistry.addRecipe(new ShapelessOreRecipe(omniBuffer, itemBuffer, powerBuffer)); + addShaped(sns, "iki", "ams", "iii", 'i', soularium, 'm', machineChassis, 'k', "itemSkull", 'a', Items.iron_axe, 's', Items.shears); + //Buffer + ItemStack itemBuffer = Type.getStack(Type.ITEM); + ItemStack powerBuffer = Type.getStack(Type.POWER); + ItemStack omniBuffer = Type.getStack(Type.OMNI); + addShaped(itemBuffer, "isi", "scs", "isi", 'i', "ingotIron", 's', "ingotElectricalSteel", 'c', Blocks.chest); + addShaped(powerBuffer, "isi", "sfs", "isi", 'i', "ingotIron", 's', "ingotElectricalSteel", 'f', machineChassis); + addShapeless(omniBuffer, itemBuffer, powerBuffer); } -} \ No newline at end of file +} diff --git a/src/main/java/crazypants/enderio/machine/buffer/BlockBuffer.java b/src/main/java/crazypants/enderio/machine/buffer/BlockBuffer.java index 8647fd5e..b7731771 100644 --- a/src/main/java/crazypants/enderio/machine/buffer/BlockBuffer.java +++ b/src/main/java/crazypants/enderio/machine/buffer/BlockBuffer.java @@ -11,6 +11,7 @@ import net.minecraft.util.IIcon; import net.minecraft.util.MovingObjectPosition; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; +import net.minecraftforge.common.util.ForgeDirection; import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @@ -184,4 +185,18 @@ public class BlockBuffer extends AbstractMachineBlock implements IFa return this; } + @Override + public Block getVisualBlock(IBlockAccess world, int x, int y, int z, ForgeDirection side) { + return getFacade(world, x, y, z, side.ordinal()); + } + + @Override + public int getVisualMeta(IBlockAccess world, int x, int y, int z, ForgeDirection side) { + return getFacadeMetadata(world, x, y, z, side.ordinal()); + } + + @Override + public boolean supportsVisualConnections() { + return true; + } } diff --git a/src/main/java/crazypants/enderio/machine/crafter/ContainerCrafter.java b/src/main/java/crazypants/enderio/machine/crafter/ContainerCrafter.java index dc91def4..9e728d70 100644 --- a/src/main/java/crazypants/enderio/machine/crafter/ContainerCrafter.java +++ b/src/main/java/crazypants/enderio/machine/crafter/ContainerCrafter.java @@ -84,7 +84,7 @@ public class ContainerCrafter extends AbstractMachineContainer { if(refStack == null || itemStack == null) { return false; } - return refStack.isItemEqual(itemStack); + return TileCrafter.compareDamageable(itemStack, refStack); } } diff --git a/src/main/java/crazypants/enderio/machine/crafter/DummyCraftingGrid.java b/src/main/java/crazypants/enderio/machine/crafter/DummyCraftingGrid.java index c8ce0268..019b4574 100644 --- a/src/main/java/crazypants/enderio/machine/crafter/DummyCraftingGrid.java +++ b/src/main/java/crazypants/enderio/machine/crafter/DummyCraftingGrid.java @@ -1,7 +1,5 @@ package crazypants.enderio.machine.crafter; -import java.util.List; - import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; @@ -20,17 +18,6 @@ public class DummyCraftingGrid implements IInventory { return inv[9]; } - public void copyRequiredInputs(List required) { - for (int i = 0; i < 9; i++) { - ItemStack is = inv[i]; - if(is != null) { - ItemStack copy = is.copy(); - copy.stackSize = 1; - required.add(copy); - } - } - } - @Override public int getSizeInventory() { return inv.length; diff --git a/src/main/java/crazypants/enderio/machine/crafter/TileCrafter.java b/src/main/java/crazypants/enderio/machine/crafter/TileCrafter.java index 2ee424d3..8920d42f 100644 --- a/src/main/java/crazypants/enderio/machine/crafter/TileCrafter.java +++ b/src/main/java/crazypants/enderio/machine/crafter/TileCrafter.java @@ -3,6 +3,7 @@ package crazypants.enderio.machine.crafter; import java.util.ArrayList; import java.util.Iterator; import java.util.List; +import java.util.UUID; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.Container; @@ -10,12 +11,17 @@ import net.minecraft.inventory.InventoryCrafting; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.CraftingManager; import net.minecraft.nbt.NBTTagCompound; +import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.common.util.FakePlayer; import com.enderio.core.common.util.ItemUtil; +import com.mojang.authlib.GameProfile; +import cpw.mods.fml.common.gameevent.PlayerEvent.ItemCraftedEvent; import crazypants.enderio.ModObject; import crazypants.enderio.config.Config; import crazypants.enderio.machine.AbstractPowerConsumerEntity; +import crazypants.enderio.machine.FakePlayerEIO; import crazypants.enderio.machine.IItemBuffer; import crazypants.enderio.machine.SlotDefinition; import crazypants.enderio.power.BasicCapacitor; @@ -26,11 +32,13 @@ public class TileCrafter extends AbstractPowerConsumerEntity implements IItemBuf DummyCraftingGrid craftingGrid = new DummyCraftingGrid(); - private List containerItems; + private final List containerItems; private boolean bufferStacks = true; private long ticksSinceLastCraft = 0; + + private FakePlayer playerInst; public TileCrafter() { super(new SlotDefinition(9, 1)); @@ -55,7 +63,7 @@ public class TileCrafter extends AbstractPowerConsumerEntity implements IItemBuf if(!slotDefinition.isInputSlot(slot)) { return false; } - return craftingGrid.inv[slot] != null && craftingGrid.inv[slot].isItemEqual(itemstack); + return craftingGrid.inv[slot] != null && compareDamageable(itemstack, craftingGrid.inv[slot]); } @Override @@ -91,10 +99,7 @@ public class TileCrafter extends AbstractPowerConsumerEntity implements IItemBuf return false; } - List required = new ArrayList(); - craftingGrid.copyRequiredInputs(required); - if(hasRequiredInput(required)) { - craftRecipe(); + if(craftRecipe()) { int used = Math.min(getEnergyStored(), Config.crafterRfPerCraft); setEnergyStored(getEnergyStored() - used); } @@ -125,7 +130,20 @@ public class TileCrafter extends AbstractPowerConsumerEntity implements IItemBuf } } - private void craftRecipe() { + static boolean compareDamageable(ItemStack stack, ItemStack req) { + if(stack.isItemEqual(req)) { + return true; + } + if(stack.isItemStackDamageable() && stack.getItem() == req.getItem()) { + return stack.getItemDamage() < stack.getMaxDamage(); + } + return false; + } + + private static final UUID uuid = UUID.fromString("9b381cae-3c95-4a64-b958-1e25b0a4c790"); + private static final GameProfile DUMMY_PROFILE = new GameProfile(uuid, "[EioCrafter]"); + + private boolean craftRecipe() { // (1) Find the items to craft with and put a copy into a temp crafting grid; // also record what was used to destroy it later @@ -136,33 +154,40 @@ public class TileCrafter extends AbstractPowerConsumerEntity implements IItemBuf } }, 3, 3); - ItemStack[] shadowInventory = new ItemStack[9]; - for (int i = 0; i < 9; i++) { - shadowInventory[i] = inventory[i] == null ? null : inventory[i].copy(); - } + int[] usedItems = new int[9]; for (int j = 0; j < 9; j++) { ItemStack req = craftingGrid.getStackInSlot(j); - for (int i = 0; i < 9 && req != null; i++) { - if (shadowInventory[i] != null && shadowInventory[i].stackSize > 0 && shadowInventory[i].isItemEqual(req)) { - req = null; - shadowInventory[i].stackSize--; - ItemStack craftingItem = shadowInventory[i].copy(); - craftingItem.stackSize = 1; - inv.setInventorySlotContents(j, craftingItem); + if (req != null) { + for (int i = 0; i < 9; i++) { + if (inventory[i] != null && inventory[i].stackSize > usedItems[i] && compareDamageable(inventory[i], req)) { + req = null; + usedItems[i]++; + ItemStack craftingItem = inventory[i].copy(); + craftingItem.stackSize = 1; + inv.setInventorySlotContents(j, craftingItem); + break; + } + } + if (req != null) { + return false; } } } // (2) Try to craft with the temp grid ItemStack output = CraftingManager.getInstance().findMatchingRecipe(inv, worldObj); - + // (3) If we got a result, ... if (output != null) { + if (playerInst == null) { + playerInst = new FakePlayerEIO(worldObj, getLocation(), DUMMY_PROFILE); + } + MinecraftForge.EVENT_BUS.post(new ItemCraftedEvent(playerInst, output, inv)); // (3a) ... remove the used up items and ... for (int i = 0; i < 9; i++) { - while (shadowInventory[i] != null && inventory[i] != null && shadowInventory[i].stackSize < inventory[i].stackSize) { + for (int j = 0; j < usedItems[i] && inventory[i] != null; j++) { setInventorySlotContents(i, eatOneItemForCrafting(inventory[i].copy())); } } @@ -190,14 +215,20 @@ public class TileCrafter extends AbstractPowerConsumerEntity implements IItemBuf // Crafting failed. This is not supposed to happen, but if a recipe is nbt-sensitive, it can. // To avoid being stuck in a dead loop, we flush the non-working input items. for (int j = 0; j < 9; j++) { - if (shadowInventory[j] != null) { - setInventorySlotContents(j, shadowInventory[j].stackSize > 0 ? shadowInventory[j] : null); - } - if (craftingGrid.getStackInSlot(j) != null) { - containerItems.add(craftingGrid.getStackInSlot(j)); + if (usedItems[j] > 0 && inventory[j] != null) { + ItemStack rejected = inventory[j].copy(); + rejected.stackSize = Math.min(inventory[j].stackSize, usedItems[j]); + containerItems.add(rejected); + if (inventory[j].stackSize <= usedItems[j]) { + inventory[j] = null; + } else { + inventory[j].stackSize -= usedItems[j]; + } } } } + + return true; } private ItemStack eatOneItemForCrafting(ItemStack avail) { @@ -254,30 +285,6 @@ public class TileCrafter extends AbstractPowerConsumerEntity implements IItemBuf return output.getMaxStackSize() >= (inventory[9].stackSize + output.stackSize); } - private boolean hasRequiredInput(List required) { - List available = new ArrayList(); - for (int i = 0; i < 9; i++) { - ItemStack is = inventory[i]; - if(is != null) { - available.add(is.copy()); - } - } - for (ItemStack req : required) { - boolean foundReq = false; - for (ItemStack avail : available) { - if(req.isItemEqual(avail) && avail.stackSize > 0) { - avail.stackSize--; - foundReq = true; - break; - } - } - if(!foundReq) { - return false; - } - } - return true; - } - @Override public int getInventoryStackLimit() { return bufferStacks ? 64 : 1; diff --git a/src/main/java/crazypants/enderio/machine/crusher/CrusherRecipeManager.java b/src/main/java/crazypants/enderio/machine/crusher/CrusherRecipeManager.java index 5a5d994c..9ad9e3a4 100644 --- a/src/main/java/crazypants/enderio/machine/crusher/CrusherRecipeManager.java +++ b/src/main/java/crazypants/enderio/machine/crusher/CrusherRecipeManager.java @@ -66,7 +66,7 @@ public class CrusherRecipeManager { int id = OreDictionary.getOreID(input.item); if(id >= 0) { String name = OreDictionary.getOreName(id); - if(name.startsWith("ingot") || name.startsWith("block")) { + if(name.startsWith("ingot") || name.startsWith("block") || name.startsWith("nugget")) { addExcludedStack(input.item); return true; } diff --git a/src/main/java/crazypants/enderio/machine/enchanter/GuiEnchanter.java b/src/main/java/crazypants/enderio/machine/enchanter/GuiEnchanter.java index e005954b..388e9579 100644 --- a/src/main/java/crazypants/enderio/machine/enchanter/GuiEnchanter.java +++ b/src/main/java/crazypants/enderio/machine/enchanter/GuiEnchanter.java @@ -1,27 +1,40 @@ package crazypants.enderio.machine.enchanter; import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.inventory.GuiContainer; import net.minecraft.client.resources.I18n; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import org.lwjgl.opengl.GL11; +import com.enderio.core.client.gui.GuiContainerBase; +import com.enderio.core.client.gui.button.IconButton; import com.enderio.core.client.render.RenderUtil; import crazypants.enderio.EnderIO; import crazypants.enderio.gui.IconEIO; -public class GuiEnchanter extends GuiContainer { +public class GuiEnchanter extends GuiContainerBase { private TileEnchanter te; private ContainerEnchanter container; + private IconButton recipeButton; public GuiEnchanter(EntityPlayer player, InventoryPlayer inventory, TileEnchanter te) { super(new ContainerEnchanter(player, inventory, te)); container = (ContainerEnchanter)inventorySlots; this.te = te; + + recipeButton = new IconButton(this, 100, 154, 8, IconEIO.RECIPE); + recipeButton.visible = false; + recipeButton.setIconMargin(3, 3); + } + + @Override + public void initGui() { + super.initGui(); + recipeButton.onGuiInit(); + recipeButton.visible = EnderIO.proxy.isNeiInstalled(); } @Override @@ -52,5 +65,4 @@ public class GuiEnchanter extends GuiContainer { drawCenteredString(Minecraft.getMinecraft().fontRenderer, s, sx + xSize/2, sy + 57, col); } } - } diff --git a/src/main/java/crazypants/enderio/machine/farm/FarmersRegistry.java b/src/main/java/crazypants/enderio/machine/farm/FarmersRegistry.java index 483c158a..83304dbe 100644 --- a/src/main/java/crazypants/enderio/machine/farm/FarmersRegistry.java +++ b/src/main/java/crazypants/enderio/machine/farm/FarmersRegistry.java @@ -1,10 +1,14 @@ package crazypants.enderio.machine.farm; +import java.util.Iterator; +import java.util.regex.Pattern; + import net.minecraft.block.Block; import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; +import cpw.mods.fml.common.Loader; import cpw.mods.fml.common.registry.GameRegistry; import crazypants.enderio.config.Config; import crazypants.enderio.machine.farm.farmers.CocoaFarmer; @@ -35,6 +39,7 @@ public final class FarmersRegistry { addMFR(); addThaumcraft(); addFlowers(); + addGrowableOres(); FarmersCommune.joinCommune(new StemFarmer(Blocks.reeds, new ItemStack(Items.reeds))); FarmersCommune.joinCommune(new StemFarmer(Blocks.cactus, new ItemStack(Blocks.cactus))); @@ -213,6 +218,28 @@ public final class FarmersRegistry { GameRegistry.findBlock("Botany", "flower"), GameRegistry.findBlock("Botania", "flower") ) ); } + + @SuppressWarnings("unchecked") + private static void addGrowableOres() { + String mod = "B0bGrowsOre"; + if (!Loader.isModLoaded(mod)) { + return; + } + Pattern[] growableOres = { Pattern.compile("(.+)Reed"), Pattern.compile("oreGrowable(.+)") }; + + Iterator blockIter = Block.blockRegistry.iterator(); + while (blockIter.hasNext()) { + Block block = blockIter.next(); + String name = Block.blockRegistry.getNameForObject(block); + if (name != null && name.startsWith(mod)) { + for (Pattern blockPattern : growableOres) { + if (blockPattern.matcher(name).find()) { + FarmersCommune.joinCommune(new StemFarmer(block, new ItemStack(block))); + } + } + } + } + } private FarmersRegistry() { } diff --git a/src/main/java/crazypants/enderio/machine/farm/GuiFarmStation.java b/src/main/java/crazypants/enderio/machine/farm/GuiFarmStation.java index dd5e95d1..589f5426 100644 --- a/src/main/java/crazypants/enderio/machine/farm/GuiFarmStation.java +++ b/src/main/java/crazypants/enderio/machine/farm/GuiFarmStation.java @@ -24,6 +24,7 @@ public class GuiFarmStation extends GuiPoweredMachineBase { public GuiFarmStation(InventoryPlayer par1InventoryPlayer, TileFarmStation machine) { super(machine, new FarmStationContainer(par1InventoryPlayer, machine)); + setYSize(ySize + 3); } @SuppressWarnings("unchecked") @@ -103,5 +104,4 @@ public class GuiFarmStation extends GuiPoweredMachineBase { protected int getPowerHeight() { return super.getPowerHeight() + 3; } - } diff --git a/src/main/java/crazypants/enderio/machine/farm/farmers/StemFarmer.java b/src/main/java/crazypants/enderio/machine/farm/farmers/StemFarmer.java index 447a7a0e..ae6c4e95 100644 --- a/src/main/java/crazypants/enderio/machine/farm/farmers/StemFarmer.java +++ b/src/main/java/crazypants/enderio/machine/farm/farmers/StemFarmer.java @@ -52,18 +52,23 @@ public class StemFarmer extends CustomSeedFarmer { boolean done = false; do{ harvestCoord = harvestCoord.getLocation(ForgeDirection.UP); - if(plantedBlock == farm.getBlock(harvestCoord) && farm.hasHoe()) { + boolean hasHoe = farm.hasHoe(); + if(plantedBlock == farm.getBlock(harvestCoord) && hasHoe) { res.harvestedBlocks.add(harvestCoord); ArrayList drops = plantedBlock.getDrops(farm.getWorldObj(), harvestCoord.x, harvestCoord.y, harvestCoord.z, meta, farm.getMaxLootingValue()); if(drops != null) { for(ItemStack drop : drops) { res.drops.add(new EntityItem(farm.getWorldObj(), bc.x + 0.5, bc.y + 0.5, bc.z + 0.5, drop.copy())); } - } farm.damageHoe(1, harvestCoord); farm.actionPerformed(false); } else { + if (!hasHoe) { + farm.setNotification(TileFarmStation.NOTIFICATION_NO_HOE); + } else { + farm.clearNotification(); + } done = true; } } while(!done); diff --git a/src/main/java/crazypants/enderio/machine/generator/combustion/TileCombustionGenerator.java b/src/main/java/crazypants/enderio/machine/generator/combustion/TileCombustionGenerator.java index c3392aab..17001332 100644 --- a/src/main/java/crazypants/enderio/machine/generator/combustion/TileCombustionGenerator.java +++ b/src/main/java/crazypants/enderio/machine/generator/combustion/TileCombustionGenerator.java @@ -421,11 +421,13 @@ public class TileCombustionGenerator extends AbstractGeneratorEntity implements @Override public FluidTank getInputTank(FluidStack forFluidType) { - if (FluidFuelRegister.instance.getCoolant(forFluidType.getFluid()) != null) { - return coolantTank; - } - if (FluidFuelRegister.instance.getFuel(forFluidType.getFluid()) != null) { - return fuelTank; + if (forFluidType != null) { + if (FluidFuelRegister.instance.getCoolant(forFluidType.getFluid()) != null) { + return coolantTank; + } + if (FluidFuelRegister.instance.getFuel(forFluidType.getFluid()) != null) { + return fuelTank; + } } return null; } diff --git a/src/main/java/crazypants/enderio/machine/invpanel/server/AbstractInventory.java b/src/main/java/crazypants/enderio/machine/invpanel/server/AbstractInventory.java index 484643e2..e279f14b 100644 --- a/src/main/java/crazypants/enderio/machine/invpanel/server/AbstractInventory.java +++ b/src/main/java/crazypants/enderio/machine/invpanel/server/AbstractInventory.java @@ -3,68 +3,80 @@ package crazypants.enderio.machine.invpanel.server; import net.minecraft.item.ItemStack; abstract class AbstractInventory { - static final ItemEntry[] NO_SLOTS = new ItemEntry[0]; - ItemEntry[] slotItems = NO_SLOTS; - int[] itemCounts; + static final SlotKey[] NO_SLOTS = new SlotKey[0]; + SlotKey[] slotKeys = NO_SLOTS; - protected void setEmpty(InventoryDatabaseServer db, int aiIndex) { - if (slotItems.length != 0) { - reset(db, 0, aiIndex); + protected void setEmpty(InventoryDatabaseServer db) { + if (slotKeys.length != 0) { + reset(db, 0); } } - protected void reset(InventoryDatabaseServer db, int count, int aiIndex) { - for (int slot = 0; slot < slotItems.length; slot++) { - ItemEntry key = slotItems[slot]; - if (key != null) { - key.removeSlot(aiIndex, slot); - db.entryChanged(key); + protected void reset(InventoryDatabaseServer db, int count) { + for (SlotKey slotKey : slotKeys) { + if(slotKey != null) { + slotKey.remove(db); } } - slotItems = new ItemEntry[count]; - itemCounts = new int[count]; + slotKeys = new SlotKey[count]; } - protected void updateSlot(InventoryDatabaseServer db, int slot, int aiIndex, ItemStack stack) { - ItemEntry current = slotItems[slot]; - if (stack == null || stack.stackSize <= 0) { - if (current != null) { - slotItems[slot] = null; - itemCounts[slot] = 0; - current.removeSlot(aiIndex, slot); - db.entryChanged(current); - } + protected void updateSlot(InventoryDatabaseServer db, int slot, ItemStack stack) { + if (stack == null) { + emptySlot(db, slot); } else { - ItemEntry key = db.lookupItem(stack, current, true); - if (key != current) { - slotItems[slot] = key; - itemCounts[slot] = stack.stackSize; - key.addSlot(aiIndex, slot); - db.entryChanged(key); - if (current != null) { - current.removeSlot(aiIndex, slot); - db.entryChanged(current); - } - } else if (itemCounts[slot] != stack.stackSize) { - itemCounts[slot] = stack.stackSize; - db.entryChanged(current); - } + updateSlot(db, slot, stack, stack.stackSize); } } - protected void updateCount(InventoryDatabaseServer db, int slot, int aiIndex, ItemEntry entry, int count) { - if (itemCounts[slot] != count) { - itemCounts[slot] = count; + protected void updateSlot(InventoryDatabaseServer db, int slot, ItemStack stack, int count) { + SlotKey slotKey = slotKeys[slot]; + ItemEntry current = slotKey != null ? slotKey.item : null; + ItemEntry key = db.lookupItem(stack, current, true); + if (key != current) { + updateSlotKey(db, slot, slotKey, key, count); + } else if (slotKey != null && slotKey.count != count) { + slotKey.count = count; + db.entryChanged(current); + } + } + + protected void emptySlot(InventoryDatabaseServer db, int slot) { + SlotKey slotKey = slotKeys[slot]; + if (slotKey != null) { + slotKey.remove(db); + slotKeys[slot] = null; + } + } + + private void updateSlotKey(InventoryDatabaseServer db, int slot, SlotKey slotKey, ItemEntry key, int count) { + if (slotKey != null) { + slotKey.remove(db); + slotKey = null; + } + if (key != null) { + slotKey = new SlotKey(this, slot, key, count); + key.addSlot(slotKey); + db.entryChanged(key); + } + slotKeys[slot] = slotKey; + } + + protected void updateCount(InventoryDatabaseServer db, int slot, ItemEntry entry, int count) { + SlotKey slotKey = slotKeys[slot]; + if (slotKey != null && slotKey.count != count && slotKey.item == entry) { if (count == 0) { - slotItems[slot] = null; - entry.removeSlot(aiIndex, slot); + slotKey.remove(db); + slotKeys[slot] = null; + } else { + slotKey.count = count; + db.entryChanged(slotKey.item); } - db.entryChanged(entry); } } - abstract int scanInventory(InventoryDatabaseServer db, int aiIndex); + abstract int scanInventory(InventoryDatabaseServer db); - abstract int extractItem(InventoryDatabaseServer db, ItemEntry entry, int slot, int aiIndex, int count); + abstract int extractItem(InventoryDatabaseServer db, ItemEntry entry, int slot, int count); } diff --git a/src/main/java/crazypants/enderio/machine/invpanel/server/DSUInventory.java b/src/main/java/crazypants/enderio/machine/invpanel/server/DSUInventory.java index 72ef0072..3bbe76ba 100644 --- a/src/main/java/crazypants/enderio/machine/invpanel/server/DSUInventory.java +++ b/src/main/java/crazypants/enderio/machine/invpanel/server/DSUInventory.java @@ -8,23 +8,18 @@ class DSUInventory extends AbstractInventory { DSUInventory(IDeepStorageUnit dsu) { this.dsu = dsu; + this.slotKeys = new SlotKey[1]; } @Override - public int scanInventory(InventoryDatabaseServer db, int aiIndex) { - if (slotItems.length != 1) { - reset(db, 1, aiIndex); - } + public int scanInventory(InventoryDatabaseServer db) { ItemStack stack = dsu.getStoredItemType(); - updateSlot(db, 0, aiIndex, stack); + updateSlot(db, 0, stack); return 1; } @Override - public int extractItem(InventoryDatabaseServer db, ItemEntry entry, int slot, int aiIndex, int count) { - if (slotItems.length != 1) { - return 0; - } + public int extractItem(InventoryDatabaseServer db, ItemEntry entry, int slot, int count) { ItemStack stack = dsu.getStoredItemType(); if (db.lookupItem(stack, entry, false) != entry) { return 0; @@ -35,7 +30,7 @@ class DSUInventory extends AbstractInventory { } remaining -= count; dsu.setStoredItemCount(remaining); - updateCount(db, slot, aiIndex, entry, remaining); + updateCount(db, 0, entry, remaining); return count; } diff --git a/src/main/java/crazypants/enderio/machine/invpanel/server/DrawerGroupInventory.java b/src/main/java/crazypants/enderio/machine/invpanel/server/DrawerGroupInventory.java new file mode 100644 index 00000000..be93d634 --- /dev/null +++ b/src/main/java/crazypants/enderio/machine/invpanel/server/DrawerGroupInventory.java @@ -0,0 +1,66 @@ +package crazypants.enderio.machine.invpanel.server; + +import com.jaquadro.minecraft.storagedrawers.api.storage.IDrawer; +import com.jaquadro.minecraft.storagedrawers.api.storage.IDrawerGroup; +import net.minecraft.item.ItemStack; + +public class DrawerGroupInventory extends AbstractInventory { + final IDrawerGroup dg; + + public DrawerGroupInventory(IDrawerGroup dg) { + this.dg = dg; + } + + @Override + int scanInventory(InventoryDatabaseServer db) { + int count = dg.getDrawerCount(); + if (count == 0) { + setEmpty(db); + return 0; + } + if (count != slotKeys.length) { + reset(db, count); + } + for (int i = 0; i < count; i++) { + IDrawer drawer = dg.getDrawer(i); + ItemStack stack; + int quantity; + if (drawer != null && + (quantity = drawer.getStoredItemCount()) > 0 && + (stack = drawer.getStoredItemPrototype()) != null && + drawer.canItemBeExtracted(stack)) { + updateSlot(db, i, stack, quantity); + } else { + emptySlot(db, i); + } + } + return count; + } + + @Override + int extractItem(InventoryDatabaseServer db, ItemEntry entry, int slot, int count) { + if (slot >= dg.getDrawerCount()) { + return 0; + } + IDrawer drawer = dg.getDrawer(slot); + if (drawer == null) { + return 0; + } + int remaining = drawer.getStoredItemCount(); + if (remaining <= 0) { + return 0; + } + ItemStack stack = drawer.getStoredItemPrototype(); + if (db.lookupItem(stack, entry, false) != entry) { + return 0; + } + if (count > remaining) { + count = remaining; + } + remaining -= count; + drawer.setStoredItemCount(remaining); + updateCount(db, slot, entry, remaining); + return count; + } + +} diff --git a/src/main/java/crazypants/enderio/machine/invpanel/server/InventoryDatabaseServer.java b/src/main/java/crazypants/enderio/machine/invpanel/server/InventoryDatabaseServer.java index 20a558ba..9a953d0e 100644 --- a/src/main/java/crazypants/enderio/machine/invpanel/server/InventoryDatabaseServer.java +++ b/src/main/java/crazypants/enderio/machine/invpanel/server/InventoryDatabaseServer.java @@ -21,7 +21,6 @@ import com.enderio.core.common.network.CompressedDataOutput; import net.minecraft.nbt.CompressedStreamTools; import net.minecraft.nbt.NBTTagCompound; -import powercrystals.minefactoryreloaded.api.IDeepStorageUnit; public class InventoryDatabaseServer extends InventoryDatabase { @@ -182,11 +181,7 @@ public class InventoryDatabaseServer extends InventoryDatabase { this.inventories = new AbstractInventory[sources.size()]; for(int i=0; i { } AbstractInventory inv = inventories[currentInventory]; - int slots = inv.scanInventory(this, currentInventory); + int slots = inv.scanInventory(this); currentInventory = (currentInventory+1) % inventories.length; tickPause += 1 + (slots + 8) / 9; diff --git a/src/main/java/crazypants/enderio/machine/invpanel/server/InventoryFactory.java b/src/main/java/crazypants/enderio/machine/invpanel/server/InventoryFactory.java new file mode 100644 index 00000000..f4c49701 --- /dev/null +++ b/src/main/java/crazypants/enderio/machine/invpanel/server/InventoryFactory.java @@ -0,0 +1,55 @@ +package crazypants.enderio.machine.invpanel.server; + +import com.jaquadro.minecraft.storagedrawers.api.storage.IDrawerGroup; +import cpw.mods.fml.common.Loader; +import crazypants.enderio.conduit.item.NetworkedInventory; +import java.util.ArrayList; +import net.minecraft.inventory.ISidedInventory; +import powercrystals.minefactoryreloaded.api.IDeepStorageUnit; + +public abstract class InventoryFactory { + + private static final ArrayList factories; + + static { + factories = new ArrayList(); + factories.add(new DSUFactory()); + if (Loader.isModLoaded("StorageDrawers")) { + factories.add(new DrawerFactory()); + } + } + + static AbstractInventory createInventory(NetworkedInventory ni) { + for(InventoryFactory f : factories) { + AbstractInventory ai = f.create(ni); + if (ai != null) { + return ai; + } + } + return new NormalInventory(ni); + } + + abstract AbstractInventory create(NetworkedInventory ni); + + static class DSUFactory extends InventoryFactory { + @Override + AbstractInventory create(NetworkedInventory ni) { + ISidedInventory inv = ni.getInventory(); + if (inv instanceof IDeepStorageUnit) { + return new DSUInventory((IDeepStorageUnit) inv); + } + return null; + } + } + + static class DrawerFactory extends InventoryFactory { + @Override + AbstractInventory create(NetworkedInventory ni) { + ISidedInventory inv = ni.getInventory(); + if (inv instanceof IDrawerGroup) { + return new DrawerGroupInventory((IDrawerGroup) inv); + } + return null; + } + } +} diff --git a/src/main/java/crazypants/enderio/machine/invpanel/server/ItemEntry.java b/src/main/java/crazypants/enderio/machine/invpanel/server/ItemEntry.java index dcec327e..546897ae 100644 --- a/src/main/java/crazypants/enderio/machine/invpanel/server/ItemEntry.java +++ b/src/main/java/crazypants/enderio/machine/invpanel/server/ItemEntry.java @@ -1,47 +1,42 @@ package crazypants.enderio.machine.invpanel.server; import crazypants.enderio.machine.invpanel.ItemEntryBase; -import java.util.HashSet; +import java.util.IdentityHashMap; import net.minecraft.nbt.NBTTagCompound; public class ItemEntry extends ItemEntryBase { - private final HashSet slots = new HashSet(); + private final IdentityHashMap slots = new IdentityHashMap(); public ItemEntry(int dbID, int hash, int itemID, int meta, NBTTagCompound nbt) { super(dbID, hash, itemID, meta, nbt); } - static int encodeAISlot(int aiIndex, int slot) { - return (aiIndex << 12) | slot; + void addSlot(SlotKey slotKey) { + slots.put(slotKey, slotKey); } - void addSlot(int aiIndex, int slot) { - slots.add(encodeAISlot(aiIndex, slot)); - } - - void removeSlot(int aiIndex, int slot) { - slots.remove(encodeAISlot(aiIndex, slot)); + void removeSlot(SlotKey slotKey) { + slots.remove(slotKey); } int countItems(InventoryDatabaseServer db) { int count = 0; - for (Integer idx : slots) { - AbstractInventory key = db.getInventory(idx >> 12); - count += key.itemCounts[idx & 4095]; + for (SlotKey slotKey : slots.values()) { + count += slotKey.count; } return count; } int extractItems(InventoryDatabaseServer db, int count) { int extracted = 0; - Integer[] copy = slots.toArray(new Integer[slots.size()]); - for (Integer idx : copy) { - int aiIndex = idx >> 12; - int slotIndex = idx & 4095; - AbstractInventory key = db.getInventory(aiIndex); - int amount = key.extractItem(db, this, slotIndex, aiIndex, count); + SlotKey[] copy = slots.values().toArray(new SlotKey[slots.size()]); + for (SlotKey slotKey : copy) { + int amount = slotKey.inv.extractItem(db, this, slotKey.slot, count); count -= amount; extracted += amount; + if (count <= 0) { + break; + } } return extracted; } diff --git a/src/main/java/crazypants/enderio/machine/invpanel/server/NormalInventory.java b/src/main/java/crazypants/enderio/machine/invpanel/server/NormalInventory.java index 87ca9423..cd6caa95 100644 --- a/src/main/java/crazypants/enderio/machine/invpanel/server/NormalInventory.java +++ b/src/main/java/crazypants/enderio/machine/invpanel/server/NormalInventory.java @@ -12,17 +12,17 @@ class NormalInventory extends AbstractInventory { } @Override - int scanInventory(InventoryDatabaseServer db, int aiIndex) { + int scanInventory(InventoryDatabaseServer db) { ISidedInventory inv = ni.getInventoryRecheck(); int side = ni.getInventorySide(); int[] slotIndices = inv.getAccessibleSlotsFromSide(side); if (slotIndices == null || slotIndices.length == 0) { - setEmpty(db, aiIndex); + setEmpty(db); return 0; } int count = slotIndices.length; - if (count != slotItems.length) { - reset(db, count, aiIndex); + if (count != slotKeys.length) { + reset(db, count); } for (int slot = 0; slot < count; slot++) { int invSlot = slotIndices[slot]; @@ -30,13 +30,13 @@ class NormalInventory extends AbstractInventory { if (stack != null && !inv.canExtractItem(invSlot, stack, side)) { stack = null; } - updateSlot(db, slot, aiIndex, stack); + updateSlot(db, slot, stack); } return count; } @Override - public int extractItem(InventoryDatabaseServer db, ItemEntry entry, int slot, int aiIndex, int count) { + public int extractItem(InventoryDatabaseServer db, ItemEntry entry, int slot, int count) { ISidedInventory inv = ni.getInventoryRecheck(); int side = ni.getInventorySide(); int[] slotIndices = inv.getAccessibleSlotsFromSide(side); @@ -57,7 +57,7 @@ class NormalInventory extends AbstractInventory { } ni.itemExtracted(invSlot, count); remaining -= count; - updateCount(db, slot, aiIndex, entry, remaining); + updateCount(db, slot, entry, remaining); return count; } diff --git a/src/main/java/crazypants/enderio/machine/invpanel/server/SlotKey.java b/src/main/java/crazypants/enderio/machine/invpanel/server/SlotKey.java new file mode 100644 index 00000000..7c82979a --- /dev/null +++ b/src/main/java/crazypants/enderio/machine/invpanel/server/SlotKey.java @@ -0,0 +1,20 @@ +package crazypants.enderio.machine.invpanel.server; + +public final class SlotKey { + final AbstractInventory inv; + final int slot; + final ItemEntry item; + int count; + + SlotKey(AbstractInventory inv, int slot, ItemEntry item, int count) { + this.inv = inv; + this.slot = slot; + this.item = item; + this.count = count; + } + + void remove(InventoryDatabaseServer db) { + item.removeSlot(this); + db.entryChanged(item); + } +} diff --git a/src/main/java/crazypants/enderio/machine/killera/TileKillerJoe.java b/src/main/java/crazypants/enderio/machine/killera/TileKillerJoe.java index bce9a9ca..9a542a90 100644 --- a/src/main/java/crazypants/enderio/machine/killera/TileKillerJoe.java +++ b/src/main/java/crazypants/enderio/machine/killera/TileKillerJoe.java @@ -38,6 +38,7 @@ import crazypants.enderio.EnderIO; import crazypants.enderio.ModObject; import crazypants.enderio.config.Config; import crazypants.enderio.machine.AbstractMachineEntity; +import crazypants.enderio.machine.FakePlayerEIO; import crazypants.enderio.machine.SlotDefinition; import crazypants.enderio.machine.generator.zombie.IHasNutrientTank; import crazypants.enderio.machine.generator.zombie.PacketNutrientTank; @@ -496,15 +497,12 @@ public class TileKillerJoe extends AbstractMachineEntity implements IFluidHandle private static final UUID uuid = UUID.fromString("3baa66fa-a69a-11e4-89d3-123b93f75cba"); private static final GameProfile DUMMY_PROFILE = new GameProfile(uuid, "[EioKillera]"); - private class Attackera extends FakePlayer { + private class Attackera extends FakePlayerEIO { ItemStack prevWeapon; public Attackera() { - super(MinecraftServer.getServer().worldServerForDimension(getWorldObj().provider.dimensionId), DUMMY_PROFILE); - posX = xCoord + 0.5; - posY = yCoord + 0.5; - posZ = zCoord + 0.5; + super(getWorldObj(), getLocation(), DUMMY_PROFILE); } @Override @@ -527,23 +525,6 @@ public class TileKillerJoe extends AbstractMachineEntity implements IFluidHandle getChargedLocation().chargeItems(inventory.mainInventory); } - - // These do things with packets...which crash since the net handler is null. Potion effects are not needed anyways. - @Override - protected void onNewPotionEffect(PotionEffect p_70670_1_) { - } - - @Override - protected void onChangedPotionEffect(PotionEffect p_70695_1_, boolean p_70695_2_) { - } - - @Override - protected void onFinishedPotionEffect(PotionEffect p_70688_1_) { - } - - @Override - public void addChatMessage(IChatComponent p_145747_1_) { - } } @Override diff --git a/src/main/java/crazypants/enderio/machine/monitor/GuiPowerMonitor.java b/src/main/java/crazypants/enderio/machine/monitor/GuiPowerMonitor.java index 1f1946eb..4913ee0c 100644 --- a/src/main/java/crazypants/enderio/machine/monitor/GuiPowerMonitor.java +++ b/src/main/java/crazypants/enderio/machine/monitor/GuiPowerMonitor.java @@ -110,7 +110,6 @@ public class GuiPowerMonitor extends GuiContainerBase { startTF = new TextFieldEnder(getFontRenderer(), x, y, 28, 14); startTF.setCanLoseFocus(true); startTF.setMaxStringLength(3); - startTF.setFocused(true); startTF.setVisible(false); startTF.setText(INT_NF.format(te.asPercentInt(te.startLevel))); @@ -119,7 +118,6 @@ public class GuiPowerMonitor extends GuiContainerBase { endTF = new TextFieldEnder(getFontRenderer(), x, y, 28, 14); endTF.setCanLoseFocus(true); endTF.setMaxStringLength(3); - endTF.setFocused(false); endTF.setVisible(false); endTF.setText(INT_NF.format(te.asPercentInt(te.stopLevel))); diff --git a/src/main/java/crazypants/enderio/machine/obelisk/attractor/BlockAttractor.java b/src/main/java/crazypants/enderio/machine/obelisk/attractor/BlockAttractor.java index 62a5a2a1..55cfa855 100644 --- a/src/main/java/crazypants/enderio/machine/obelisk/attractor/BlockAttractor.java +++ b/src/main/java/crazypants/enderio/machine/obelisk/attractor/BlockAttractor.java @@ -4,6 +4,7 @@ import net.minecraft.entity.player.EntityPlayer; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.IIcon; import net.minecraft.world.World; +import net.minecraftforge.common.MinecraftForge; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import crazypants.enderio.GuiHandler; @@ -15,6 +16,7 @@ public class BlockAttractor extends BlockObeliskAbstract { public static BlockAttractor create() { BlockAttractor res = new BlockAttractor(); res.init(); + MinecraftForge.EVENT_BUS.register(new EndermanFixer()); return res; } diff --git a/src/main/java/crazypants/enderio/machine/obelisk/attractor/EndermanFixer.java b/src/main/java/crazypants/enderio/machine/obelisk/attractor/EndermanFixer.java new file mode 100644 index 00000000..86d98966 --- /dev/null +++ b/src/main/java/crazypants/enderio/machine/obelisk/attractor/EndermanFixer.java @@ -0,0 +1,15 @@ +package crazypants.enderio.machine.obelisk.attractor; + +import net.minecraft.entity.monster.EntityEnderman; +import net.minecraftforge.event.entity.living.EnderTeleportEvent; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; + +public class EndermanFixer { + + @SubscribeEvent + public void onEndermanTeleport(EnderTeleportEvent event) { + if (event.entityLiving instanceof EntityEnderman && event.entityLiving.getEntityData().getBoolean("EIO:tracked")) { + event.setCanceled(true); + } + } +} diff --git a/src/main/java/crazypants/enderio/machine/obelisk/attractor/TileAttractor.java b/src/main/java/crazypants/enderio/machine/obelisk/attractor/TileAttractor.java index 07c7a394..27fca71e 100644 --- a/src/main/java/crazypants/enderio/machine/obelisk/attractor/TileAttractor.java +++ b/src/main/java/crazypants/enderio/machine/obelisk/attractor/TileAttractor.java @@ -9,6 +9,7 @@ import java.util.Set; import net.minecraft.entity.EntityCreature; import net.minecraft.entity.EntityList; import net.minecraft.entity.EntityLiving; +import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.ai.EntityAIBase; import net.minecraft.entity.ai.EntityAITasks; import net.minecraft.entity.ai.EntityAITasks.EntityAITaskEntry; @@ -25,6 +26,7 @@ import net.minecraft.server.MinecraftServer; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.AxisAlignedBB; import net.minecraft.world.World; +import net.minecraft.world.WorldSettings.GameType; import net.minecraftforge.common.util.FakePlayer; import com.enderio.core.client.render.BoundingBox; @@ -38,6 +40,7 @@ import crazypants.enderio.EnderIO; import crazypants.enderio.ModObject; import crazypants.enderio.config.Config; import crazypants.enderio.machine.AbstractPowerConsumerEntity; +import crazypants.enderio.machine.FakePlayerEIO; import crazypants.enderio.machine.SlotDefinition; import crazypants.enderio.machine.ranged.IRanged; import crazypants.enderio.machine.ranged.RangeEntity; @@ -166,13 +169,40 @@ public class TileAttractor extends AbstractPowerConsumerEntity implements IRange onEntityTick(ent); } else if(tracking.size() < maxMobsAttracted && trackMob(ent)) { trackingThisTick.add(ent); + onTracked(ent); } } } + for (EntityLiving e : tracking) { + if (!trackingThisTick.contains(e)) { + onUntracked(e); + } + } tracking.clear(); tracking = trackingThisTick; return false; } + + private void onUntracked(EntityLiving e) { + if (e instanceof EntityEnderman) { + e.getEntityData().setBoolean("EIO:tracked", false); + } + } + + private void onTracked(EntityLiving e) { + if (e instanceof EntityEnderman) { + e.getEntityData().setBoolean("EIO:tracked", true); + } + } + + @Override + public void invalidate() { + super.invalidate(); + for (EntityLiving e : tracking) { + onUntracked(e); + } + tracking.clear(); + } protected double usePower() { return usePower(getPowerUsePerTick()); @@ -281,10 +311,6 @@ public class TileAttractor extends AbstractPowerConsumerEntity implements IRange } private boolean applySpecialCase(EntityLiving ent) { - return ent instanceof EntitySlime || ent instanceof EntitySilverfish || ent instanceof EntityBlaze; - } - - private boolean useSpecialCase(EntityLiving ent) { if(ent instanceof EntitySlime) { ent.faceEntity(getTarget(), 10.0F, 20.0F); return true; @@ -298,6 +324,10 @@ public class TileAttractor extends AbstractPowerConsumerEntity implements IRange return false; } + private boolean useSpecialCase(EntityLiving ent) { + return ent instanceof EntitySlime || ent instanceof EntitySilverfish || ent instanceof EntityBlaze; + } + private void onEntityTick(EntityLiving ent) { if(ent instanceof EntitySlime) { ent.faceEntity(getTarget(), 10.0F, 20.0F); @@ -325,7 +355,9 @@ public class TileAttractor extends AbstractPowerConsumerEntity implements IRange } } else if(ent instanceof EntityPigZombie || ent instanceof EntitySpider) { forceMove(ent); - } + } else if(ent instanceof EntityEnderman) { + ((EntityEnderman) ent).setTarget(getTarget()); + } } private void forceMove(EntityLiving ent) { @@ -346,19 +378,14 @@ public class TileAttractor extends AbstractPowerConsumerEntity implements IRange } private boolean useSetTarget(EntityLiving ent) { - return ent instanceof EntityEnderman || ent instanceof EntityPigZombie || ent instanceof EntitySpider || ent instanceof EntitySilverfish; + return ent instanceof EntityPigZombie || ent instanceof EntitySpider || ent instanceof EntitySilverfish; } - private class Target extends FakePlayer { - - ItemStack prevWeapon; + private class Target extends FakePlayerEIO { public Target() { - super(MinecraftServer.getServer().worldServerForDimension(getWorldObj().provider.dimensionId), new GameProfile(null, - ModObject.blockAttractor.unlocalisedName + ":" + getLocation())); - posX = xCoord + 0.5; - posY = yCoord + 1.5; - posZ = zCoord + 0.5; + super(getWorldObj(), getLocation(), new GameProfile(null, ModObject.blockAttractor.unlocalisedName + ":" + getLocation())); + posY += 1; } } diff --git a/src/main/java/crazypants/enderio/machine/painter/BlockPaintedGlowstone.java b/src/main/java/crazypants/enderio/machine/painter/BlockPaintedGlowstone.java index 86ff59dc..d44559da 100644 --- a/src/main/java/crazypants/enderio/machine/painter/BlockPaintedGlowstone.java +++ b/src/main/java/crazypants/enderio/machine/painter/BlockPaintedGlowstone.java @@ -294,4 +294,19 @@ public class BlockPaintedGlowstone extends BlockEio implements ITileEntityProvid } return this; } + + @Override + public Block getVisualBlock(IBlockAccess world, int x, int y, int z, ForgeDirection side) { + return getFacade(world, x, y, z, side.ordinal()); + } + + @Override + public int getVisualMeta(IBlockAccess world, int x, int y, int z, ForgeDirection side) { + return getFacadeMetadata(world, x, y, z, side.ordinal()); + } + + @Override + public boolean supportsVisualConnections() { + return true; + } } diff --git a/src/main/java/crazypants/enderio/machine/painter/PainterContainer.java b/src/main/java/crazypants/enderio/machine/painter/PainterContainer.java index 777fadcf..116243d0 100644 --- a/src/main/java/crazypants/enderio/machine/painter/PainterContainer.java +++ b/src/main/java/crazypants/enderio/machine/painter/PainterContainer.java @@ -20,7 +20,7 @@ public class PainterContainer extends AbstractMachineContainer { return tileEntity.isItemValidForSlot(0, itemStack); } }); - addSlotToContainer(new Slot(tileEntity, 1, 37, 34) { + addSlotToContainer(new Slot(tileEntity, 1, 38, 34) { @Override public boolean isItemValid(ItemStack itemStack) { return tileEntity.isItemValidForSlot(1, itemStack); diff --git a/src/main/java/crazypants/enderio/machine/spawner/ContainerPoweredSpawner.java b/src/main/java/crazypants/enderio/machine/spawner/ContainerPoweredSpawner.java index b6fe7de9..5b0f6b63 100644 --- a/src/main/java/crazypants/enderio/machine/spawner/ContainerPoweredSpawner.java +++ b/src/main/java/crazypants/enderio/machine/spawner/ContainerPoweredSpawner.java @@ -8,19 +8,22 @@ import crazypants.enderio.machine.gui.AbstractMachineContainer; public class ContainerPoweredSpawner extends AbstractMachineContainer { + private Slot slotInput; + private Slot slotOutput; + public ContainerPoweredSpawner(InventoryPlayer playerInv, AbstractMachineEntity te) { super(playerInv, te); } @Override protected void addMachineSlots(InventoryPlayer playerInv) { - addSlotToContainer(new Slot(tileEntity, 0, 54, 42) { + slotInput = addSlotToContainer(new Slot(tileEntity, 0, 54, 42) { @Override public boolean isItemValid(ItemStack itemStack) { return tileEntity.isItemValidForSlot(0, itemStack); } }); - addSlotToContainer(new Slot(tileEntity, 1, 105, 42) { + slotOutput = addSlotToContainer(new Slot(tileEntity, 1, 105, 42) { @Override public boolean isItemValid(ItemStack itemStack) { return false; @@ -28,5 +31,9 @@ public class ContainerPoweredSpawner extends AbstractMachineContainer { }); } + public void setSlotVisibility(boolean visible) { + slotInput.yDisplayPosition = visible ? 42 : -3000; + slotOutput.yDisplayPosition = visible ? 42 : -3000; + } } diff --git a/src/main/java/crazypants/enderio/machine/spawner/GuiPoweredSpawner.java b/src/main/java/crazypants/enderio/machine/spawner/GuiPoweredSpawner.java index 0bd85ea3..f019e318 100644 --- a/src/main/java/crazypants/enderio/machine/spawner/GuiPoweredSpawner.java +++ b/src/main/java/crazypants/enderio/machine/spawner/GuiPoweredSpawner.java @@ -1,6 +1,7 @@ package crazypants.enderio.machine.spawner; import java.awt.Color; +import java.awt.Rectangle; import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.GuiButton; @@ -11,6 +12,7 @@ import org.lwjgl.opengl.GL11; import com.enderio.core.client.gui.button.MultiIconButton; import com.enderio.core.client.render.ColorUtil; import com.enderio.core.client.render.RenderUtil; +import com.enderio.core.common.Lang; import crazypants.enderio.EnderIO; import crazypants.enderio.machine.gui.GuiPoweredMachineBase; @@ -19,12 +21,20 @@ import crazypants.enderio.network.PacketHandler; public class GuiPoweredSpawner extends GuiPoweredMachineBase { private final MultiIconButton modeB; + private final Rectangle progressTooltipRect; + private boolean wasSpawnMode; + private String header; public GuiPoweredSpawner(InventoryPlayer par1InventoryPlayer, TilePoweredSpawner te) { super(te, new ContainerPoweredSpawner(par1InventoryPlayer, te)); modeB = MultiIconButton.createRightArrowButton(this, 8888, 115, 10); modeB.setSize(10, 16); + + addProgressTooltip(80, 34, 14, 14); + progressTooltipRect = progressTooltips.get(0).getBounds(); + + updateSpawnMode(te.isSpawnMode()); } @Override @@ -43,6 +53,25 @@ public class GuiPoweredSpawner extends GuiPoweredMachineBase } } + private void updateSpawnMode(boolean spawnMode) { + wasSpawnMode = spawnMode; + ((ContainerPoweredSpawner) inventorySlots).setSlotVisibility(!spawnMode); + + if(spawnMode) { + header = EnderIO.lang.localize("gui.machine.poweredspawner.spawn"); + progressTooltipRect.x = 80; + progressTooltipRect.y = 34; + progressTooltipRect.width = 14; + progressTooltipRect.height = 14; + } else { + header = EnderIO.lang.localize("gui.machine.poweredspawner.capture"); + progressTooltipRect.x = 52; + progressTooltipRect.y = 40; + progressTooltipRect.width = 72; + progressTooltipRect.height = 21; + } + } + @Override protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) { GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); @@ -55,36 +84,32 @@ public class GuiPoweredSpawner extends GuiPoweredMachineBase super.drawGuiContainerBackgroundLayer(par1, par2, par3); TilePoweredSpawner spawner = getTileEntity(); - - int left = getGuiLeft(); - int top = getGuiTop(); + boolean spawnMode = spawner.isSpawnMode(); - String txt = EnderIO.lang.localize("gui.machine.poweredspawner.spawn"); - if(!spawner.isSpawnMode()) { - txt = EnderIO.lang.localize("gui.machine.poweredspawner.capture"); + if(spawnMode != wasSpawnMode) { + updateSpawnMode(spawnMode); } + FontRenderer fr = getFontRenderer(); - int x = left + xSize / 2 - fr.getStringWidth(txt) / 2; - int y = top + fr.FONT_HEIGHT + 6; - fr.drawStringWithShadow(txt, x, y, ColorUtil.getRGB(Color.WHITE)); + int x = sx + xSize / 2 - fr.getStringWidth(header) / 2; + int y = sy + fr.FONT_HEIGHT + 6; + fr.drawStringWithShadow(header, x, y, ColorUtil.getRGB(Color.WHITE)); RenderUtil.bindTexture("enderio:textures/gui/poweredSpawner.png"); - if(spawner.isSpawnMode()) { - int yOff = 34; - drawTexturedModalRect(left + 80, top + yOff, 207, 0, 17, 15); - if(spawner.getProgress() < 1 && spawner.getProgress() > 0) { + if(spawnMode) { + drawTexturedModalRect(sx + 80, sy + 34, 207, 0, 17, 15); + if(shouldRenderProgress()) { int scaled = getProgressScaled(14) + 1; - drawTexturedModalRect(left + 81, top + yOff + 14 - scaled, 176, 14 - scaled, 14, scaled); + drawTexturedModalRect(sx + 81, sy + 34 + 14 - scaled, 176, 14 - scaled, 14, scaled); } } else { - drawTexturedModalRect(left + 52, top + 40, 52, 170, 72, 21); - if(spawner.getProgress() < 1 && spawner.getProgress() > 0) { + drawTexturedModalRect(sx + 52, sy + 40, 52, 170, 72, 21); + if(shouldRenderProgress()) { int scaled = getProgressScaled(24); - drawTexturedModalRect(left + 76, top + 43, 176, 14, scaled + 1, 16); + drawTexturedModalRect(sx + 76, sy + 43, 176, 14, scaled + 1, 16); } } - } @Override diff --git a/src/main/java/crazypants/enderio/machine/spawner/TilePoweredSpawner.java b/src/main/java/crazypants/enderio/machine/spawner/TilePoweredSpawner.java index 54b18f22..ece33b17 100644 --- a/src/main/java/crazypants/enderio/machine/spawner/TilePoweredSpawner.java +++ b/src/main/java/crazypants/enderio/machine/spawner/TilePoweredSpawner.java @@ -6,9 +6,7 @@ import net.minecraft.entity.EntityLiving; import net.minecraft.entity.EnumCreatureType; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; -import net.minecraft.tileentity.MobSpawnerBaseLogic; import net.minecraft.util.AxisAlignedBB; -import net.minecraft.world.World; import crazypants.enderio.EnderIO; import crazypants.enderio.ModObject; import crazypants.enderio.config.Config; @@ -40,15 +38,16 @@ public class TilePoweredSpawner extends AbstractPoweredTaskEntity { public static final int MIN_PLAYER_DISTANCE = Config.poweredSpawnerMaxPlayerDistance; public static final boolean USE_VANILLA_SPAWN_CHECKS = Config.poweredSpawnerUseVanillaSpawChecks; - private final SpawnerLogic logic = new SpawnerLogic(); - private static final String NULL_ENTITY_NAME = "None"; + private String entityTypeName; private boolean isSpawnMode = true; + private int powerUsePerTick; + private int remainingSpawnTries; public TilePoweredSpawner() { super(new SlotDefinition(1, 1, 1)); - logic.setEntityName(NULL_ENTITY_NAME); + entityTypeName = NULL_ENTITY_NAME; } public boolean isSpawnMode() { @@ -66,16 +65,17 @@ public class TilePoweredSpawner extends AbstractPoweredTaskEntity { protected void taskComplete() { super.taskComplete(); if(isSpawnMode) { - logic.spawnDelay = 0; + remainingSpawnTries = Config.poweredSpawnerSpawnCount + Config.poweredSpawnerMaxSpawnTries; + for (int i = 0; i < Config.poweredSpawnerSpawnCount && remainingSpawnTries > 0; ++i) { + if(!trySpawnEntity()) { + break; + } + } } else { - if(getStackInSlot(0) == null || getStackInSlot(1) != null) { + if(getStackInSlot(0) == null || getStackInSlot(1) != null || !hasEntityName()) { return; } - String name = logic.getEntityNameToSpawn(); - if(NULL_ENTITY_NAME.equals(name)) { - return; - } - ItemStack res = EnderIO.itemSoulVessel.createVesselWithEntityStub(logic.getEntityNameToSpawn()); + ItemStack res = EnderIO.itemSoulVessel.createVesselWithEntityStub(getEntityName()); decrStackSize(0, 1); setInventorySlotContents(1, res); } @@ -83,20 +83,26 @@ public class TilePoweredSpawner extends AbstractPoweredTaskEntity { @Override public void onCapacitorTypeChange() { - ICapacitor refCap = null; + ICapacitor refCap; + int basePowerUse; switch (getCapacitorType()) { + default: case BASIC_CAPACITOR: refCap = CAP_ONE; + basePowerUse = POWER_PER_TICK_ONE; break; case ACTIVATED_CAPACITOR: refCap = CAP_TWO; + basePowerUse = POWER_PER_TICK_TWO; break; case ENDER_CAPACITOR: refCap = CAP_THREE; + basePowerUse = POWER_PER_TICK_THREE; break; } - double multuplier = PoweredSpawnerConfig.getInstance().getCostMultiplierFor(logic.getEntityNameToSpawn()); - setCapacitor(new BasicCapacitor((int) (refCap.getMaxEnergyExtracted() * multuplier), refCap.getMaxEnergyStored())); + double multiplier = PoweredSpawnerConfig.getInstance().getCostMultiplierFor(getEntityName()); + setCapacitor(new BasicCapacitor((int) (refCap.getMaxEnergyExtracted() * multiplier), refCap.getMaxEnergyStored())); + powerUsePerTick = (int) Math.ceil(basePowerUse * multiplier); forceClientUpdate = true; } @@ -118,9 +124,14 @@ public class TilePoweredSpawner extends AbstractPoweredTaskEntity { @Override protected IMachineRecipe canStartNextTask(float chance) { + if(!hasEntityName()) { + return null; + } if(isSpawnMode) { - if(logic.getEntityNameToSpawn() == null || logic.getEntityNameToSpawn().equals(NULL_ENTITY_NAME)) { - return null; + if(MIN_PLAYER_DISTANCE > 0) { + if(worldObj.getClosestPlayer(xCoord + 0.5, yCoord + 0.5, zCoord + 0.5, MIN_PLAYER_DISTANCE) == null) { + return null; + } } } else { if(getStackInSlot(0) == null || getStackInSlot(1) != null) { @@ -137,13 +148,7 @@ public class TilePoweredSpawner extends AbstractPoweredTaskEntity { @Override public int getPowerUsePerTick() { - double multuplier = PoweredSpawnerConfig.getInstance().getCostMultiplierFor(logic.getEntityNameToSpawn()); - if(getCapacitorType().ordinal() == 0) { - return (int) Math.round(POWER_PER_TICK_ONE * multuplier); - } else if(getCapacitorType().ordinal() == 1) { - return (int) Math.round(POWER_PER_TICK_TWO * multuplier); - } - return (int) Math.round(POWER_PER_TICK_THREE * multuplier); + return powerUsePerTick; } @Override @@ -156,29 +161,14 @@ public class TilePoweredSpawner extends AbstractPoweredTaskEntity { return true; } - @Override - public void readCustomNBT(NBTTagCompound nbtRoot) { - logic.readFromNBT(nbtRoot); - super.readCustomNBT(nbtRoot); - - } - - @Override - public void writeCustomNBT(NBTTagCompound nbtRoot) { - logic.writeToNBT(nbtRoot); - super.writeCustomNBT(nbtRoot); - - } - @Override public void readCommon(NBTTagCompound nbtRoot) { - //Must read the mob type first so we no the multiplier to be used when calculating input/output power + //Must read the mob type first so we know the multiplier to be used when calculating input/output power String mobType = BlockPoweredSpawner.readMobTypeFromNBT(nbtRoot); if(mobType == null) { mobType = NULL_ENTITY_NAME; } - logic.setEntityName(mobType); - logic.resetTimer(); + entityTypeName = mobType; if(!nbtRoot.hasKey("isSpawnMode")) { isSpawnMode = true; } else { @@ -189,29 +179,25 @@ public class TilePoweredSpawner extends AbstractPoweredTaskEntity { @Override public void writeCommon(NBTTagCompound nbtRoot) { - String mobType = logic.getEntityNameToSpawn(); - if(mobType == null || mobType.equals(NULL_ENTITY_NAME)) { - BlockPoweredSpawner.writeMobTypeToNBT(nbtRoot, null); + if(hasEntityName()) { + BlockPoweredSpawner.writeMobTypeToNBT(nbtRoot, getEntityName()); } else { - BlockPoweredSpawner.writeMobTypeToNBT(nbtRoot, mobType); + BlockPoweredSpawner.writeMobTypeToNBT(nbtRoot, null); } nbtRoot.setBoolean("isSpawnMode", isSpawnMode); super.writeCommon(nbtRoot); } @Override - public void doUpdate() { - logic.updateSpawner(); - super.doUpdate(); - } - - /** - * Called when a client event is received with the event number and argument, - * see World.sendClientEvent - */ - @Override - public boolean receiveClientEvent(int p_145842_1_, int p_145842_2_) { - return logic.setDelayToMin(p_145842_1_) ? true : super.receiveClientEvent(p_145842_1_, p_145842_2_); + protected void updateEntityClient() { + if(isActive()) { + double x = xCoord + worldObj.rand.nextFloat(); + double y = yCoord + worldObj.rand.nextFloat(); + double z = zCoord + worldObj.rand.nextFloat(); + worldObj.spawnParticle("smoke", x, y, z, 0.0D, 0.0D, 0.0D); + worldObj.spawnParticle("flame", x, y, z, 0.0D, 0.0D, 0.0D); + } + super.updateEntityClient(); } @Override @@ -246,138 +232,58 @@ public class TilePoweredSpawner extends AbstractPoweredTaskEntity { return spaceClear; } + Entity createEntity(boolean forceAlive) { + Entity ent = EntityList.createEntityByName(getEntityName(), worldObj); + if(forceAlive && MIN_PLAYER_DISTANCE <= 0 && Config.poweredSpawnerDespawnTimeSeconds > 0 && ent instanceof EntityLiving) { + ent.getEntityData().setLong(BlockPoweredSpawner.KEY_SPAWNED_BY_POWERED_SPAWNER, worldObj.getTotalWorldTime()); + ((EntityLiving) ent).func_110163_bv(); + } + return ent; + } + + protected boolean trySpawnEntity() { + Entity entity = createEntity(true); + if(!(entity instanceof EntityLiving)) { + return false; + } + EntityLiving entityliving = (EntityLiving) entity; + int spawnRange = Config.poweredSpawnerSpawnRange; + + if(Config.poweredSpawnerMaxNearbyEntities > 0) { + int nearbyEntities = worldObj.getEntitiesWithinAABB( + entity.getClass(), + AxisAlignedBB.getBoundingBox( + xCoord - spawnRange*2, yCoord - 4, zCoord - spawnRange*2, + xCoord + spawnRange*2, yCoord + 4, zCoord + spawnRange*2)).size(); + + if(nearbyEntities >= Config.poweredSpawnerMaxNearbyEntities) { + return false; + } + } + + while(remainingSpawnTries-- > 0) { + double x = xCoord + (worldObj.rand.nextDouble() - worldObj.rand.nextDouble()) * spawnRange; + double y = yCoord + worldObj.rand.nextInt(3) - 1; + double z = zCoord + (worldObj.rand.nextDouble() - worldObj.rand.nextDouble()) * spawnRange; + entity.setLocationAndAngles(x, y, z, worldObj.rand.nextFloat() * 360.0F, 0.0F); + + if(canSpawnEntity(entityliving)) { + entityliving.onSpawnWithEgg(null); + worldObj.spawnEntityInWorld(entityliving); + worldObj.playAuxSFX(2004, xCoord, yCoord, zCoord, 0); + entityliving.spawnExplosionParticle(); + return true; + } + } + + return false; + } + public String getEntityName() { - return logic.getEntityNameToSpawn(); + return entityTypeName; } - class SpawnerLogic extends MobSpawnerBaseLogic { - - private int spawnCount = 4; - private int maxNearbyEntities = 6; - private int spawnRange = 4; - - @Override - public void func_98267_a(int par1) { - worldObj.addBlockEvent(xCoord, yCoord, zCoord, EnderIO.blockPoweredSpawner, par1, 0); - } - - @Override - public World getSpawnerWorld() { - return worldObj; - } - - @Override - public int getSpawnerX() { - return xCoord; - } - - @Override - public int getSpawnerY() { - return yCoord; - } - - @Override - public int getSpawnerZ() { - return zCoord; - } - - @Override - public void setRandomEntity(MobSpawnerBaseLogic.WeightedRandomMinecart par1WeightedRandomMinecart) { - super.setRandomEntity(par1WeightedRandomMinecart); - if(getSpawnerWorld() != null) { - getSpawnerWorld().markBlockForUpdate(xCoord, yCoord, zCoord); - } - } - - /** - * Returns true if there's a player close enough to this mob spawner to - * activate it. - */ - @Override - public boolean isActivated() { - if(MIN_PLAYER_DISTANCE > 0) { - //TODO: Add this to main 'hasPower' like check so turn of the machine if the player is out of range? - boolean playerInRange = worldObj.getClosestPlayer(getSpawnerX() + 0.5D, getSpawnerY() + 0.5D, getSpawnerZ() + 0.5D, - MIN_PLAYER_DISTANCE) != null; - if(!playerInRange) { - return false; - } - } - return isActive(); - } - - @Override - public void updateSpawner() { - - if(isActivated()) { - double d2; - - if(getSpawnerWorld().isRemote) { - double d0 = getSpawnerX() + getSpawnerWorld().rand.nextFloat(); - double d1 = getSpawnerY() + getSpawnerWorld().rand.nextFloat(); - d2 = getSpawnerZ() + getSpawnerWorld().rand.nextFloat(); - getSpawnerWorld().spawnParticle("smoke", d0, d1, d2, 0.0D, 0.0D, 0.0D); - getSpawnerWorld().spawnParticle("flame", d0, d1, d2, 0.0D, 0.0D, 0.0D); - - field_98284_d = field_98287_c; - field_98287_c = (field_98287_c + 1000.0F / (spawnDelay + 200.0F)) % 360.0D; - } else { - - if(spawnDelay > 0) { - return; - } - resetTimer(); - - for (int i = 0; i < spawnCount; ++i) { - - Entity entity = createEntity(true); - if(entity == null) { - return; - } - - int j = getSpawnerWorld().getEntitiesWithinAABB( - entity.getClass(), - AxisAlignedBB.getBoundingBox(getSpawnerX(), getSpawnerY(), getSpawnerZ(), getSpawnerX() + 1, - getSpawnerY() + 1, getSpawnerZ() + 1).expand(spawnRange * 2, 4.0D, spawnRange * 2)).size(); - - if(j >= maxNearbyEntities) { - resetTimer(); - return; - } - - d2 = getSpawnerX() + (getSpawnerWorld().rand.nextDouble() - getSpawnerWorld().rand.nextDouble()) * spawnRange; - double d3 = getSpawnerY() + getSpawnerWorld().rand.nextInt(3) - 1; - double d4 = getSpawnerZ() + (getSpawnerWorld().rand.nextDouble() - getSpawnerWorld().rand.nextDouble()) * spawnRange; - EntityLiving entityliving = entity instanceof EntityLiving ? (EntityLiving) entity : null; - entity.setLocationAndAngles(d2, d3, d4, getSpawnerWorld().rand.nextFloat() * 360.0F, 0.0F); - - if(entityliving != null && canSpawnEntity(entityliving)) { - func_98265_a(entity); - getSpawnerWorld().playAuxSFX(2004, getSpawnerX(), getSpawnerY(), getSpawnerZ(), 0); - - if(entityliving != null) - { - entityliving.spawnExplosionParticle(); - } - } - } - } - } - } - - Entity createEntity(boolean forceAlive) { - Entity ent = EntityList.createEntityByName(getEntityNameToSpawn(), getSpawnerWorld()); - if(forceAlive && MIN_PLAYER_DISTANCE <= 0 && Config.poweredSpawnerDespawnTimeSeconds > 0 && ent instanceof EntityLiving) { - ent.getEntityData().setLong(BlockPoweredSpawner.KEY_SPAWNED_BY_POWERED_SPAWNER, getSpawnerWorld().getTotalWorldTime()); - ((EntityLiving) ent).func_110163_bv(); - } - return ent; - } - - void resetTimer() { - spawnDelay = Integer.MAX_VALUE; - } - + public boolean hasEntityName() { + return !NULL_ENTITY_NAME.equals(entityTypeName); } - } diff --git a/src/main/java/crazypants/enderio/material/Alloy.java b/src/main/java/crazypants/enderio/material/Alloy.java index e17d2f21..8b5865f2 100644 --- a/src/main/java/crazypants/enderio/material/Alloy.java +++ b/src/main/java/crazypants/enderio/material/Alloy.java @@ -1,7 +1,11 @@ package crazypants.enderio.material; +import net.minecraft.item.ItemStack; + import org.apache.commons.lang3.StringUtils; +import crazypants.enderio.EnderIO; + public enum Alloy { ELECTRICAL_STEEL("electricalSteel", 6.0f), @@ -15,19 +19,35 @@ public enum Alloy { public final String unlocalisedName; public final String iconKey; - public final String oredictIngotName; - public final String oredictBlockName; + public final String oreIngot; + public final String oreBlock; private final float hardness; private Alloy(String baseName, float hardness) { this.unlocalisedName = "enderio." + baseName; this.iconKey = "enderio:" + baseName; - this.oredictIngotName = "ingot" + StringUtils.capitalize(baseName); - this.oredictBlockName = "block" + StringUtils.capitalize(baseName); + this.oreIngot = "ingot" + StringUtils.capitalize(baseName); + this.oreBlock = "block" + StringUtils.capitalize(baseName); this.hardness = hardness; } public float getHardness() { return hardness; } + + public ItemStack getStackIngot() { + return getStackIngot(1); + } + + public ItemStack getStackIngot(int size) { + return new ItemStack(EnderIO.itemAlloy, size, ordinal()); + } + + public ItemStack getStackBlock() { + return getStackBlock(1); + } + + public ItemStack getStackBlock(int size) { + return new ItemStack(EnderIO.blockIngotStorage, size, ordinal()); + } } diff --git a/src/main/java/crazypants/enderio/material/MachinePart.java b/src/main/java/crazypants/enderio/material/MachinePart.java index 0c74cadc..005d407c 100644 --- a/src/main/java/crazypants/enderio/material/MachinePart.java +++ b/src/main/java/crazypants/enderio/material/MachinePart.java @@ -1,5 +1,11 @@ package crazypants.enderio.material; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraftforge.oredict.OreDictionary; + +import org.apache.commons.lang3.StringUtils; + public enum MachinePart { MACHINE_CHASSI("machineChassi"), @@ -7,10 +13,17 @@ public enum MachinePart { public final String unlocalisedName; public final String iconKey; + public final String oreDict; private MachinePart(String unlocalisedName) { this.unlocalisedName = "enderio." + unlocalisedName; this.iconKey = "enderio:" + unlocalisedName; + this.oreDict = "item" + StringUtils.capitalize(unlocalisedName); + } + + public static void registerOres(Item item) { + for (MachinePart m : values()) { + OreDictionary.registerOre(m.oreDict, new ItemStack(item, 1, m.ordinal())); + } } - } diff --git a/src/main/java/crazypants/enderio/material/Material.java b/src/main/java/crazypants/enderio/material/Material.java index 86af833a..6db4e1c7 100644 --- a/src/main/java/crazypants/enderio/material/Material.java +++ b/src/main/java/crazypants/enderio/material/Material.java @@ -6,6 +6,8 @@ import net.minecraftforge.oredict.OreDictionary; import org.apache.commons.lang3.StringUtils; +import crazypants.enderio.EnderIO; + public enum Material { SILICON("silicon"), @@ -41,4 +43,12 @@ public enum Material { OreDictionary.registerOre(m.oreDict, new ItemStack(item, 1, m.ordinal())); } } + + public ItemStack getStack() { + return getStack(1); + } + + public ItemStack getStack(int size) { + return new ItemStack(EnderIO.itemMaterial, size, ordinal()); + } } diff --git a/src/main/java/crazypants/enderio/material/MaterialRecipes.java b/src/main/java/crazypants/enderio/material/MaterialRecipes.java index 5a4ea921..e7a21dcc 100644 --- a/src/main/java/crazypants/enderio/material/MaterialRecipes.java +++ b/src/main/java/crazypants/enderio/material/MaterialRecipes.java @@ -4,10 +4,8 @@ import java.util.ArrayList; import net.minecraft.init.Blocks; import net.minecraft.init.Items; -import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraftforge.oredict.OreDictionary; -import net.minecraftforge.oredict.ShapedOreRecipe; import net.minecraftforge.oredict.ShapelessOreRecipe; import com.enderio.core.common.util.OreDictionaryHelper; @@ -19,6 +17,9 @@ import crazypants.enderio.machine.obelisk.weather.TileWeatherObelisk.WeatherTask import static com.enderio.core.common.util.OreDictionaryHelper.*; import static crazypants.enderio.EnderIO.itemBasicCapacitor; +import static crazypants.enderio.material.Alloy.*; +import static crazypants.enderio.material.Material.*; +import static crazypants.util.RecipeUtil.*; public class MaterialRecipes { @@ -44,13 +45,10 @@ public class MaterialRecipes { OreDictionary.registerOre("dustIron", new ItemStack(EnderIO.itemPowderIngot, 1, PowderIngot.POWDER_IRON.ordinal())); OreDictionary.registerOre("dustGold", new ItemStack(EnderIO.itemPowderIngot, 1, PowderIngot.POWDER_GOLD.ordinal())); OreDictionary.registerOre("dustObsidian", new ItemStack(EnderIO.itemPowderIngot, 1, PowderIngot.POWDER_OBSIDIAN.ordinal())); - - OreDictionary.registerOre("gearStone", new ItemStack(EnderIO.itemMachinePart, 1, MachinePart.BASIC_GEAR.ordinal())); - OreDictionary.registerOre("itemSilicon", new ItemStack(EnderIO.itemMaterial, 1, Material.SILICON.ordinal())); - + for (Alloy alloy : Alloy.values()) { - OreDictionary.registerOre(alloy.oredictIngotName, new ItemStack(EnderIO.itemAlloy, 1, alloy.ordinal())); - OreDictionary.registerOre(alloy.oredictBlockName, new ItemStack(EnderIO.blockIngotStorage, 1, alloy.ordinal())); + OreDictionary.registerOre(alloy.oreIngot, new ItemStack(EnderIO.itemAlloy, 1, alloy.ordinal())); + OreDictionary.registerOre(alloy.oreBlock, new ItemStack(EnderIO.blockIngotStorage, 1, alloy.ordinal())); } OreDictionary.registerOre("nuggetPulsatingIron", new ItemStack(EnderIO.itemMaterial, 1, Material.PHASED_IRON_NUGGET.ordinal())); @@ -74,63 +72,60 @@ public class MaterialRecipes { OreDictionary.registerOre("itemSkull", new ItemStack(EnderIO.blockEndermanSkull)); //Glass stuff for compatability - GameRegistry.addShapedRecipe(new ItemStack(Blocks.glass_pane, 16, 0), " ", "eee", "eee", 'e', pureGlass); - GameRegistry.addShapelessRecipe(new ItemStack(Blocks.glass), pureGlass); - GameRegistry.addShapedRecipe(new ItemStack(Items.glass_bottle, 3, 0), " ", "g g", " g ", 'g', pureGlass); + addShaped(new ItemStack(Blocks.glass_pane, 16, 0), " ", "eee", "eee", 'e', pureGlass); + addShapeless(new ItemStack(Blocks.glass), pureGlass); + addShaped(new ItemStack(Items.glass_bottle, 3, 0), " ", "g g", " g ", 'g', pureGlass); Material.registerOres(EnderIO.itemMaterial); + MachinePart.registerOres(EnderIO.itemMachinePart); } public static void addRecipes() { //Common Ingredients - ItemStack conduitBinder = new ItemStack(EnderIO.itemMaterial, 4, Material.CONDUIT_BINDER.ordinal()); - ItemStack basicGear = new ItemStack(EnderIO.itemMachinePart, 1, MachinePart.BASIC_GEAR.ordinal()); - ItemStack binderComposite = new ItemStack(EnderIO.itemMaterial, 1, Material.BINDER_COMPOSITE.ordinal()); + String conduitBinder = CONDUIT_BINDER.oreDict; ItemStack fusedQuartzFrame = new ItemStack(EnderIO.itemFusedQuartzFrame, 1, 0); - ItemStack machineChassi = new ItemStack(EnderIO.itemMachinePart, 1, MachinePart.MACHINE_CHASSI.ordinal()); - ItemStack phasedGold = new ItemStack(EnderIO.itemAlloy, 1, Alloy.PHASED_GOLD.ordinal()); - ItemStack phasedIron = new ItemStack(EnderIO.itemAlloy, 1, Alloy.PHASED_IRON.ordinal()); - ItemStack electricalSteel = new ItemStack(EnderIO.itemAlloy, 1, Alloy.ELECTRICAL_STEEL.ordinal()); - ItemStack darkSteel = new ItemStack(EnderIO.itemAlloy, 1, Alloy.DARK_STEEL.ordinal()); + String energeticAlloy = ENERGETIC_ALLOY.oreIngot; + String phasedGold = PHASED_GOLD.oreIngot; + String phasedIron = PHASED_IRON.oreIngot; + String darkSteel = DARK_STEEL.oreIngot; ItemStack capacitor = new ItemStack(itemBasicCapacitor, 1, 0); //Conduit Binder - ItemStack cbc = binderComposite.copy(); - cbc.stackSize = 8; + ItemStack cbc = BINDER_COMPOSITE.getStack(8); if (Config.useAlternateBinderRecipe) { - GameRegistry.addShapedRecipe(cbc, "gcg", "sgs", "gcg", 'g', Blocks.gravel, 's', Blocks.sand, 'c', Items.clay_ball); + addShaped(cbc, "gcg", "sgs", "gcg", 'g', Blocks.gravel, 's', Blocks.sand, 'c', Items.clay_ball); } else { - GameRegistry.addShapedRecipe(cbc, "ggg", "scs", "ggg", 'g', Blocks.gravel, 's', Blocks.sand, 'c', Items.clay_ball); + addShaped(cbc, "ggg", "scs", "ggg", 'g', Blocks.gravel, 's', Blocks.sand, 'c', Items.clay_ball); } - GameRegistry.addSmelting(binderComposite, conduitBinder, 0); + GameRegistry.addSmelting(BINDER_COMPOSITE.getStack(), CONDUIT_BINDER.getStack(4), 0); //Nuggets ItemStack phasedIronNugget = new ItemStack(EnderIO.itemMaterial, 9, Material.PHASED_IRON_NUGGET.ordinal()); - GameRegistry.addShapelessRecipe(phasedIronNugget, phasedIron); + addShapeless(phasedIronNugget, phasedIron); phasedIronNugget = phasedIronNugget.copy(); phasedIronNugget.stackSize = 1; - GameRegistry.addShapedRecipe(phasedIron, "eee", "eee", "eee", 'e', phasedIronNugget); + addShaped(PHASED_IRON.getStackIngot(), "eee", "eee", "eee", 'e', phasedIronNugget); ItemStack vibrantNugget = new ItemStack(EnderIO.itemMaterial, 9, Material.VIBRANT_NUGGET.ordinal()); - GameRegistry.addShapelessRecipe(vibrantNugget, phasedGold); + addShapeless(vibrantNugget, phasedGold); vibrantNugget = vibrantNugget.copy(); vibrantNugget.stackSize = 1; - GameRegistry.addShapedRecipe(phasedGold, "eee", "eee", "eee", 'e', vibrantNugget); + addShaped(PHASED_GOLD.getStackIngot(), "eee", "eee", "eee", 'e', vibrantNugget); //Crystals ItemStack pulsCry = new ItemStack(EnderIO.itemMaterial, 1, Material.PULSATING_CYSTAL.ordinal()); - GameRegistry.addShapedRecipe(pulsCry, "nnn", "ngn", "nnn", 'n', phasedIronNugget, 'g', Items.diamond); + addShaped(pulsCry, "nnn", "ngn", "nnn", 'n', phasedIronNugget, 'g', Items.diamond); ItemStack vibCry = new ItemStack(EnderIO.itemMaterial, 1, Material.VIBRANT_CYSTAL.ordinal()); - GameRegistry.addShapedRecipe(vibCry, "nnn", "ngn", "nnn", 'n', vibrantNugget, 'g', Items.emerald); + addShaped(vibCry, "nnn", "ngn", "nnn", 'n', vibrantNugget, 'g', Items.emerald); //Balls ItemStack darkBall = new ItemStack(EnderIO.itemMaterial, 5, Material.DARK_GRINDING_BALL.ordinal()); - GameRegistry.addShapedRecipe(darkBall, " s ", "sss", " s ", 's', darkSteel); + addShaped(darkBall, " s ", "sss", " s ", 's', darkSteel); //Smelting ItemStack dustIron = new ItemStack(EnderIO.itemPowderIngot, 1, PowderIngot.POWDER_IRON.ordinal()); @@ -143,37 +138,36 @@ public class MaterialRecipes { //Ender Dusts ItemStack enderDust = new ItemStack(EnderIO.itemPowderIngot, 1, PowderIngot.POWDER_ENDER.ordinal()); - GameRegistry.addShapedRecipe(new ItemStack(Items.ender_pearl), "eee", "eee", "eee", 'e', enderDust); + addShaped(new ItemStack(Items.ender_pearl), "eee", "eee", "eee", 'e', enderDust); //Dark Iron Bars ItemStack diBars = new ItemStack(EnderIO.blockDarkIronBars, 16, 0); - GameRegistry.addShapedRecipe(diBars, "ddd", "ddd", 'd', darkSteel); + addShaped(diBars, "ddd", "ddd", 'd', darkSteel); // Fused Quartz Frame - GameRegistry.addRecipe(new ShapedOreRecipe(fusedQuartzFrame, "bsb", "s s", "bsb", 'b', conduitBinder, 's', "stickWood")); - GameRegistry.addRecipe(new ShapedOreRecipe(fusedQuartzFrame, "bsb", "s s", "bsb", 'b', conduitBinder, 's', "woodStick")); + addShaped(fusedQuartzFrame, "bsb", "s s", "bsb", 'b', conduitBinder, 's', "stickWood"); + addShaped(fusedQuartzFrame, "bsb", "s s", "bsb", 'b', conduitBinder, 's', "woodStick"); // Machine Chassi ArrayList steelIngots = OreDictionary.getOres("ingotSteel"); - if (Config.useSteelInChassi == true && steelIngots != null && !steelIngots.isEmpty()) { - GameRegistry.addRecipe(new ShapedOreRecipe(machineChassi, "fif", "ici", "fif", 'f', Blocks.iron_bars, 'i', "ingotSteel", 'c', capacitor)); - } else { - GameRegistry.addShapedRecipe(machineChassi, "fif", "ici", "fif", 'f', Blocks.iron_bars, 'i', Items.iron_ingot, 'c', capacitor); - } + ItemStack chassis = new ItemStack(EnderIO.itemMachinePart, 1, MachinePart.MACHINE_CHASSI.ordinal()); + String mat = Config.useSteelInChassi == true && steelIngots != null && !steelIngots.isEmpty() ? "ingotSteel" : "ingotIron"; + addShaped(chassis, "fif", "ici", "fif", 'f', Blocks.iron_bars, 'i', mat, 'c', capacitor); // Basic Gear - GameRegistry.addRecipe(new ShapedOreRecipe(basicGear, "scs", "c c", "scs", 's', "stickWood", 'c', Blocks.cobblestone)); - GameRegistry.addRecipe(new ShapedOreRecipe(basicGear, "scs", "c c", "scs", 's', "woodStick", 'c', Blocks.cobblestone)); + ItemStack gear = new ItemStack(EnderIO.itemMachinePart, 1, MachinePart.BASIC_GEAR.ordinal()); + addShaped(gear, "scs", "c c", "scs", 's', "stickWood", 'c', "cobblestone"); + addShaped(gear, "scs", "c c", "scs", 's', "woodStick", 'c', "cobblestone"); //Ender Capacitor ItemStack enderCapacitor = new ItemStack(EnderIO.itemBasicCapacitor, 1, 2); ItemStack activatedCapacitor = new ItemStack(EnderIO.itemBasicCapacitor, 1, 1); if (Config.useHardRecipes) { - GameRegistry.addShapedRecipe(enderCapacitor, "eee", "cgc", "eee", 'e', phasedGold, 'c', activatedCapacitor, 'g', Blocks.glowstone); + addShaped(enderCapacitor, "eee", "cgc", "eee", 'e', phasedGold, 'c', activatedCapacitor, 'g', Blocks.glowstone); } else { - GameRegistry.addShapedRecipe(enderCapacitor, " e ", "cgc", " e ", 'e', phasedGold, 'c', activatedCapacitor, 'g', Blocks.glowstone); + addShaped(enderCapacitor, " e ", "cgc", " e ", 'e', phasedGold, 'c', activatedCapacitor, 'g', Blocks.glowstone); } // Weather Crystal @@ -183,23 +177,20 @@ public class MaterialRecipes { if (Config.reinforcedObsidianEnabled) { ItemStack reinfObs = new ItemStack(EnderIO.blockReinforcedObsidian); - ItemStack corners = darkSteel; + String corners = darkSteel; if (Config.reinforcedObsidianUseDarkSteelBlocks) { - corners = new ItemStack(EnderIO.blockIngotStorage, 1, Alloy.DARK_STEEL.ordinal()); + corners = Alloy.DARK_STEEL.oreBlock; } - GameRegistry.addShapedRecipe(reinfObs, "dbd", "bob", "dbd", 'd', corners, 'b', EnderIO.blockDarkIronBars, 'o', Blocks.obsidian); + addShaped(reinfObs, "dbd", "bob", "dbd", 'd', corners, 'b', EnderIO.blockDarkIronBars, 'o', Blocks.obsidian); } - GameRegistry.addRecipe(new ShapedOreRecipe(EnderIO.blockDarkSteelAnvil, "bbb", " i ", "iii", + addShaped(EnderIO.blockDarkSteelAnvil, "bbb", " i ", "iii", 'b', DARK_STEEL.oreBlock, 'i', darkSteel); - 'b', "blockDarkSteel", 'i', "ingotDarkSteel")); - - GameRegistry.addRecipe(new ItemStack(EnderIO.blockDarkSteelLadder, 12), "b", "b", "b", 'b', EnderIO.blockDarkIronBars); + addShaped(new ItemStack(EnderIO.blockDarkSteelLadder, 12), "b", "b", "b", 'b', EnderIO.blockDarkIronBars); for (Alloy alloy : Alloy.values()) { - GameRegistry - .addRecipe(new ShapedOreRecipe(new ItemStack(EnderIO.blockIngotStorage, 1, alloy.ordinal()), "iii", "iii", "iii", 'i', alloy.oredictIngotName)); - GameRegistry.addShapelessRecipe(new ItemStack(EnderIO.itemAlloy, 9, alloy.ordinal()), new ItemStack(EnderIO.blockIngotStorage, 1, alloy.ordinal())); + addShaped(alloy.getStackBlock(), "iii", "iii", "iii", 'i', alloy.oreIngot); + addShapeless(alloy.getStackIngot(9), alloy.oreBlock); } //Food @@ -208,10 +199,7 @@ public class MaterialRecipes { GameRegistry.addSmelting(flour, bread, 0.35f); - } - - public static void addOreDictionaryRecipes() { - if (OreDictionaryHelper.hasCopper()) { + if (hasCopper()) { ItemStack dustCopper = new ItemStack(EnderIO.itemPowderIngot, 1, PowderIngot.POWDER_COPPER.ordinal()); ItemStack ingotCopper = OreDictionaryPreferences.instance.getPreferred(OreDictionaryHelper.INGOT_COPPER); GameRegistry.addSmelting(dustCopper, ingotCopper, 0); @@ -222,27 +210,23 @@ public class MaterialRecipes { GameRegistry.addSmelting(dustTin, ingotTin, 0); } - ItemStack capacitor = new ItemStack(EnderIO.itemBasicCapacitor, 1, 0); ArrayList copperIngots = OreDictionary.getOres("ingotCopper"); - Item gold; + String gold; if (Config.useHardRecipes) { - gold = Items.gold_ingot; + gold = "ingotGold"; } else { - gold = Items.gold_nugget; + gold = "nuggetGold"; } if (copperIngots != null && !copperIngots.isEmpty() && Config.useModMetals) { - GameRegistry.addRecipe(new ShapedOreRecipe(capacitor, " gr", "gcg", "rg ", 'r', Items.redstone, 'g', gold, 'c', "ingotCopper")); + addShaped(capacitor, " gr", "gcg", "rg ", 'r', Items.redstone, 'g', gold, 'c', "ingotCopper"); } else { - GameRegistry.addShapedRecipe(capacitor, " gr", "gig", "rg ", 'r', Items.redstone, 'g', gold, 'i', Items.iron_ingot); + addShaped(capacitor, " gr", "gig", "rg ", 'r', "dustRedstone", 'g', gold, 'i', "ingotIron"); } - int dustCoal = OreDictionary.getOreID("dustCoal"); - ItemStack activatedCapacitor = new ItemStack(EnderIO.itemBasicCapacitor, 1, 1); - ItemStack energeticAlloy = new ItemStack(EnderIO.itemAlloy, 1, Alloy.ENERGETIC_ALLOY.ordinal()); if (Config.useHardRecipes) { - GameRegistry.addRecipe(new ShapedOreRecipe(activatedCapacitor, "eee", "cCc", "eee", 'e', energeticAlloy, 'c', capacitor, 'C', "dustCoal")); + addShaped(activatedCapacitor, "eee", "cCc", "eee", 'e', energeticAlloy, 'c', capacitor, 'C', "dustCoal"); } else { - GameRegistry.addRecipe(new ShapedOreRecipe(activatedCapacitor, " e ", "cCc", " e ", 'e', energeticAlloy, 'c', capacitor, 'C', "dustCoal")); + addShaped(activatedCapacitor, " e ", "cCc", " e ", 'e', energeticAlloy, 'c', capacitor, 'C', "dustCoal"); } } -} \ No newline at end of file +} diff --git a/src/main/java/crazypants/enderio/teleport/anchor/BlockTravelAnchor.java b/src/main/java/crazypants/enderio/teleport/anchor/BlockTravelAnchor.java index 32982054..a37eca72 100644 --- a/src/main/java/crazypants/enderio/teleport/anchor/BlockTravelAnchor.java +++ b/src/main/java/crazypants/enderio/teleport/anchor/BlockTravelAnchor.java @@ -16,6 +16,7 @@ import net.minecraft.util.IIcon; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import net.minecraftforge.common.UsernameCache; +import net.minecraftforge.common.util.ForgeDirection; import com.enderio.core.api.client.gui.IResourceTooltipProvider; import com.enderio.core.common.TileEntityEnder; @@ -73,7 +74,7 @@ public class BlockTravelAnchor extends BlockEio implements IGuiHandler, ITileEnt private BlockTravelAnchor() { super(ModObject.blockTravelAnchor.unlocalisedName, TileTravelAnchor.class); - if(!Config.travelAnchorEnabled) { + if (!Config.travelAnchorEnabled) { setCreativeTab(null); } } @@ -94,9 +95,9 @@ public class BlockTravelAnchor extends BlockEio implements IGuiHandler, ITileEnt @SideOnly(Side.CLIENT) public IIcon getIcon(IBlockAccess world, int x, int y, int z, int blockSide) { TileEntity te = world.getTileEntity(x, y, z); - if(te instanceof TileTravelAnchor) { + if (te instanceof TileTravelAnchor) { TileTravelAnchor tef = (TileTravelAnchor) te; - if(tef.getSourceBlock() != null) { + if (tef.getSourceBlock() != null) { return tef.getSourceBlock().getIcon(blockSide, tef.getSourceBlockMetadata()); } } @@ -110,9 +111,9 @@ public class BlockTravelAnchor extends BlockEio implements IGuiHandler, ITileEnt @Override public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entity, ItemStack par6ItemStack) { - if(entity instanceof EntityPlayer) { + if (entity instanceof EntityPlayer) { TileEntity te = world.getTileEntity(x, y, z); - if(te instanceof TileTravelAnchor) { + if (te instanceof TileTravelAnchor) { TileTravelAnchor ta = (TileTravelAnchor) te; ta.setPlacedBy((EntityPlayer) entity); Block b = PainterUtil.getSourceBlock(par6ItemStack); @@ -126,9 +127,9 @@ public class BlockTravelAnchor extends BlockEio implements IGuiHandler, ITileEnt @Override public boolean openGui(World world, int x, int y, int z, EntityPlayer entityPlayer, int side) { TileEntity te = world.getTileEntity(x, y, z); - if(te instanceof ITravelAccessable) { + if (te instanceof ITravelAccessable) { ITravelAccessable ta = (ITravelAccessable) te; - if(ta.canUiBeAccessed(entityPlayer)) { + if (ta.canUiBeAccessed(entityPlayer)) { entityPlayer.openGui(EnderIO.instance, GuiHandler.GUI_ID_TRAVEL_ACCESSABLE, world, x, y, z); } else { sendPrivateChatMessage(entityPlayer, ta.getPlacedBy()); @@ -136,7 +137,7 @@ public class BlockTravelAnchor extends BlockEio implements IGuiHandler, ITileEnt } return true; } - + public static void sendPrivateChatMessage(EntityPlayer player, UUID owner) { if(player.worldObj.isRemote && !player.isSneaking()) { player.addChatComponentMessage(new ChatComponentText(EnderIO.lang.localize("gui.travelAccessable.privateBlock1") + " " @@ -144,12 +145,12 @@ public class BlockTravelAnchor extends BlockEio implements IGuiHandler, ITileEnt + EnderIO.lang.localize("gui.travelAccessable.privateBlock2"))); } } - + @Override public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { TileEntity te = world.getTileEntity(x, y, z); - if(te instanceof ITravelAccessable) { - if(ID == GuiHandler.GUI_ID_TRAVEL_ACCESSABLE) { + if (te instanceof ITravelAccessable) { + if (ID == GuiHandler.GUI_ID_TRAVEL_ACCESSABLE) { return new ContainerTravelAccessable(player.inventory, (ITravelAccessable) te, world); } else { return new ContainerTravelAuth(player.inventory); @@ -161,8 +162,8 @@ public class BlockTravelAnchor extends BlockEio implements IGuiHandler, ITileEnt @Override public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { TileEntity te = world.getTileEntity(x, y, z); - if(te instanceof ITravelAccessable) { - if(ID == GuiHandler.GUI_ID_TRAVEL_ACCESSABLE) { + if (te instanceof ITravelAccessable) { + if (ID == GuiHandler.GUI_ID_TRAVEL_ACCESSABLE) { return new GuiTravelAccessable(player.inventory, (ITravelAccessable) te, world); } else { return new GuiTravelAuth(player, (ITravelAccessable) te, world); @@ -175,13 +176,13 @@ public class BlockTravelAnchor extends BlockEio implements IGuiHandler, ITileEnt protected void processDrop(World world, int x, int y, int z, TileEntityEnder te, ItemStack drop) { TileTravelAnchor anchor = (TileTravelAnchor) te; - if(anchor == null) { + if (anchor == null) { return; } ItemStack itemStack = new ItemStack(this); Block srcBlk = anchor.getSourceBlock(); - if(srcBlk != null) { + if (srcBlk != null) { itemStack = createItemStackForSourceBlock(anchor.getSourceBlock(), anchor.getSourceBlockMetadata()); drop.stackTagCompound = (NBTTagCompound) itemStack.stackTagCompound.copy(); } @@ -196,9 +197,9 @@ public class BlockTravelAnchor extends BlockEio implements IGuiHandler, ITileEnt @SideOnly(Side.CLIENT) public int colorMultiplier(IBlockAccess world, int x, int y, int z) { TileEntity te = world.getTileEntity(x, y, z); - if(te instanceof TileTravelAnchor) { + if (te instanceof TileTravelAnchor) { TileTravelAnchor tef = (TileTravelAnchor) te; - if(tef.getSourceBlock() != null) { + if (tef.getSourceBlock() != null) { return tef.getSourceBlock().colorMultiplier(world, x, y, z); } } @@ -216,7 +217,7 @@ public class BlockTravelAnchor extends BlockEio implements IGuiHandler, ITileEnt } public ItemStack createItemStackForSourceBlock(Block block, int damage) { - if(block == this) { + if (block == this) { return new ItemStack(this); } ItemStack result = new ItemStack(this, 1, damage); @@ -238,7 +239,7 @@ public class BlockTravelAnchor extends BlockEio implements IGuiHandler, ITileEnt @Override public ResultStack[] getCompletedResult(float chance, MachineRecipeInput... inputs) { ItemStack paintSource = MachineRecipeInput.getInputForSlot(1, inputs); - if(paintSource == null) { + if (paintSource == null) { return new ResultStack[0]; } return new ResultStack[] { new ResultStack(createItemStackForSourceBlock(Block.getBlockFromItem(paintSource.getItem()), paintSource.getItemDamage())) }; @@ -248,7 +249,7 @@ public class BlockTravelAnchor extends BlockEio implements IGuiHandler, ITileEnt @Override public int getFacadeMetadata(IBlockAccess world, int x, int y, int z, int side) { TileEntity te = world.getTileEntity(x, y, z); - if(te instanceof TileTravelAnchor) { + if (te instanceof TileTravelAnchor) { return ((TileTravelAnchor) te).getSourceBlockMetadata(); } return 0; @@ -257,9 +258,24 @@ public class BlockTravelAnchor extends BlockEio implements IGuiHandler, ITileEnt @Override public Block getFacade(IBlockAccess world, int x, int y, int z, int side) { TileEntity te = world.getTileEntity(x, y, z); - if(te instanceof TileTravelAnchor) { + if (te instanceof TileTravelAnchor) { return ((TileTravelAnchor) te).getSourceBlock(); } return this; } + + @Override + public Block getVisualBlock(IBlockAccess world, int x, int y, int z, ForgeDirection side) { + return getFacade(world, x, y, z, side.ordinal()); + } + + @Override + public int getVisualMeta(IBlockAccess world, int x, int y, int z, ForgeDirection side) { + return getFacadeMetadata(world, x, y, z, side.ordinal()); + } + + @Override + public boolean supportsVisualConnections() { + return true; + } } diff --git a/src/main/java/crazypants/enderio/teleport/telepad/TileTelePad.java b/src/main/java/crazypants/enderio/teleport/telepad/TileTelePad.java index 3d7b6fe8..9b6e62a4 100644 --- a/src/main/java/crazypants/enderio/teleport/telepad/TileTelePad.java +++ b/src/main/java/crazypants/enderio/teleport/telepad/TileTelePad.java @@ -346,7 +346,9 @@ public class TileTelePad extends TileTravelAnchor implements IInternalPowerRecei int distance = new BlockCoord(this).getDist(target); double base = Math.log((0.005 * distance) + 1); this.maxPower = (int) (base * Config.telepadPowerCoefficient); - + if (this.maxPower <= 0) { + this.maxPower = 1; + } } else { this.maxPower = Config.telepadPowerInterdimensional; } @@ -524,7 +526,7 @@ public class TileTelePad extends TileTravelAnchor implements IInternalPowerRecei this.target = coords; this.coordsChanged = true; } else { - this.master.setCoords(coords); + this.master.setCoords_internal(coords); } } } diff --git a/src/main/java/crazypants/enderio/thaumcraft/ThaumcraftCompat.java b/src/main/java/crazypants/enderio/thaumcraft/ThaumcraftCompat.java index 8e775fdf..f65bc4a3 100644 --- a/src/main/java/crazypants/enderio/thaumcraft/ThaumcraftCompat.java +++ b/src/main/java/crazypants/enderio/thaumcraft/ThaumcraftCompat.java @@ -36,38 +36,38 @@ public class ThaumcraftCompat { ThaumcraftApi.registerObjectTag("dustCoal", new AspectList().add(getAspects(Items.coal))); ThaumcraftApi.registerObjectTag("itemSilicon", new AspectList().add(Aspect.FIRE, 1).add(Aspect.ORDER, 1).add(Aspect.SENSES, 1)); - ThaumcraftApi.registerObjectTag(Alloy.ELECTRICAL_STEEL.oredictIngotName, new AspectList() + ThaumcraftApi.registerObjectTag(Alloy.ELECTRICAL_STEEL.oreIngot, new AspectList() .add(getAspects("dustCoal")) .add(getAspects(Items.iron_ingot)) .add(getAspects("itemSilicon"))); - ThaumcraftApi.registerObjectTag(Alloy.ENERGETIC_ALLOY.oredictIngotName, new AspectList() + ThaumcraftApi.registerObjectTag(Alloy.ENERGETIC_ALLOY.oreIngot, new AspectList() .add(getAspects(Items.glowstone_dust)) .add(getAspects(Items.redstone)) .add(getAspects(Items.gold_ingot))); - ThaumcraftApi.registerObjectTag(Alloy.PHASED_GOLD.oredictIngotName, new AspectList() + ThaumcraftApi.registerObjectTag(Alloy.PHASED_GOLD.oreIngot, new AspectList() .add(getAspects(Items.ender_pearl)) .add(getAspects("ingotEnergeticAlloy"))); - ThaumcraftApi.registerObjectTag(Alloy.REDSTONE_ALLOY.oredictIngotName, new AspectList() + ThaumcraftApi.registerObjectTag(Alloy.REDSTONE_ALLOY.oreIngot, new AspectList() .add(getAspects(Items.redstone)) .add(getAspects("itemSilicon"))); - ThaumcraftApi.registerObjectTag(Alloy.CONDUCTIVE_IRON.oredictIngotName, new AspectList() + ThaumcraftApi.registerObjectTag(Alloy.CONDUCTIVE_IRON.oreIngot, new AspectList() .add(getAspects(Items.redstone)) .add(getAspects(Items.iron_ingot))); - ThaumcraftApi.registerObjectTag(Alloy.PHASED_IRON.oredictIngotName, new AspectList() + ThaumcraftApi.registerObjectTag(Alloy.PHASED_IRON.oreIngot, new AspectList() .add(getAspects(Items.ender_pearl)) .add(getAspects(Items.iron_ingot))); - ThaumcraftApi.registerObjectTag(Alloy.DARK_STEEL.oredictIngotName, new AspectList() + ThaumcraftApi.registerObjectTag(Alloy.DARK_STEEL.oreIngot, new AspectList() .add(getAspects(Items.iron_ingot)) .add(getAspects("dustCoal")) .add(getAspects(Blocks.obsidian))); - ThaumcraftApi.registerObjectTag(Alloy.SOULARIUM.oredictIngotName, new AspectList() + ThaumcraftApi.registerObjectTag(Alloy.SOULARIUM.oreIngot, new AspectList() .add(getAspects(Blocks.soul_sand)) .add(getAspects(Items.gold_ingot))); @@ -80,19 +80,19 @@ public class ThaumcraftCompat { .add(getAspects(EnderIO.blockEndermanSkull)) .add(getAspects(Items.potionitem)).add(getAspects(Items.potionitem)) .add(getAspects(new ItemStack(EnderIO.itemBasicCapacitor, 1, Capacitors.BASIC_CAPACITOR.ordinal()))) - .add(getAspects(Alloy.SOULARIUM.oredictIngotName)).add(getAspects(Alloy.SOULARIUM.oredictIngotName))); + .add(getAspects(Alloy.SOULARIUM.oreIngot)).add(getAspects(Alloy.SOULARIUM.oreIngot))); ThaumcraftApi.registerObjectTag(new ItemStack(EnderIO.itemFrankenSkull, 1, FrankenSkull.ZOMBIE_ELECTRODE.ordinal()), new AspectList() .add(getAspects(new ItemStack(Items.skull, 1, 2))) .add(getAspects("itemSilicon")).add(getAspects("itemSilicon")) .add(getAspects(new ItemStack(EnderIO.itemBasicCapacitor, 1, Capacitors.BASIC_CAPACITOR.ordinal()))) - .add(getAspects(Alloy.ENERGETIC_ALLOY.oredictIngotName)).add(getAspects(Alloy.ENERGETIC_ALLOY.oredictIngotName))); + .add(getAspects(Alloy.ENERGETIC_ALLOY.oreIngot)).add(getAspects(Alloy.ENERGETIC_ALLOY.oreIngot))); ThaumcraftApi.registerObjectTag(new ItemStack(EnderIO.itemFrankenSkull, 1, FrankenSkull.ZOMBIE_CONTROLLER.ordinal()), new AspectList() .add(getAspects(new ItemStack(Items.skull, 1, 2))) .add(getAspects("itemSilicon")).add(getAspects("itemSilicon")) .add(getAspects(new ItemStack(EnderIO.itemBasicCapacitor, 1, Capacitors.BASIC_CAPACITOR.ordinal()))) - .add(getAspects(Alloy.SOULARIUM.oredictIngotName)).add(getAspects(Alloy.SOULARIUM.oredictIngotName))); + .add(getAspects(Alloy.SOULARIUM.oreIngot)).add(getAspects(Alloy.SOULARIUM.oreIngot))); ThaumcraftApi.registerObjectTag(new ItemStack(EnderIO.itemFrankenSkull, 1, FrankenSkull.FRANKEN_ZOMBIE.ordinal()), new AspectList() .add(Aspect.UNDEAD, 2) @@ -103,8 +103,8 @@ public class ThaumcraftCompat { ThaumcraftApi.registerObjectTag(new ItemStack(EnderIO.itemFrankenSkull, 1, FrankenSkull.ENDER_RESONATOR.ordinal()), new AspectList() .add(getAspects(EnderIO.blockEndermanSkull)) .add(getAspects("itemSilicon")).add(getAspects("itemSilicon")) - .add(getAspects(Alloy.PHASED_GOLD.oredictIngotName)) - .add(getAspects(Alloy.SOULARIUM.oredictIngotName)).add(getAspects(Alloy.SOULARIUM.oredictIngotName))); + .add(getAspects(Alloy.PHASED_GOLD.oreIngot)) + .add(getAspects(Alloy.SOULARIUM.oreIngot)).add(getAspects(Alloy.SOULARIUM.oreIngot))); ThaumcraftApi.registerObjectTag(new ItemStack(EnderIO.itemMaterial, 1, Material.ENDER_CRYSTAL.ordinal()), new AspectList() .add(Aspect.AIR, 2) diff --git a/src/main/java/crazypants/util/IFacade.java b/src/main/java/crazypants/util/IFacade.java index adbeb429..c6975bf7 100644 --- a/src/main/java/crazypants/util/IFacade.java +++ b/src/main/java/crazypants/util/IFacade.java @@ -1,5 +1,7 @@ package crazypants.util; -public interface IFacade extends info.jbcs.minecraft.chisel.api.IFacade, com.cricketcraft.chisel.api.IFacade { +import cofh.api.block.IBlockAppearance; + +public interface IFacade extends info.jbcs.minecraft.chisel.api.IFacade, com.cricketcraft.chisel.api.IFacade, IBlockAppearance { // :( } diff --git a/src/main/java/crazypants/util/RecipeUtil.java b/src/main/java/crazypants/util/RecipeUtil.java new file mode 100644 index 00000000..ebece446 --- /dev/null +++ b/src/main/java/crazypants/util/RecipeUtil.java @@ -0,0 +1,35 @@ +package crazypants.util; + +import net.minecraft.block.Block; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraftforge.oredict.ShapedOreRecipe; +import net.minecraftforge.oredict.ShapelessOreRecipe; +import cpw.mods.fml.common.registry.GameRegistry; + +public class RecipeUtil { + + public static void addShaped(Item res, Object... recipe) { + addShaped(new ItemStack(res), recipe); + } + + public static void addShaped(Block res, Object... recipe) { + addShaped(new ItemStack(res), recipe); + } + + public static void addShaped(ItemStack res, Object... recipe) { + GameRegistry.addRecipe(new ShapedOreRecipe(res, recipe)); + } + + public static void addShapeless(Item res, Object... recipe) { + addShaped(new ItemStack(res), recipe); + } + + public static void addShapeless(Block res, Object... recipe) { + addShaped(new ItemStack(res), recipe); + } + + public static void addShapeless(ItemStack res, Object... recipe) { + GameRegistry.addRecipe(new ShapelessOreRecipe(res, recipe)); + } +}