Browse Source

whoops there was a nullpointer in stonelayers

Gregorius Techneticies 2 months ago
parent
commit
50263eef59
Signed by: Gregorius Techneticies <gregoriustech@gmail.com> GPG Key ID: 1B693EA14F2FD70F

+ 5
- 7
src/main/java/gregapi/block/multitileentity/MultiTileEntityItemInternal.java View File

@@ -1,5 +1,5 @@
1 1
 /**
2
- * Copyright (c) 2020 GregTech-6 Team
2
+ * Copyright (c) 2021 GregTech-6 Team
3 3
  *
4 4
  * This file is part of GregTech.
5 5
  *
@@ -598,16 +598,14 @@ public class MultiTileEntityItemInternal extends ItemBlock implements squeek.app
598 598
 	}
599 599
 	
600 600
 	@Override
601
-	public double charge(ItemStack aStack, double aCharge, int aTier, boolean aIgnoreTransferLimit, boolean aSimulate) {
602
-		aTier = UT.Code.bind4(aTier);
603
-		if (aCharge < V[aTier]) return 0;
604
-		return V[aTier] * doEnergyInjection(TD.Energy.EU, aStack, V[aTier], (long)(aCharge / V[aTier]), null, null, 0, 0, 0, !aSimulate);
601
+	public double charge   (ItemStack aStack, double aCharge, int aTier, boolean aIgnoreTransferLimit, boolean aSimulate) {
602
+		if (aCharge < V[aTier = UT.Code.bind4(aTier)]) return 0;
603
+		return V[aTier] * doEnergyInjection (TD.Energy.EU, aStack, V[aTier], (long)(aCharge / V[aTier]), null, null, 0, 0, 0, !aSimulate);
605 604
 	}
606 605
 	
607 606
 	@Override
608 607
 	public double discharge(ItemStack aStack, double aCharge, int aTier, boolean aIgnoreTransferLimit, boolean aBatteryAlike, boolean aSimulate) {
609
-		aTier = UT.Code.bind4(aTier);
610
-		if (aCharge < V[aTier]) return 0;
608
+		if (aCharge < V[aTier = UT.Code.bind4(aTier)]) return 0;
611 609
 		return V[aTier] * doEnergyExtraction(TD.Energy.EU, aStack, V[aTier], (long)(aCharge / V[aTier]), null, null, 0, 0, 0, !aSimulate);
612 610
 	}
613 611
 	

+ 12
- 14
src/main/java/gregapi/item/multiitem/MultiItem.java View File

@@ -276,18 +276,6 @@ public abstract class MultiItem extends ItemBase implements IItemEnergy {
276 276
 		if (tList != null) for (IBehavior<MultiItem> tBehavior : tList) tBehavior.onUpdate(this, aStack, aWorld, aPlayer, aTimer, aIsInHand);
277 277
 	}
278 278
 	
279
-	public double charge(ItemStack aStack, double aCharge, int aTier, boolean aIgnoreTransferLimit, boolean aSimulate) {
280
-		aTier = UT.Code.bind4(aTier);
281
-		if (aCharge < V[aTier]) return 0;
282
-		return V[aTier] * doEnergyInjection(TD.Energy.EU, aStack, V[aTier], (long)(aCharge / V[aTier]), null, null, 0, 0, 0, !aSimulate);
283
-	}
284
-	
285
-	public double discharge(ItemStack aStack, double aCharge, int aTier, boolean aIgnoreTransferLimit, boolean aBatteryAlike, boolean aSimulate) {
286
-		aTier = UT.Code.bind4(aTier);
287
-		if (aCharge < V[aTier]) return 0;
288
-		return V[aTier] * doEnergyExtraction(TD.Energy.EU, aStack, V[aTier], (long)(aCharge / V[aTier]), null, null, 0, 0, 0, !aSimulate);
289
-	}
290
-	
291 279
 	public FluidStack getFluid(ItemStack aStack) {return getFluidContent(aStack);}
292 280
 	
293 281
 	public int getCapacity(ItemStack aStack) {
@@ -402,6 +390,16 @@ public abstract class MultiItem extends ItemBase implements IItemEnergy {
402 390
 	
403 391
 	public int getDefaultStackLimit(ItemStack aStack) {return 64;}
404 392
 	
393
+	public double charge   (ItemStack aStack, double aCharge, int aTier, boolean aIgnoreTransferLimit, boolean aSimulate) {
394
+		if (aCharge < V[aTier = UT.Code.bind4(aTier)]) return 0;
395
+		return V[aTier] * doEnergyInjection (TD.Energy.EU, aStack, V[aTier], (long)(aCharge / V[aTier]), null, null, 0, 0, 0, !aSimulate);
396
+	}
397
+	
398
+	public double discharge(ItemStack aStack, double aCharge, int aTier, boolean aIgnoreTransferLimit, boolean aBatteryAlike, boolean aSimulate) {
399
+		if (aCharge < V[aTier = UT.Code.bind4(aTier)]) return 0;
400
+		return V[aTier] * doEnergyExtraction(TD.Energy.EU, aStack, V[aTier], (long)(aCharge / V[aTier]), null, null, 0, 0, 0, !aSimulate);
401
+	}
402
+	
405 403
 	@Override
406 404
 	public boolean isEnergyType(TagData aEnergyType, ItemStack aStack, boolean aEmitting) {
407 405
 		IItemEnergy tStats = getEnergyStats(aStack);
@@ -410,10 +408,10 @@ public abstract class MultiItem extends ItemBase implements IItemEnergy {
410 408
 	}
411 409
 	
412 410
 	@Override
413
-	public long doEnergyInjection(TagData aEnergyType, ItemStack aStack, long aSize, long aAmount, IInventory aInventory, World aWorld, int aX, int aY, int aZ, boolean aDoInject) {
411
+	public long doEnergyInjection (TagData aEnergyType, ItemStack aStack, long aSize, long aAmount, IInventory aInventory, World aWorld, int aX, int aY, int aZ, boolean aDoInject) {
414 412
 		IItemEnergy tStats = getEnergyStats(aStack);
415 413
 		if (tStats == null) return 0;
416
-		return tStats.doEnergyInjection(aEnergyType, aStack, aSize, aAmount, aInventory, aWorld, aX, aY, aZ, aDoInject);
414
+		return tStats.doEnergyInjection (aEnergyType, aStack, aSize, aAmount, aInventory, aWorld, aX, aY, aZ, aDoInject);
417 415
 	}
418 416
 	
419 417
 	@Override

+ 15
- 15
src/main/java/gregapi/item/multiitem/energy/EnergyStat.java View File

@@ -1,5 +1,5 @@
1 1
 /**
2
- * Copyright (c) 2019 Gregorius Techneticies
2
+ * Copyright (c) 2021 GregTech-6 Team
3 3
  *
4 4
  * This file is part of GregTech.
5 5
  *
@@ -55,14 +55,14 @@ public class EnergyStat implements IItemEnergy {
55 55
 		mFullItem = aFullItem;
56 56
 	}
57 57
 	
58
-	public static IItemEnergy makeREBattery (TagData aEnergyType, long aCapacity, long aSize, long aAmountIN, long aAmountOUT, ItemStack aEmptyItem, ItemStack aHalfItem, ItemStack aFullItem) {return new EnergyStat(aEnergyType, aCapacity, aSize, aAmountIN, aAmountOUT, T, T, aEmptyItem, aHalfItem, aFullItem);}
59
-	public static IItemEnergy makeREBattery (TagData aEnergyType, long aCapacity, long aSize, long aAmountIN, long aAmountOUT, ItemStack aItem) {return new EnergyStat(aEnergyType, aCapacity, aSize, aAmountIN, aAmountOUT, T, T, aItem, aItem, aItem);}
60
-	public static IItemEnergy makeREBattery (TagData aEnergyType, long aCapacity, long aSize, long aAmount, ItemStack aEmptyItem, ItemStack aHalfItem, ItemStack aFullItem) {return new EnergyStat(aEnergyType, aCapacity, aSize, aAmount, aAmount, T, T, aEmptyItem, aHalfItem, aFullItem);}
61
-	public static IItemEnergy makeREBattery (TagData aEnergyType, long aCapacity, long aSize, long aAmount, ItemStack aItem) {return new EnergyStat(aEnergyType, aCapacity, aSize, aAmount, aAmount, T, T, aItem, aItem, aItem);}
62
-	public static IItemEnergy makeSUBattery (TagData aEnergyType, long aCapacity, long aSize, long aAmount, ItemStack aEmptyItem, ItemStack aHalfItem, ItemStack aFullItem) {return new EnergyStat(aEnergyType, aCapacity, aSize, aAmount, aAmount, F, T, aEmptyItem, aHalfItem, aFullItem);}
63
-	public static IItemEnergy makeSUBattery (TagData aEnergyType, long aCapacity, long aSize, long aAmount, ItemStack aItem) {return new EnergyStat(aEnergyType, aCapacity, aSize, aAmount, aAmount, F, T, aItem, aItem, aItem);}
64
-	public static IItemEnergy makeTool      (TagData aEnergyType, long aCapacity, long aSize, long aAmount, ItemStack aEmptyItem, ItemStack aHalfItem, ItemStack aFullItem) {return new EnergyStat(aEnergyType, aCapacity, aSize, aAmount, aAmount, T, F, aEmptyItem, aHalfItem, aFullItem);}
65
-	public static IItemEnergy makeTool      (TagData aEnergyType, long aCapacity, long aSize, long aAmount, ItemStack aItem) {return new EnergyStat(aEnergyType, aCapacity, aSize, aAmount, aAmount, T, F, aItem, aItem, aItem);}
58
+	public static IItemEnergy makeREBattery(TagData aEnergyType, long aCapacity, long aSize, long aAmountIN, long aAmountOUT, ItemStack aEmptyItem, ItemStack aHalfItem, ItemStack aFullItem) {return new EnergyStat(aEnergyType, aCapacity, aSize, aAmountIN, aAmountOUT, T, T, aEmptyItem, aHalfItem, aFullItem);}
59
+	public static IItemEnergy makeREBattery(TagData aEnergyType, long aCapacity, long aSize, long aAmountIN, long aAmountOUT, ItemStack aItem) {return new EnergyStat(aEnergyType, aCapacity, aSize, aAmountIN, aAmountOUT, T, T, aItem, aItem, aItem);}
60
+	public static IItemEnergy makeREBattery(TagData aEnergyType, long aCapacity, long aSize, long aAmount, ItemStack aEmptyItem, ItemStack aHalfItem, ItemStack aFullItem) {return new EnergyStat(aEnergyType, aCapacity, aSize, aAmount, aAmount, T, T, aEmptyItem, aHalfItem, aFullItem);}
61
+	public static IItemEnergy makeREBattery(TagData aEnergyType, long aCapacity, long aSize, long aAmount, ItemStack aItem) {return new EnergyStat(aEnergyType, aCapacity, aSize, aAmount, aAmount, T, T, aItem, aItem, aItem);}
62
+	public static IItemEnergy makeSUBattery(TagData aEnergyType, long aCapacity, long aSize, long aAmount, ItemStack aEmptyItem, ItemStack aHalfItem, ItemStack aFullItem) {return new EnergyStat(aEnergyType, aCapacity, aSize, aAmount, aAmount, F, T, aEmptyItem, aHalfItem, aFullItem);}
63
+	public static IItemEnergy makeSUBattery(TagData aEnergyType, long aCapacity, long aSize, long aAmount, ItemStack aItem) {return new EnergyStat(aEnergyType, aCapacity, aSize, aAmount, aAmount, F, T, aItem, aItem, aItem);}
64
+	public static IItemEnergy makeTool     (TagData aEnergyType, long aCapacity, long aSize, long aAmount, ItemStack aEmptyItem, ItemStack aHalfItem, ItemStack aFullItem) {return new EnergyStat(aEnergyType, aCapacity, aSize, aAmount, aAmount, T, F, aEmptyItem, aHalfItem, aFullItem);}
65
+	public static IItemEnergy makeTool     (TagData aEnergyType, long aCapacity, long aSize, long aAmount, ItemStack aItem) {return new EnergyStat(aEnergyType, aCapacity, aSize, aAmount, aAmount, T, F, aItem, aItem, aItem);}
66 66
 	
67 67
 	@Override
68 68
 	public long doEnergyInjection(TagData aEnergyType, ItemStack aStack, long aSize, long aAmount, IInventory aInventory, World aWorld, int aX, int aY, int aZ, boolean aDoInject) {
@@ -156,13 +156,13 @@ public class EnergyStat implements IItemEnergy {
156 156
 		return tNBT==null?0:tNBT.getLong(NBT_ENERGY);
157 157
 	}
158 158
 	
159
-	@Override public long getEnergyCapacity(TagData aEnergyType, ItemStack aStack) {return aEnergyType == mType || aEnergyType == null ? mCapacity : 0;}
160
-	@Override public long getEnergySizeInputMin(TagData aEnergyType, ItemStack aStack) {return aEnergyType == mType || aEnergyType == null ? mSize <= 8 ? 1 : mSize / 2 : 0;}
161
-	@Override public long getEnergySizeOutputMin(TagData aEnergyType, ItemStack aStack) {return aEnergyType == mType || aEnergyType == null ? mSize <= 8 ? 1 : mSize / 2 : 0;}
162
-	@Override public long getEnergySizeInputRecommended(TagData aEnergyType, ItemStack aStack) {return aEnergyType == mType || aEnergyType == null ? mSize : 0;}
159
+	@Override public long getEnergyCapacity             (TagData aEnergyType, ItemStack aStack) {return aEnergyType == mType || aEnergyType == null ? mCapacity : 0;}
160
+	@Override public long getEnergySizeInputMin         (TagData aEnergyType, ItemStack aStack) {return aEnergyType == mType || aEnergyType == null ? mSize <= 8 ? 1 : mSize / 2 : 0;}
161
+	@Override public long getEnergySizeOutputMin        (TagData aEnergyType, ItemStack aStack) {return aEnergyType == mType || aEnergyType == null ? mSize <= 8 ? 1 : mSize / 2 : 0;}
162
+	@Override public long getEnergySizeInputRecommended (TagData aEnergyType, ItemStack aStack) {return aEnergyType == mType || aEnergyType == null ? mSize : 0;}
163 163
 	@Override public long getEnergySizeOutputRecommended(TagData aEnergyType, ItemStack aStack) {return aEnergyType == mType || aEnergyType == null ? mSize : 0;}
164
-	@Override public long getEnergySizeInputMax(TagData aEnergyType, ItemStack aStack) {return aEnergyType == mType || aEnergyType == null ? mSize * 2 : 0;}
165
-	@Override public long getEnergySizeOutputMax(TagData aEnergyType, ItemStack aStack) {return aEnergyType == mType || aEnergyType == null ? mSize * 2 : 0;}
164
+	@Override public long getEnergySizeInputMax         (TagData aEnergyType, ItemStack aStack) {return aEnergyType == mType || aEnergyType == null ? mSize * 2 : 0;}
165
+	@Override public long getEnergySizeOutputMax        (TagData aEnergyType, ItemStack aStack) {return aEnergyType == mType || aEnergyType == null ? mSize * 2 : 0;}
166 166
 	@Override public Collection<TagData> getEnergyTypes(ItemStack aStack) {return new HashSetNoNulls<>(F, mType);}
167 167
 	@Override public boolean isEnergyType(TagData aEnergyType, ItemStack aStack, boolean aEmitting) {return (aEnergyType == mType || aEnergyType == null) && (aEmitting ? mCanDecharge : mCanCharge);}
168 168
 	@Override public boolean canEnergyInjection (TagData aEnergyType, ItemStack aStack, long aSize) {return mCanCharge   && (aEnergyType == mType || aEnergyType == null) && aStack.stackSize == 1 && aSize <= getEnergySizeInputMax (aEnergyType, aStack) && aSize >= getEnergySizeInputMin (aEnergyType, aStack);}

+ 1
- 1
src/main/java/gregapi/worldgen/StoneLayer.java View File

@@ -75,7 +75,7 @@ public class StoneLayer {
75 75
 		mOreBroken  = BlocksGT.stoneToBrokenOres.get(mStack);
76 76
 		mOreSmall   = BlocksGT.stoneToSmallOres .get(mStack);
77 77
 		mOres       = new ArrayListNoNulls<>(8);
78
-		for (StoneLayerOres tOre : aOres) if (tOre.mMaterial != MT.Empty && ConfigsGT.WORLDGEN.get("stonelayers."+mMaterial.mNameInternal, tOre.mMaterial.mNameInternal, T)) mOres.add(tOre);
78
+		for (StoneLayerOres tOre : aOres) if (tOre != null && tOre.mMaterial != MT.Empty && ConfigsGT.WORLDGEN.get("stonelayers."+mMaterial.mNameInternal, tOre.mMaterial.mNameInternal, T)) mOres.add(tOre);
79 79
 	}
80 80
 	
81 81
 	/** List of Stone and Ore Blocks, that can simply be replaced by the Stone Layers. */

Loading…
Cancel
Save