Skip to content

Commit 71f841e

Browse files
committed
Add compat for Coal Coke Dust
1 parent 242fa74 commit 71f841e

7 files changed

Lines changed: 93 additions & 4 deletions

File tree

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ run-data
2525
*.vscode
2626
*.zip
2727
*.mrpack
28-
*.jar
2928
*.exe
3029

3130
# Files from Forge MDK

README.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,21 @@ Pneumaticcraft takes priority, recipes have been unified, TFMG's plastic sheet i
2424
Mods: [Create: Connected](https://modrinth.com/mod/create-connected), [Create Utilities](https://modrinth.com/mod/create-utilities)<br>
2525
Create: Connected takes priority, recipes have been unified, Create Utilities's Gearcube is hid in JEI/REI/EMI. <br>
2626
</details>
27+
28+
<details>
29+
<summary>Coal Coke Dust</summary>
30+
31+
Mods: [Immersive Engineering](https://modrinth.com/mod/immersiveengineering), [TFMG](https://modrinth.com/mod/create-tfmg)<br>
32+
Coal Coke Dust from both mods works in both mods' processes and recipes.
33+
</details>
2734
<br>
2835

2936
### Fluids
3037

3138
<details>
3239
<summary>Crude Oil</summary>
3340

34-
Mods: [Ad Astra](https://modrinth.com/mod/ad-astra), [CDG](https://modrinth.com/mod/create-diesel-generators), [Destroy](https://modrinth.com/mod/destroy), [Pneumaticcraft](https://modrinth.com/mod/pneumaticcraft-repressurized), [TFMG](https://modrinth.com/mod/create-tfmg) <br>
41+
Mods: [Ad Astra](https://modrinth.com/mod/ad-astra), [CDG](https://modrinth.com/mod/create-diesel-generators), [C:L&W](https://modrinth.com/mod/create-love-war), [Destroy](https://modrinth.com/mod/destroy), [Pneumaticcraft](https://modrinth.com/mod/pneumaticcraft-repressurized), [TFMG](https://modrinth.com/mod/create-tfmg) <br>
3542
Crude Oil from all these mods works in all distillation processes requiring it present in these mods.<br>
3643
</details>
3744

@@ -57,7 +64,7 @@ Kerosene, Molten/Liquid Plastic, Lubricant/Lubrication Oil from both mods works
5764
<br><br>
5865

5966
## Installation
60-
The mod is currently only available for 1.20.1 (neo)forge. Fabric/Quilt versions and 1.19.2 versions may come later.<br>
67+
The mod is currently only available for 1.20.1 (neo)forge. Fabric/Quilt versions and >=1.21.1 versions will come soon. A port to 1.19.2 is not planned.<br>
6168
[Almost Unified](https://modrinth.com/mod/almost-unified) is required to be installed.<br>
6269
<br><br>
6370

@@ -69,7 +76,6 @@ They can be enabled during world creation or by using the ``/datapack enable`` c
6976
<br><br>
7077

7178
## Suggestions / More Compatibility Features
72-
If you want to change something like which mod takes priority please have a look at the [Wiki](https://github.com/Amronos/createaddoncompatibility/wiki/Unification-Config-Changes#changes-to-the-config-by-create-addon-compatibility). <br>
7379
I do have more compatibility features planned, but if you have any ideas feel free to create an issue on GitHub or tell me in the Discord server.
7480

7581
<br><br>

build.gradle

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,10 @@ repositories {
8989
name = "ModMaven"
9090
url = "https://modmaven.dev"
9191
}
92+
maven {
93+
name = "Modrinth Maven"
94+
url = "https://api.modrinth.com/maven"
95+
}
9296
}
9397

9498
dependencies {
@@ -108,6 +112,7 @@ dependencies {
108112

109113
implementation fg.deobf("com.almostreliable.mods:almostunified-forge:${almostunified_version}")
110114

115+
implementation fg.deobf("maven.modrinth:create-tfmg:0.9.3-1.20.1")
111116
}
112117

113118

gradle/wrapper/gradle-wrapper.jar

60.6 KB
Binary file not shown.

src/main/java/com/amronos/createaddoncompatibility/data/tags/ForgeTags.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ private static TagKey<Fluid> tag(String name) {
2222

2323
public static class Items {
2424
public static final TagKey<Item> PLASTIC = tag("ingots/plastic");
25+
public static final TagKey<Item> COKE_DUST = tag("dusts/coal_coke");
2526

2627
private static TagKey<Item> tag(String name) {
2728
return ItemTags.create(new ResourceLocation("forge", name));
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
package com.amronos.createaddoncompatibility.mixin;
2+
3+
import com.amronos.createaddoncompatibility.data.tags.ForgeTags;
4+
import com.drmangotea.tfmg.blocks.machines.metal_processing.blast_furnace.BlastFurnaceOutputBlockEntity;
5+
import com.drmangotea.tfmg.registry.TFMGItems;
6+
import com.simibubi.create.foundation.item.SmartInventory;
7+
import net.minecraft.world.entity.item.ItemEntity;
8+
import net.minecraft.world.item.ItemStack;
9+
import org.spongepowered.asm.mixin.Mixin;
10+
import org.spongepowered.asm.mixin.Pseudo;
11+
import org.spongepowered.asm.mixin.Shadow;
12+
import org.spongepowered.asm.mixin.Unique;
13+
import org.spongepowered.asm.mixin.injection.At;
14+
import org.spongepowered.asm.mixin.injection.Inject;
15+
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
16+
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
17+
18+
import java.util.List;
19+
20+
@Pseudo
21+
@Mixin(BlastFurnaceOutputBlockEntity.class)
22+
public class MixinBlastFurnaceOutputBlockEntity {
23+
@Shadow
24+
public SmartInventory fuelInventory;
25+
@Shadow
26+
public SmartInventory inputInventory;
27+
28+
@Unique
29+
public SmartInventory createaddoncompatibility$previousFuelInventory;
30+
@Unique
31+
public SmartInventory createaddoncompatibility$previousInputInventory;
32+
33+
@Inject(remap = false, method = "acceptInsertedItems", at = @At(value = "HEAD"))
34+
private void savePreviousInventory(CallbackInfo info){
35+
createaddoncompatibility$previousFuelInventory = fuelInventory;
36+
createaddoncompatibility$previousInputInventory = inputInventory;
37+
}
38+
39+
@Inject(remap = false, method = "acceptInsertedItems", at = @At(value = "TAIL"), locals = LocalCapture.CAPTURE_FAILSOFT)
40+
private void acceptInsertedItems(CallbackInfo info, List<ItemEntity> itemsToPick) {
41+
fuelInventory = createaddoncompatibility$previousFuelInventory;
42+
inputInventory = createaddoncompatibility$previousInputInventory;
43+
for (ItemEntity itemEntity : itemsToPick) {
44+
ItemStack itemStack = itemEntity.getItem();
45+
int count;
46+
int freeSpace2;
47+
if (itemStack.is(ForgeTags.Items.COKE_DUST)) {
48+
freeSpace2 = this.fuelInventory.getStackInSlot(0).getMaxStackSize() - this.fuelInventory.getStackInSlot(0).getCount();
49+
count = itemStack.getCount();
50+
if (count > freeSpace2) {
51+
itemStack.setCount(itemStack.getCount() - freeSpace2);
52+
this.fuelInventory.setItem(0, new ItemStack(TFMGItems.COAL_COKE_DUST.get(), this.fuelInventory.getStackInSlot(0).getCount() + freeSpace2));
53+
} else {
54+
this.fuelInventory.setItem(0, new ItemStack(TFMGItems.COAL_COKE_DUST.get(), this.fuelInventory.getStackInSlot(0).getCount() + itemStack.getCount()));
55+
itemEntity.discard();
56+
}
57+
} else {
58+
if (itemStack.getCount() == 1) {
59+
itemStack.setCount(2);
60+
itemEntity.setItem(itemStack);
61+
}
62+
63+
freeSpace2 = this.inputInventory.getStackInSlot(0).getMaxStackSize() - this.inputInventory.getStackInSlot(0).getCount();
64+
count = itemStack.getCount();
65+
if (this.inputInventory.isEmpty() || this.inputInventory.getItem(0).is(itemStack.getItem())) {
66+
if (count > freeSpace2) {
67+
itemStack.setCount(itemStack.getCount() - freeSpace2);
68+
this.inputInventory.setItem(0, new ItemStack(itemStack.getItem(), this.inputInventory.getStackInSlot(0).getCount() + freeSpace2));
69+
} else {
70+
this.inputInventory.setItem(0, new ItemStack(itemStack.getItem(), this.inputInventory.getStackInSlot(0).getCount() + itemStack.getCount()));
71+
itemEntity.discard();
72+
}
73+
}
74+
}
75+
}
76+
}
77+
}

src/main/resources/mixins.createaddoncompatibility.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"refmap": "createaddoncompatibility.refmap.json",
55
"compatibilityLevel": "JAVA_17",
66
"mixins": [
7+
"MixinBlastFurnaceOutputBlockEntity",
78
"MixinUnifyConfig"
89
],
910
"client": [

0 commit comments

Comments
 (0)