Skip to content

Commit 4fd855e

Browse files
authored
Merge branch 'GregTechCEu:master' into master
2 parents 539e56c + 8e9efb7 commit 4fd855e

File tree

96 files changed

+1525
-1197
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

96 files changed

+1525
-1197
lines changed

dependencies.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
dependencies {
4141
// Published dependencies
4242
api("codechicken:codechickenlib:3.2.3.358")
43-
api("com.cleanroommc:modularui:2.5.0-rc2") { transitive = false }
43+
api("com.cleanroommc:modularui:2.5.0-rc3") { transitive = false }
4444
api("com.cleanroommc:groovyscript:1.2.0-hotfix1") { transitive = false }
4545
api("CraftTweaker2:CraftTweaker2-MC1120-Main:1.12-4.1.20.700")
4646
api("appeng:ae2-uel:v0.56.4") { transitive = false }

src/main/java/gregtech/GregTechMod.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@
3131
acceptedMinecraftVersions = "[1.12.2,1.13)",
3232
version = GTInternalTags.VERSION,
3333
dependencies = "required:forge@[14.23.5.2847,);" + "required-after:codechickenlib@[3.2.3,);" +
34-
"required-after:modularui@[2.3,);" + "required-after:mixinbooter@[8.0,);" + "after:appliedenergistics2;" +
34+
"required-after:modularui@[2.5.0-rc,);" + "required-after:mixinbooter@[8.0,);" +
35+
"after:appliedenergistics2;" +
3536
"after:forestry;" + "after:extrabees;" + "after:extratrees;" + "after:genetics;" + "after:magicbees;" +
3637
"after:jei@[4.15.0,);" + "after:crafttweaker@[4.1.20,);" + "after:groovyscript@[1.2.0,);" +
3738
"after:theoneprobe;" + "after:hwyla;")

src/main/java/gregtech/api/GTValues.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -122,11 +122,12 @@ public class GTValues {
122122
* The short names for the voltages, formatted for text
123123
*/
124124
public static final String[] VNF = new String[] {
125-
DARK_GRAY + "ULV", GRAY + "LV", AQUA + "MV",
126-
GOLD + "HV", DARK_PURPLE + "EV", DARK_BLUE + "IV",
127-
LIGHT_PURPLE + "LuV", RED + "ZPM", DARK_AQUA + "UV",
128-
DARK_RED + "UHV", GREEN + "UEV", DARK_GREEN + "UIV",
129-
YELLOW + "UXV", BLUE + "OpV", RED.toString() + BOLD + "MAX" };
125+
RED + "ULV", GRAY + "LV", GOLD + "MV",
126+
YELLOW + "HV", DARK_GRAY + "EV", WHITE + "IV",
127+
LIGHT_PURPLE + "LuV", AQUA + "ZPM", DARK_GREEN + "UV",
128+
DARK_RED + "UHV", DARK_BLUE + "UEV", DARK_GREEN.toString() + BOLD + "UIV",
129+
DARK_PURPLE.toString() + BOLD + "UXV", DARK_RED.toString() + BOLD + "OpV",
130+
RED.toString() + BOLD + "MAX" };
130131

131132
/**
132133
* The short names for the voltages, up to max Long, formatted for text
@@ -146,7 +147,7 @@ public class GTValues {
146147
* Color values for the voltages
147148
*/
148149
public static final int[] VC = new int[] { 0xC80000, 0xDCDCDC, 0xFF6400, 0xFFFF1E, 0x808080, 0xF0F0F5, 0xE99797,
149-
0x7EC3C4, 0x7EB07E, 0xBF74C0, 0x0B5CFE, 0x914E91, 0x488748, 0x8C0000, 0x2828F5 };
150+
0x7EC3C4, 0x7EB07E, 0xBF74C0, 0x0B5CFE, 0x488748, 0x914E91, 0x8C0000, 0x2828F5 };
150151

151152
/**
152153
* The long names for the voltages

src/main/java/gregtech/api/capability/impl/AbstractRecipeLogic.java

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import gregtech.api.GTValues;
44
import gregtech.api.capability.GregtechDataCodes;
55
import gregtech.api.capability.GregtechTileCapabilities;
6+
import gregtech.api.capability.IEnergyContainer;
67
import gregtech.api.capability.IMultiblockController;
78
import gregtech.api.capability.IMultipleTankHandler;
89
import gregtech.api.capability.IWorkable;
@@ -101,17 +102,27 @@ public AbstractRecipeLogic(MetaTileEntity tileEntity, RecipeMap<?> recipeMap, bo
101102
/**
102103
* @return the energy container's energy input per second
103104
*/
104-
protected abstract long getEnergyInputPerSecond();
105+
protected long getEnergyInputPerSecond() {
106+
return getEnergyContainer().getInputPerSec();
107+
}
105108

