diff options
author | bartimaeusnek <33183715+bartimaeusnek@users.noreply.github.com> | 2019-12-22 10:47:50 +0100 |
---|---|---|
committer | bartimaeusnek <33183715+bartimaeusnek@users.noreply.github.com> | 2019-12-22 10:47:50 +0100 |
commit | 3a5ed85148a1e64616d0f5eaf639cd45cd0253af (patch) | |
tree | fac898da0b88c10177ca93afc5605c592235a193 | |
parent | 330d0422e03fd6a247e53fc951406f315ce51531 (diff) | |
download | GT5-Unofficial-3a5ed85148a1e64616d0f5eaf639cd45cd0253af.tar.gz GT5-Unofficial-3a5ed85148a1e64616d0f5eaf639cd45cd0253af.tar.bz2 GT5-Unofficial-3a5ed85148a1e64616d0f5eaf639cd45cd0253af.zip |
Material Conversion Fix
Signed-off-by: bartimaeusnek <33183715+bartimaeusnek@users.noreply.github.com>
Former-commit-id: 4feb0999cb5e05275db0ae4b5267f6af23736d39
-rw-r--r-- | src/main/java/com/github/bartimaeusnek/bartworks/MainMod.java | 2 | ||||
-rw-r--r-- | src/main/java/com/github/bartimaeusnek/bartworks/server/EventHandler/ServerEventHandler.java | 26 |
2 files changed, 22 insertions, 6 deletions
diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/MainMod.java b/src/main/java/com/github/bartimaeusnek/bartworks/MainMod.java index a054945a32..2d33252b12 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/MainMod.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/MainMod.java @@ -162,8 +162,8 @@ public final class MainMod { ServerEventHandler serverEventHandler = new ServerEventHandler(); if (FMLCommonHandler.instance().getSide().isServer()) { MinecraftForge.EVENT_BUS.register(serverEventHandler); - FMLCommonHandler.instance().bus().register(serverEventHandler); } + FMLCommonHandler.instance().bus().register(serverEventHandler); if (ConfigHandler.BioLab) new BioLabLoader().run(); if (ConfigHandler.newStuff) { diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/server/EventHandler/ServerEventHandler.java b/src/main/java/com/github/bartimaeusnek/bartworks/server/EventHandler/ServerEventHandler.java index cf084f627a..bb7c343eee 100644 --- a/src/main/java/com/github/bartimaeusnek/bartworks/server/EventHandler/ServerEventHandler.java +++ b/src/main/java/com/github/bartimaeusnek/bartworks/server/EventHandler/ServerEventHandler.java @@ -55,6 +55,9 @@ public class ServerEventHandler { if (event == null || !(event.player instanceof EntityPlayerMP)) return; + if (event.player.worldObj.getTotalWorldTime() % 20 != 0) + return; + boolean replace = false; ItemStack toReplace = null; for (int i = 0; i < event.player.inventory.mainInventory.length; i++) { @@ -62,19 +65,32 @@ public class ServerEventHandler { if (stack == null) continue; int[] oreIDs = OreDictionary.getOreIDs(stack); + if (oreIDs.length > 0){ - for (int oreID : oreIDs) { + loop: for (int oreID : oreIDs) { String oreDictName = OreDictionary.getOreName(oreID); for (Werkstoff e : Werkstoff.werkstoffHashSet) { replace = e.getGenerationFeatures().enforceUnification; - if (replace && (oreDictName.contains(e.getVarName()) || e.getADDITIONAL_OREDICT().stream().anyMatch(oreDictName::contains))) { - String prefix = oreDictName.replace(e.getVarName(), ""); - toReplace = GT_OreDictUnificator.get(OrePrefixes.getPrefix(prefix),e.getVarName(),stack.stackSize); + if (replace) { + if (oreDictName.contains(e.getVarName())) { + String prefix = oreDictName.replace(e.getVarName(), ""); + toReplace = GT_OreDictUnificator.get(OrePrefixes.getPrefix(prefix), e.getVarName(), stack.stackSize); + break loop; + } else { + for (String s : e.getADDITIONAL_OREDICT()) { + if (oreDictName.contains(s)) { + String prefix = oreDictName.replace(s, ""); + toReplace = GT_OreDictUnificator.get(OrePrefixes.getPrefix(prefix), e.getVarName(), stack.stackSize); + break loop; + } + } + } } + replace = false; } } } - if (replace) { + if (replace && toReplace != null) { event.player.inventory.setInventorySlotContents(i, toReplace); replace = false; } |