aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorbartimaeusnek <33183715+bartimaeusnek@users.noreply.github.com>2019-08-13 03:35:42 +0200
committerbartimaeusnek <33183715+bartimaeusnek@users.noreply.github.com>2019-08-13 03:35:42 +0200
commita3a672f8f5cd7b0dc13ca5db7fa2c46cb849e840 (patch)
tree54e3fa15d2d7fc8e864d16a3a3cf0a1aacca79e9 /src
parent50c4013a228c30fedec312c062a04a7511077f7e (diff)
downloadGT5-Unofficial-a3a672f8f5cd7b0dc13ca5db7fa2c46cb849e840.tar.gz
GT5-Unofficial-a3a672f8f5cd7b0dc13ca5db7fa2c46cb849e840.tar.bz2
GT5-Unofficial-a3a672f8f5cd7b0dc13ca5db7fa2c46cb849e840.zip
fixed MP issues
Signed-off-by: bartimaeusnek <33183715+bartimaeusnek@users.noreply.github.com> Former-commit-id: bd9898031da9580de00cdc928bf90af882fe9c58
Diffstat (limited to 'src')
-rw-r--r--src/main/java/com/github/bartimaeusnek/bartworks/MainMod.java26
-rw-r--r--src/main/java/com/github/bartimaeusnek/bartworks/common/net/BW_Network.java3
-rw-r--r--src/main/java/com/github/bartimaeusnek/bartworks/common/net/ServerJoinedPackage.java64
-rw-r--r--src/main/java/com/github/bartimaeusnek/bartworks/server/EventHandler/ServerEventHandler.java5
-rw-r--r--src/main/java/com/github/bartimaeusnek/bartworks/system/material/CircuitGeneration/CircuitImprintLoader.java52
-rw-r--r--src/main/java/com/github/bartimaeusnek/bartworks/system/material/CircuitGeneration/CircuitPartLoader.java3
-rw-r--r--src/main/java/com/github/bartimaeusnek/bartworks/util/BWRecipes.java3
7 files changed, 114 insertions, 42 deletions
diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/MainMod.java b/src/main/java/com/github/bartimaeusnek/bartworks/MainMod.java
index fab50ec3b4..21ad4d58cc 100644
--- a/src/main/java/com/github/bartimaeusnek/bartworks/MainMod.java
+++ b/src/main/java/com/github/bartimaeusnek/bartworks/MainMod.java
@@ -84,21 +84,21 @@ public final class MainMod {
public static final String VERSION = "@version@";
public static final String MOD_ID = "bartworks";
public static final String APIVERSION = "@apiversion@";
- public static final Logger LOGGER = LogManager.getLogger(NAME);
+ public static final Logger LOGGER = LogManager.getLogger(MainMod.NAME);
public static final CreativeTabs GT2 = new GT2Tab("GT2C");
public static final CreativeTabs BIO_TAB = new BioTab("BioTab");
public static final CreativeTabs BWT = new bartworksTab("bartworks");
public static final IGuiHandler GH = new GuiHandler();
- @Mod.Instance(MOD_ID)
+ @Mod.Instance(MainMod.MOD_ID)
public static MainMod instance;
public static BW_Network BW_Network_instance = new BW_Network();
@Mod.EventHandler
public void preInit(FMLPreInitializationEvent preinit) {
- if (!(API_REFERENCE.VERSION.equals(APIVERSION))) {
- LOGGER.error("Something has loaded an old API. Please contact the Mod authors to update!");
+ if (!(API_REFERENCE.VERSION.equals(MainMod.APIVERSION))) {
+ MainMod.LOGGER.error("Something has loaded an old API. Please contact the Mod authors to update!");
}
//fixing BorosilicateGlass... -_-'
@@ -116,7 +116,7 @@ public final class MainMod {
}
}
if (ConfigHandler.GTNH)
- LOGGER.info("GTNH-Detected . . . ACTIVATE HARDMODE.");
+ MainMod.LOGGER.info("GTNH-Detected . . . ACTIVATE HARDMODE.");
if (ConfigHandler.BioLab) {
BioCultureLoader bioCultureLoader = new BioCultureLoader();
@@ -148,7 +148,7 @@ public final class MainMod {
@Mod.EventHandler
public void postInit(FMLPostInitializationEvent postinit) {
- NetworkRegistry.INSTANCE.registerGuiHandler(instance, GH);
+ NetworkRegistry.INSTANCE.registerGuiHandler(MainMod.instance, MainMod.GH);
if (ConfigHandler.BioLab)
new GTNHBlocks().run();
BioObjectAdder.regenerateBioFluids();
@@ -166,14 +166,18 @@ public final class MainMod {
@Mod.EventHandler
public void onServerStarted(FMLServerStartedEvent event) {
OreDictHandler.adaptCacheForWorld();
+ MainMod.runOnPlayerJoined(ConfigHandler.classicMode);
+ }
+
+ public static void runOnPlayerJoined(boolean classicMode){
WerkstoffLoader.removeIC2Recipes();
- this.addElectricImplosionCompressorRecipes();
+ MainMod.addElectricImplosionCompressorRecipes();
new CircuitImprintLoader().run();
- if (ConfigHandler.classicMode)
+ if (classicMode)
new DownTierLoader().run();
}
- private void addElectricImplosionCompressorRecipes() {
+ private static void addElectricImplosionCompressorRecipes() {
if (eicMap == null) {
eicMap = new GT_Recipe.GT_Recipe_Map(new HashSet<GT_Recipe>(GT_Recipe.GT_Recipe_Map.sImplosionRecipes.mRecipeList.size()), "gt.recipe.electricimplosioncompressor", "Electric Implosion Compressor", (String) null, "gregtech:textures/gui/basicmachines/Default", 1, 2, 1, 0, 1, "", 1, "", true, true);
for (GT_Recipe recipe : GT_Recipe.GT_Recipe_Map.sImplosionRecipes.mRecipeList) {
@@ -181,14 +185,14 @@ public final class MainMod {
continue;
HashSet<ItemStack> inputs = new HashSet<>();
for (ItemStack is : recipe.mInputs)
- if (!this.checkForExplosives(is))
+ if (!checkForExplosives(is))
inputs.add(is);
eicMap.addRecipe(true, inputs.toArray(new ItemStack[0]), recipe.mOutputs, null, null, null, recipe.mDuration, BW_Util.getMachineVoltageFromTier(10), 0);
}
}
}
- private boolean checkForExplosives(ItemStack input) {
+ private static boolean checkForExplosives(ItemStack input) {
return (GT_Utility.areStacksEqual(input, new ItemStack(Blocks.tnt)) || GT_Utility.areStacksEqual(input, GT_ModHandler.getIC2Item("industrialTnt", 1L)) || GT_Utility.areStacksEqual(input, GT_ModHandler.getIC2Item("dynamite", 1L)) || GT_Utility.areStacksEqual(input, ItemList.Block_Powderbarrel.get(1L)));
}
diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/net/BW_Network.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/net/BW_Network.java
index e7708253e1..bb32c7aeb4 100644
--- a/src/main/java/com/github/bartimaeusnek/bartworks/common/net/BW_Network.java
+++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/net/BW_Network.java
@@ -45,7 +45,6 @@ import net.minecraft.world.chunk.Chunk;
import javax.annotation.Nonnull;
import java.util.EnumMap;
-import java.util.Iterator;
import java.util.List;
/*
@@ -59,7 +58,7 @@ public class BW_Network extends MessageToMessageCodec<FMLProxyPacket, GT_Packet>
public BW_Network() {
this.mChannel = NetworkRegistry.INSTANCE.newChannel("BartWorks", this, new BW_Network.HandlerShared());
- this.mSubChannels = new GT_Packet[]{new RendererPacket(), new CircuitProgrammerPacket(), new OrePacket(), new OreDictCachePacket()};
+ this.mSubChannels = new GT_Packet[]{new RendererPacket(), new CircuitProgrammerPacket(), new OrePacket(), new OreDictCachePacket(), new ServerJoinedPackage()};
}
protected void encode(ChannelHandlerContext aContext, GT_Packet aPacket, List<Object> aOutput) throws Exception {
diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/common/net/ServerJoinedPackage.java b/src/main/java/com/github/bartimaeusnek/bartworks/common/net/ServerJoinedPackage.java
new file mode 100644
index 0000000000..a9b37065e4
--- /dev/null
+++ b/src/main/java/com/github/bartimaeusnek/bartworks/common/net/ServerJoinedPackage.java
@@ -0,0 +1,64 @@
+/*
+ * Copyright (c) 2019 bartimaeusnek
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+package com.github.bartimaeusnek.bartworks.common.net;
+
+import com.github.bartimaeusnek.bartworks.MainMod;
+import com.github.bartimaeusnek.bartworks.common.configs.ConfigHandler;
+import com.google.common.io.ByteArrayDataInput;
+import gregtech.api.net.GT_Packet;
+import net.minecraft.world.IBlockAccess;
+
+public class ServerJoinedPackage extends GT_Packet {
+
+ private boolean config;
+
+ ServerJoinedPackage() {
+ super(true);
+ }
+
+ public ServerJoinedPackage(Object obj) {
+ super(false);
+ this.config = ConfigHandler.classicMode;
+ }
+
+ @Override
+ public byte getPacketID() {
+ return 4;
+ }
+
+ @Override
+ public byte[] encode() {
+ return new byte[]{(byte) (this.config ? 1 : 0)};
+ }
+
+ @Override
+ public GT_Packet decode(ByteArrayDataInput byteArrayDataInput) {
+ this.config = byteArrayDataInput.readBoolean();
+ return this;
+ }
+
+ @Override
+ public void process(IBlockAccess iBlockAccess) {
+ MainMod.runOnPlayerJoined(this.config);
+ }
+}
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 9fc72b31cd..5c357302e7 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
@@ -24,6 +24,7 @@ package com.github.bartimaeusnek.bartworks.server.EventHandler;
import com.github.bartimaeusnek.bartworks.MainMod;
import com.github.bartimaeusnek.bartworks.common.net.OreDictCachePacket;
+import com.github.bartimaeusnek.bartworks.common.net.ServerJoinedPackage;
import com.github.bartimaeusnek.bartworks.system.oredict.OreDictHandler;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.eventhandler.EventPriority;
@@ -32,10 +33,12 @@ import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraftforge.event.entity.EntityJoinWorldEvent;
public class ServerEventHandler {
+
@SubscribeEvent(priority = EventPriority.LOWEST)
- public void getTooltip(EntityJoinWorldEvent event) {
+ public void EntityJoinWorldEvent(EntityJoinWorldEvent event) {
if (event == null || !(event.entity instanceof EntityPlayerMP) || !FMLCommonHandler.instance().getSide().isServer())
return;
MainMod.BW_Network_instance.sendToPlayer(new OreDictCachePacket(OreDictHandler.getNonBWCache()), (EntityPlayerMP) event.entity);
+ MainMod.BW_Network_instance.sendToPlayer(new ServerJoinedPackage(null),(EntityPlayerMP) event.entity);
}
}
diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/CircuitGeneration/CircuitImprintLoader.java b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/CircuitGeneration/CircuitImprintLoader.java
index aa1470073e..4a3421a51d 100644
--- a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/CircuitGeneration/CircuitImprintLoader.java
+++ b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/CircuitGeneration/CircuitImprintLoader.java
@@ -107,8 +107,9 @@ public class CircuitImprintLoader implements Runnable {
GT_Recipe newRecipe = original.copy();
for (ItemStack is : newRecipe.mInputs){
int[] oreIDs = OreDictionary.getOreIDs(is);
- if(oreIDs == null || oreIDs.length < 1 || !OreDictionary.getOreName(oreIDs[0]).contains("circuit"))
- is.stackSize = Math.max( 64, is.stackSize *= 4);
+ if(oreIDs == null || oreIDs.length < 1 || !OreDictionary.getOreName(oreIDs[0]).contains("circuit")) {
+ is.stackSize = Math.max(64, is.stackSize*4);
+ }
}
newRecipe.mFluidInputs[0].amount *= 4;
newRecipe.mDuration *= 4;
@@ -117,39 +118,38 @@ public class CircuitImprintLoader implements Runnable {
public static GT_Recipe reBuildRecipe(GT_Recipe original){
ItemStack out = original.copy().getOutput(0);
- out.stackSize = 16;
+ out.stackSize *= 16;
ItemStack[] in = new ItemStack[6];
BiMap<ItemList, Short> inversed = CircuitImprintLoader.circuitIIconRefs.inverse();
for (int i = 0; i < 6; i++) {
try {
- for (ItemList il : inversed.keySet()){
+ for (ItemList il : inversed.keySet()){
if (GT_Utility.areStacksEqual(il.get(1), original.mInputs[i])) {
in[i] = BW_Meta_Items.getNEWCIRCUITS().getStack(inversed.get(il), original.mInputs[i].stackSize);
}
- }
- if (original.mInputs[i] != null && in[i] == null){
- if (BW_Util.checkStackAndPrefix(original.mInputs[i]) && GT_OreDictUnificator.getAssociation(original.mInputs[i]).mPrefix == OrePrefixes.wireGt01){
- in[i] = GT_OreDictUnificator.get(OrePrefixes.wireGt16,GT_OreDictUnificator.getAssociation(original.mInputs[i]).mMaterial.mMaterial,original.mInputs[i].stackSize);
- }
- else {
- in[i] = original.mInputs[i].copy();
- in[i].stackSize *= 16;
- }
-// if (in[i].stackSize > 64)
-// return null;
- }
- } catch (ArrayIndexOutOfBoundsException e){
- break;
- } catch (NullPointerException e){
- e.printStackTrace();
- }
- }
- if (CircuitImprintLoader.checkForBlacklistedComponents(in)){
+ }
+ if (original.mInputs[i] != null && in[i] == null){
+ if (BW_Util.checkStackAndPrefix(original.mInputs[i]) && GT_OreDictUnificator.getAssociation(original.mInputs[i]).mPrefix == OrePrefixes.wireGt01){
+ in[i] = GT_OreDictUnificator.get(OrePrefixes.wireGt16,GT_OreDictUnificator.getAssociation(original.mInputs[i]).mMaterial.mMaterial,original.mInputs[i].stackSize);
+ }
+ else {
+ in[i] = original.mInputs[i].copy();
+ in[i].stackSize *= 16;
+ }
+// if (in[i].stackSize > 64)
+// return null;
+ }
+ } catch (ArrayIndexOutOfBoundsException e){
+ break;
+ } catch (NullPointerException e){
+ e.printStackTrace();
+ }
+ }
+ if (CircuitImprintLoader.checkForBlacklistedComponents(in)){
return null;
- }
-
- return new BWRecipes.DynamicGTRecipe(false,in,new ItemStack[]{out},BW_Meta_Items.getNEWCIRCUITS().getStackWithNBT(CircuitImprintLoader.getTagFromStack(original.mOutputs[0]),0,0),null, original.mFluidInputs,null,original.mDuration,original.mEUt,original.mSpecialValue);
+ }
+ return new BWRecipes.DynamicGTRecipe(false,in,new ItemStack[]{out},BW_Meta_Items.getNEWCIRCUITS().getStackWithNBT(CircuitImprintLoader.getTagFromStack(original.mOutputs[0]),0,0),null, original.mFluidInputs,null,original.mDuration,original.mEUt,original.mSpecialValue);
}
diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/CircuitGeneration/CircuitPartLoader.java b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/CircuitGeneration/CircuitPartLoader.java
index 7bec3e9213..4c754e4caf 100644
--- a/src/main/java/com/github/bartimaeusnek/bartworks/system/material/CircuitGeneration/CircuitPartLoader.java
+++ b/src/main/java/com/github/bartimaeusnek/bartworks/system/material/CircuitGeneration/CircuitPartLoader.java
@@ -86,7 +86,8 @@ public class CircuitPartLoader implements Runnable {
name = OreDictionary.getOreName(oreIDS[0]);
if ((name == null || name.isEmpty()) && (single.toString().contains("Circuit") || single.toString().contains("circuit") || single.toString().contains("board")) && single.getBlock() == Blocks.air) {
ArrayList<String> toolTip = new ArrayList<>();
- single.getItem().addInformation(single.get(1).copy(), null, toolTip, true);
+ if (FMLCommonHandler.instance().getEffectiveSide().isClient())
+ single.getItem().addInformation(single.get(1).copy(), null, toolTip, true);
String tt = (toolTip.size() > 0 ? toolTip.get(0) : "");
// tt += "Internal Name = "+single;
String localised = GT_LanguageManager.getTranslation(GT_LanguageManager.getTranslateableItemStackName(itemStack));
diff --git a/src/main/java/com/github/bartimaeusnek/bartworks/util/BWRecipes.java b/src/main/java/com/github/bartimaeusnek/bartworks/util/BWRecipes.java
index e6c83a7f76..be9f710991 100644
--- a/src/main/java/com/github/bartimaeusnek/bartworks/util/BWRecipes.java
+++ b/src/main/java/com/github/bartimaeusnek/bartworks/util/BWRecipes.java
@@ -47,6 +47,7 @@ import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fluids.FluidStack;
import javax.annotation.Nonnegative;
+import java.io.Serializable;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashSet;
@@ -495,7 +496,7 @@ public class BWRecipes {
return false;
}
- public static class DynamicGTRecipe extends GT_Recipe {
+ public static class DynamicGTRecipe extends GT_Recipe implements Serializable {
public DynamicGTRecipe(boolean aOptimize, ItemStack[] aInputs, ItemStack[] aOutputs, Object aSpecialItems, int[] aChances, FluidStack[] aFluidInputs, FluidStack[] aFluidOutputs, int aDuration, int aEUt, int aSpecialValue) {
super(aOptimize, aInputs, aOutputs, aSpecialItems, aChances, aFluidInputs, aFluidOutputs, aDuration, aEUt, aSpecialValue);
}