106109
/**
107110
* @return the energy container's current stored energy
108111
*/
109-
protected abstract long getEnergyStored();
112+
protected long getEnergyStored() {
113+
return getEnergyContainer().getEnergyStored();
114+
}
110115

111116
/**
112117
* @return the energy container's maximum energy capacity
113118
*/
114-
protected abstract long getEnergyCapacity();
119+
protected long getEnergyCapacity() {
120+
return getEnergyContainer().getEnergyCapacity();
121+
}
122+
123+
protected IEnergyContainer getEnergyContainer() {
124+
return IEnergyContainer.DEFAULT;
125+
}
115126

116127
/**
117128
* Draw energy from the energy container
@@ -120,12 +131,22 @@ public AbstractRecipeLogic(MetaTileEntity tileEntity, RecipeMap<?> recipeMap, bo
120131
* @param simulate whether to simulate energy extraction or not
121132
* @return true if the energy can/was drained, otherwise false
122133
*/
123-
protected abstract boolean drawEnergy(long recipeEUt, boolean simulate);
134+
protected boolean drawEnergy(long recipeEUt, boolean simulate) {
135+
// this should be the ONLY time eut is negative!
136+
if (consumesEnergy()) recipeEUt = -recipeEUt;
137+
long resultEnergy = getEnergyStored() + recipeEUt;
138+
if (resultEnergy >= 0L && resultEnergy <= getEnergyCapacity()) {
139+
if (!simulate) getEnergyContainer().changeEnergy(recipeEUt);
140+
return true;
141+
} else return false;
142+
}
124143

125144
/**
126145
* @return the maximum voltage the machine can use/handle for recipe searching
127146
*/
128-
public abstract long getMaxVoltage();
147+
public long getMaxVoltage() {
148+
return Math.max(getEnergyContainer().getInputVoltage(), getEnergyContainer().getOutputVoltage());
149+
}
129150

130151
/**
131152
*
@@ -941,7 +962,7 @@ public String[] getAvailableOverclockingTiers() {
941962
protected void setupRecipe(@NotNull Recipe recipe) {
942963
this.progressTime = 1;
943964
setMaxProgress(ocResult.duration());
944-
this.recipeEUt = consumesEnergy() ? ocResult.eut() : -ocResult.eut();
965+
this.recipeEUt = ocResult.eut();
945966

946967
int recipeTier = GTUtility.getTierByVoltage(recipe.getEUt());
947968
int machineTier = getOverclockForTier(getMaximumOverclockVoltage());
@@ -1226,7 +1247,7 @@ public void deserializeNBT(@NotNull NBTTagCompound compound) {
12261247
if (progressTime > 0) {
12271248
this.isActive = true;
12281249
this.maxProgressTime = compound.getInteger("MaxProgress");
1229-
this.recipeEUt = compound.getLong("RecipeEUt");
1250+
this.recipeEUt = Math.abs(compound.getLong("RecipeEUt"));
12301251
NBTTagList itemOutputsList = compound.getTagList("ItemOutputs", Constants.NBT.TAG_COMPOUND);
12311252
this.itemOutputs = new ArrayList<>(itemOutputsList.tagCount());
12321253
for (int i = 0; i < itemOutputsList.tagCount(); i++) {

src/main/java/gregtech/api/capability/impl/BoilerRecipeLogic.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package gregtech.api.capability.impl;
22

33
import gregtech.api.GTValues;
4+
import gregtech.api.capability.IEnergyContainer;
45
import gregtech.api.capability.IMultiblockController;
56
import gregtech.api.capability.IMultipleTankHandler;
67
import gregtech.api.recipes.Recipe;
@@ -330,6 +331,12 @@ public long getMaxVoltage() {
330331
return 0;
331332
}
332333

334+
@Override
335+
protected IEnergyContainer getEnergyContainer() {
336+
GTLog.logger.error("Large Boiler called getEnergyContainer(), this should not be possible!");
337+
return super.getEnergyContainer();
338+
}
339+
333340
/**
334341
* @param fluidHandler the handler to drain from
335342
* @param amount the amount to drain

src/main/java/gregtech/api/capability/impl/MultiblockFuelRecipeLogic.java

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -95,19 +95,9 @@ protected long boostProduction(long production) {
9595
}
9696

9797
@Override
98-
protected boolean drawEnergy(long recipeEUt, boolean simulate) {
99-
long euToDraw = boostProduction(recipeEUt);
100-
long resultEnergy = getEnergyStored() - euToDraw;
101-
if (resultEnergy >= 0L && resultEnergy <= getEnergyCapacity()) {
102-
if (!simulate) getEnergyContainer().changeEnergy(-euToDraw);
103-
return true;
104-
}
105-
return false;
106-
}
107-
108-
@Override
109-
public long getInfoProviderEUt() {
110-
return boostProduction(super.getInfoProviderEUt());
98+
protected void setupRecipe(@NotNull Recipe recipe) {
99+
super.setupRecipe(recipe);
100+
this.recipeEUt = boostProduction(this.recipeEUt);
111101
}
112102

113103
@Override

src/main/java/gregtech/api/capability/impl/MultiblockRecipeLogic.java

Lines changed: 2 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -384,35 +384,11 @@ protected void performMufflerOperations() {
384384
}
385385
}
386386

387-
@Override
388-
protected long getEnergyInputPerSecond() {
389-
return getEnergyContainer().getInputPerSec();
390-
}
391-
392-
@Override
393-
protected long getEnergyStored() {
394-
return getEnergyContainer().getEnergyStored();
395-
}
396-
397-
@Override
398-
protected long getEnergyCapacity() {
399-
return getEnergyContainer().getEnergyCapacity();
400-
}
401-
402-
@Override
403-
protected boolean drawEnergy(long recipeEUt, boolean simulate) {
404-
long resultEnergy = getEnergyStored() - recipeEUt;
405-
if (resultEnergy >= 0L && resultEnergy <= getEnergyCapacity()) {
406-
if (!simulate) getEnergyContainer().changeEnergy(-recipeEUt);
407-
return true;
408-
} else return false;
409-
}
410-
411387
@Override
412388
public long getMaxVoltage() {
413389
IEnergyContainer energyContainer = getEnergyContainer();
414390
if (!consumesEnergy()) {
415-
// Generators
391+
// Generator Multiblocks
416392
long voltage = energyContainer.getOutputVoltage();
417393
long amperage = energyContainer.getOutputAmperage();
418394
if (energyContainer instanceof EnergyContainerList && amperage == 1) {
@@ -424,7 +400,7 @@ public long getMaxVoltage() {
424400
}
425401
return voltage;
426402
} else {
427-
// Machines
403+
// Machine Multiblocks
428404
if (energyContainer instanceof EnergyContainerList energyList) {
429405
long highestVoltage = energyList.getHighestInputVoltage();
430406
if (energyList.getNumHighestInputContainers() > 1) {

src/main/java/gregtech/api/capability/impl/RecipeLogicEnergy.java

Lines changed: 2 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -25,33 +25,8 @@ public RecipeLogicEnergy(MetaTileEntity tileEntity, RecipeMap<?> recipeMap,
2525
}
2626

2727
@Override
28-
protected long getEnergyInputPerSecond() {
29-
return energyContainer.get().getInputPerSec();
30-
}
31-
32-
@Override
33-
protected long getEnergyStored() {
34-
return energyContainer.get().getEnergyStored();
35-
}
36-
37-
@Override
38-
protected long getEnergyCapacity() {
39-
return energyContainer.get().getEnergyCapacity();
40-
}
41-
42-
@Override
43-
protected boolean drawEnergy(long recipeEUt, boolean simulate) {
44-
long resultEnergy = getEnergyStored() - recipeEUt;
45-
if (resultEnergy >= 0L && resultEnergy <= getEnergyCapacity()) {
46-
if (!simulate) energyContainer.get().changeEnergy(-recipeEUt);
47-
return true;
48-
}
49-
return false;
50-
}
51-
52-
@Override
53-
public long getMaxVoltage() {
54-
return Math.max(energyContainer.get().getInputVoltage(), energyContainer.get().getOutputVoltage());
28+
protected IEnergyContainer getEnergyContainer() {
29+
return energyContainer.get();
5530
}
5631

5732
@Override

src/main/java/gregtech/api/items/metaitem/stats/IItemBehaviour.java

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ default EnumActionResult onItemUseFirst(EntityPlayer player, World world, BlockP
3838

3939
default ActionResult<ItemStack> onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand,
4040
EnumFacing facing, float hitX, float hitY, float hitZ) {
41-
return ActionResult.newResult(EnumActionResult.PASS, player.getHeldItem(hand));
41+
return pass(player.getHeldItem(hand));
4242
}
4343

4444
default void addInformation(ItemStack itemStack, List<String> lines) {}
@@ -50,8 +50,20 @@ default Multimap<String, AttributeModifier> getAttributeModifiers(EntityEquipmen
5050
}
5151

5252
default ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
53-
return ActionResult.newResult(EnumActionResult.PASS, player.getHeldItem(hand));
53+
return pass(player.getHeldItem(hand));
5454
}
5555

5656
default void addPropertyOverride(@NotNull Item item) {}
57+
58+
default ActionResult<ItemStack> pass(ItemStack stack) {
59+
return ActionResult.newResult(EnumActionResult.PASS, stack);
60+
}
61+
62+
default ActionResult<ItemStack> success(ItemStack stack) {
63+
return ActionResult.newResult(EnumActionResult.SUCCESS, stack);
64+
}
65+
66+
default ActionResult<ItemStack> fail(ItemStack stack) {
67+
return ActionResult.newResult(EnumActionResult.FAIL, stack);
68+
}
5769
}

0 commit comments

Comments
 (0)