Skip to content

Commit 0466fd6

Browse files
committed
Prepare for first alpha
1 parent e7c67db commit 0466fd6

File tree

76 files changed

+496
-321
lines changed

Some content is hidden

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

76 files changed

+496
-321
lines changed

build.gradle

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,8 @@ loom {
110110
}
111111
}
112112
assemble.dependsOn runDatagenClient
113-
test.dependsOn runGametest
113+
// TODO: re-enable tests when we add one
114+
//test.dependsOn runGametest
114115

115116
tasks.withType(JavaCompile).configureEach {
116117
// Minecraft 1.18 (1.18-pre2) upwards uses Java 17.

src/main/java/dev/technici4n/moderndynamics/Constants.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
// All the things that should be moved to a config "one day"
2424
public class Constants {
2525
public static class Fluids {
26-
public static final long BASE_IO = FluidConstants.BUCKET / 10;
26+
public static final long BASE_IO = FluidConstants.BUCKET / 20;
2727
public static final long CAPACITY = FluidConstants.BUCKET;
2828
}
2929
}

src/main/java/dev/technici4n/moderndynamics/attachment/AttachmentTier.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@
2121
import net.minecraft.world.item.Rarity;
2222

2323
public enum AttachmentTier {
24-
BASIC(3, 4, 40, 1, Rarity.COMMON),
25-
IMPROVED(9, 16, 20, 2, Rarity.UNCOMMON),
26-
ADVANCED(15, 64, 10, 3, Rarity.RARE),
24+
IRON(3, 4, 40, 2, Rarity.COMMON),
25+
GOLD(9, 16, 20, 4, Rarity.UNCOMMON),
26+
DIAMOND(15, 64, 10, 10, Rarity.RARE),
2727
;
2828

2929
public final int filterSize;
@@ -41,6 +41,6 @@ public enum AttachmentTier {
4141
}
4242

4343
public boolean allowAdvancedBehavior() {
44-
return this == ADVANCED;
44+
return this == DIAMOND;
4545
}
4646
}

src/main/java/dev/technici4n/moderndynamics/attachment/IoAttachmentItem.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public AttachedAttachment createAttached(NodeHost host, CompoundTag configTag) {
6767
public Set<Setting> getSupportedSettings() {
6868
var result = EnumSet.noneOf(Setting.class);
6969
result.add(Setting.FILTER_INVERSION);
70-
if (tier.compareTo(AttachmentTier.IMPROVED) >= 0) {
70+
if (tier.compareTo(AttachmentTier.GOLD) >= 0) {
7171
result.add(Setting.FILTER_DAMAGE);
7272
result.add(Setting.FILTER_NBT);
7373
result.add(Setting.FILTER_MOD);
@@ -76,19 +76,19 @@ public Set<Setting> getSupportedSettings() {
7676
switch (type) {
7777
case FILTER -> {
7878
result.add(Setting.OVERSENDING_MODE);
79-
if (tier.compareTo(AttachmentTier.IMPROVED) >= 0) {
79+
if (tier.compareTo(AttachmentTier.GOLD) >= 0) {
8080
result.add(Setting.MAX_ITEMS_IN_INVENTORY);
8181
}
8282
}
8383
case SERVO -> {
8484
result.add(Setting.MAX_ITEMS_EXTRACTED);
85-
if (tier.compareTo(AttachmentTier.IMPROVED) >= 0) {
85+
if (tier.compareTo(AttachmentTier.GOLD) >= 0) {
8686
result.add(Setting.ROUTING_MODE);
8787
}
8888
}
8989
case RETRIEVER -> {
9090
result.add(Setting.MAX_ITEMS_EXTRACTED);
91-
if (tier.compareTo(AttachmentTier.IMPROVED) >= 0) {
91+
if (tier.compareTo(AttachmentTier.GOLD) >= 0) {
9292
result.add(Setting.MAX_ITEMS_IN_INVENTORY);
9393
result.add(Setting.ROUTING_MODE);
9494
}

src/main/java/dev/technici4n/moderndynamics/attachment/MdAttachments.java

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -19,23 +19,23 @@
1919
package dev.technici4n.moderndynamics.attachment;
2020

2121
public class MdAttachments {
22-
public static final RenderedAttachment BASIC_SERVO = new RenderedAttachment("basic_servo");
23-
public static final RenderedAttachment IMPROVED_SERVO = new RenderedAttachment("improved_servo");
24-
public static final RenderedAttachment ADVANCED_SERVO = new RenderedAttachment("advanced_servo");
25-
public static final RenderedAttachment BASIC_SERVO_STUFFED = new RenderedAttachment("basic_servo_stuffed");
26-
public static final RenderedAttachment IMPROVED_SERVO_STUFFED = new RenderedAttachment("improved_servo_stuffed");
27-
public static final RenderedAttachment ADVANCED_SERVO_STUFFED = new RenderedAttachment("advanced_servo_stuffed");
22+
public static final RenderedAttachment IRON_SERVO = new RenderedAttachment("iron_servo");
23+
public static final RenderedAttachment GOLD_SERVO = new RenderedAttachment("gold_servo");
24+
public static final RenderedAttachment DIAMOND_SERVO = new RenderedAttachment("diamond_servo");
25+
public static final RenderedAttachment IRON_SERVO_STUFFED = new RenderedAttachment("iron_servo_stuffed");
26+
public static final RenderedAttachment GOLD_SERVO_STUFFED = new RenderedAttachment("gold_servo_stuffed");
27+
public static final RenderedAttachment DIAMOND_SERVO_STUFFED = new RenderedAttachment("diamond_servo_stuffed");
2828

29-
public static final RenderedAttachment BASIC_RETRIEVER = new RenderedAttachment("basic_retriever");
30-
public static final RenderedAttachment IMPROVED_RETRIEVER = new RenderedAttachment("improved_retriever");
31-
public static final RenderedAttachment ADVANCED_RETRIEVER = new RenderedAttachment("advanced_retriever");
32-
public static final RenderedAttachment BASIC_RETRIEVER_STUFFED = new RenderedAttachment("basic_retriever_stuffed");
33-
public static final RenderedAttachment IMPROVED_RETRIEVER_STUFFED = new RenderedAttachment("improved_retriever_stuffed");
34-
public static final RenderedAttachment ADVANCED_RETRIEVER_STUFFED = new RenderedAttachment("advanced_retriever_stuffed");
29+
public static final RenderedAttachment IRON_RETRIEVER = new RenderedAttachment("iron_retriever");
30+
public static final RenderedAttachment GOLD_RETRIEVER = new RenderedAttachment("gold_retriever");
31+
public static final RenderedAttachment DIAMOND_RETRIEVER = new RenderedAttachment("diamond_retriever");
32+
public static final RenderedAttachment IRON_RETRIEVER_STUFFED = new RenderedAttachment("iron_retriever_stuffed");
33+
public static final RenderedAttachment GOLD_RETRIEVER_STUFFED = new RenderedAttachment("gold_retriever_stuffed");
34+
public static final RenderedAttachment DIAMOND_RETRIEVER_STUFFED = new RenderedAttachment("diamond_retriever_stuffed");
3535

36-
public static final RenderedAttachment BASIC_FILTER = new RenderedAttachment("basic_filter");
37-
public static final RenderedAttachment IMPROVED_FILTER = new RenderedAttachment("improved_filter");
38-
public static final RenderedAttachment ADVANCED_FILTER = new RenderedAttachment("advanced_filter");
36+
public static final RenderedAttachment IRON_FILTER = new RenderedAttachment("iron_filter");
37+
public static final RenderedAttachment GOLD_FILTER = new RenderedAttachment("gold_filter");
38+
public static final RenderedAttachment DIAMOND_FILTER = new RenderedAttachment("diamond_filter");
3939

4040
public static final RenderedAttachment INHIBITOR = new RenderedAttachment("inhibitor");
4141

src/main/java/dev/technici4n/moderndynamics/attachment/attached/ItemAttachedIo.java

Lines changed: 53 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@
3434
import java.util.List;
3535
import java.util.Map;
3636
import net.fabricmc.fabric.api.transfer.v1.item.ItemVariant;
37+
import net.fabricmc.fabric.api.transfer.v1.storage.Storage;
38+
import net.fabricmc.fabric.api.transfer.v1.transaction.Transaction;
3739
import net.minecraft.core.Direction;
3840
import net.minecraft.core.NonNullList;
3941
import net.minecraft.nbt.CompoundTag;
@@ -95,6 +97,18 @@ public ItemAttachedIo(IoAttachmentItem item, CompoundTag configData) {
9597
}
9698
this.maxItemsInInventory = configData.getInt("maxItemsInInventory");
9799
this.maxItemsInInventory = Mth.clamp(this.maxItemsInInventory, 0, getMaxItemsExtractedMaximum());
100+
101+
this.stuffedItems.clear();
102+
var stuffedTag = configData.getList("stuffed", CompoundTag.TAG_COMPOUND);
103+
for (int i = 0; i < stuffedTag.size(); i++) {
104+
var compound = stuffedTag.getCompound(i);
105+
var variant = ItemVariant.fromNbt(compound);
106+
var amount = compound.getLong("#a");
107+
108+
if (!variant.isBlank() && amount > 0) {
109+
this.stuffedItems.put(variant, amount);
110+
}
111+
}
98112
}
99113

100114
@Override
@@ -128,6 +142,16 @@ public CompoundTag writeConfigTag(CompoundTag configData) {
128142
configData.remove("maxItemsInInventory");
129143
}
130144

145+
var stuffedTag = new ListTag();
146+
for (var entry : stuffedItems.entrySet()) {
147+
var compound = entry.getKey().toNbt();
148+
compound.putLong("#a", entry.getValue());
149+
stuffedTag.add(compound);
150+
}
151+
if (!stuffedTag.isEmpty()) {
152+
configData.put("stuffed", stuffedTag);
153+
}
154+
131155
return configData;
132156
}
133157

@@ -262,9 +286,9 @@ public void setMaxItemsExtracted(int value) {
262286

263287
public int getMaxItemsExtractedMaximum() {
264288
return switch (getTier()) {
265-
case BASIC -> 8;
266-
case IMPROVED -> 24;
267-
case ADVANCED -> 64;
289+
case IRON -> 8;
290+
case GOLD -> 24;
291+
case DIAMOND -> 64;
268292
};
269293
}
270294

@@ -284,4 +308,30 @@ private ItemCachedFilter getCachedFilter() {
284308
protected void resetCachedFilter() {
285309
this.cachedFilter = null;
286310
}
311+
312+
public long moveStuffedToStorage(Storage<ItemVariant> targetStorage, long maxAmount) {
313+
long totalMoved = 0;
314+
315+
try (var tx = Transaction.openOuter()) {
316+
for (var it = stuffedItems.entrySet().iterator(); it.hasNext() && totalMoved < maxAmount;) {
317+
var entry = it.next();
318+
long stuffedAmount = entry.getValue();
319+
long inserted = targetStorage.insert(entry.getKey(), Math.min(stuffedAmount, maxAmount - totalMoved), tx);
320+
321+
if (inserted > 0) {
322+
totalMoved -= inserted;
323+
324+
if (inserted < stuffedAmount) {
325+
entry.setValue(stuffedAmount - inserted);
326+
} else {
327+
it.remove();
328+
}
329+
}
330+
}
331+
332+
tx.commit();
333+
}
334+
335+
return totalMoved;
336+
}
287337
}

src/main/java/dev/technici4n/moderndynamics/data/DataGenerators.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,6 @@ public void onInitializeDataGenerator(FabricDataGenerator fabricDataGenerator) {
2828

2929
fabricDataGenerator.addProvider(ItemModelsProvider::new);
3030
fabricDataGenerator.addProvider(PipeModelsProvider::new);
31+
fabricDataGenerator.addProvider(RecipesProvider::new);
3132
}
3233
}

src/main/java/dev/technici4n/moderndynamics/data/PipeModelsProvider.java

Lines changed: 34 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,14 @@
2121
import com.google.gson.Gson;
2222
import com.google.gson.GsonBuilder;
2323
import com.google.gson.JsonObject;
24-
import dev.technici4n.moderndynamics.attachment.MdAttachments;
2524
import dev.technici4n.moderndynamics.attachment.RenderedAttachment;
2625
import dev.technici4n.moderndynamics.init.MdBlocks;
2726
import dev.technici4n.moderndynamics.pipe.PipeBlock;
2827
import dev.technici4n.moderndynamics.util.MdId;
2928
import java.io.IOException;
3029
import java.nio.file.Files;
3130
import java.nio.file.Path;
31+
import java.util.Locale;
3232
import net.fabricmc.fabric.api.datagen.v1.FabricDataGenerator;
3333
import net.minecraft.data.DataProvider;
3434
import net.minecraft.data.HashCache;
@@ -49,37 +49,35 @@ public void run(HashCache cache) throws IOException {
4949
}
5050

5151
private void registerPipeModels(HashCache cache) throws IOException {
52-
registerPipeModel(cache, MdBlocks.BASIC_ITEM_PIPE, "base/item/basic", "connector/tin", true);
53-
registerPipeModel(cache, MdBlocks.BASIC_ITEM_PIPE_OPAQUE, "base/item/basic_opaque", "connector/tin", false);
54-
registerPipeModel(cache, MdBlocks.FAST_ITEM_PIPE, "lead", "connection_lead");
55-
registerPipeModel(cache, MdBlocks.FAST_ITEM_PIPE_OPAQUE, "lead", "connection_lead");
56-
registerPipeModel(cache, MdBlocks.CONDUCTIVE_ITEM_PIPE, "lead", "connection_lead");
57-
registerPipeModel(cache, MdBlocks.CONDUCTIVE_ITEM_PIPE_OPAQUE, "lead", "connection_lead");
58-
registerPipeModel(cache, MdBlocks.CONDUCTIVE_FAST_ITEM_PIPE, "lead", "connection_lead");
59-
registerPipeModel(cache, MdBlocks.CONDUCTIVE_FAST_ITEM_PIPE_OPAQUE, "lead", "connection_lead");
60-
61-
registerPipeModel(cache, MdBlocks.BASIC_FLUID_PIPE, "base/fluid/basic", "connector/copper", true);
62-
registerPipeModel(cache, MdBlocks.BASIC_FLUID_PIPE_OPAQUE, "lead", "connection_lead");
63-
registerPipeModel(cache, MdBlocks.FAST_FLUID_PIPE, "lead", "connection_lead");
64-
registerPipeModel(cache, MdBlocks.FAST_FLUID_PIPE_OPAQUE, "lead", "connection_lead");
65-
registerPipeModel(cache, MdBlocks.CONDUCTIVE_FLUID_PIPE, "lead", "connection_lead");
66-
registerPipeModel(cache, MdBlocks.CONDUCTIVE_FLUID_PIPE_OPAQUE, "lead", "connection_lead");
67-
registerPipeModel(cache, MdBlocks.CONDUCTIVE_FAST_FLUID_PIPE, "lead", "connection_lead");
68-
registerPipeModel(cache, MdBlocks.CONDUCTIVE_FAST_FLUID_PIPE_OPAQUE, "lead", "connection_lead");
69-
70-
registerPipeModel(cache, MdBlocks.BASIC_ENERGY_PIPE, "base/energy/lead", "connector/lead");
71-
registerPipeModel(cache, MdBlocks.IMPROVED_ENERGY_PIPE, "base/energy/invar", "connector/invar");
72-
registerPipeModel(cache, MdBlocks.ADVANCED_ENERGY_PIPE, "base/energy/electrum", "connector/electrum");
73-
74-
registerPipeModel(cache, MdBlocks.EMPTY_REINFORCED_ENERGY_PIPE, "lead", "connection_lead");
75-
registerPipeModel(cache, MdBlocks.EMPTY_SIGNALUM_ENERGY_PIPE, "lead", "connection_lead");
76-
registerPipeModel(cache, MdBlocks.EMPTY_RESONANT_ENERGY_PIPE, "lead", "connection_lead");
77-
registerPipeModel(cache, MdBlocks.EMPTY_SUPERCONDUCTING_PIPE, "lead", "connection_lead");
78-
}
79-
80-
// TODO: remove
81-
private void registerPipeModel(HashCache cache, PipeBlock pipe, String texture, String connectionTexture) throws IOException {
82-
registerPipeModel(cache, pipe, texture, connectionTexture, false);
52+
registerPipeModel(cache, MdBlocks.ITEM_PIPE, "base/item/basic", "connector/iron", true);
53+
registerPipeModel(cache, MdBlocks.FLUID_PIPE, "base/fluid/basic", "connector/copper", true);
54+
55+
/*
56+
* registerPipeModel(cache, MdBlocks.BASIC_ITEM_PIPE_OPAQUE, "base/item/basic_opaque", "connector/tin", false);
57+
* registerPipeModel(cache, MdBlocks.FAST_ITEM_PIPE, "lead", "connection_lead");
58+
* registerPipeModel(cache, MdBlocks.FAST_ITEM_PIPE_OPAQUE, "lead", "connection_lead");
59+
* registerPipeModel(cache, MdBlocks.CONDUCTIVE_ITEM_PIPE, "lead", "connection_lead");
60+
* registerPipeModel(cache, MdBlocks.CONDUCTIVE_ITEM_PIPE_OPAQUE, "lead", "connection_lead");
61+
* registerPipeModel(cache, MdBlocks.CONDUCTIVE_FAST_ITEM_PIPE, "lead", "connection_lead");
62+
* registerPipeModel(cache, MdBlocks.CONDUCTIVE_FAST_ITEM_PIPE_OPAQUE, "lead", "connection_lead");
63+
*
64+
* registerPipeModel(cache, MdBlocks.BASIC_FLUID_PIPE_OPAQUE, "lead", "connection_lead");
65+
* registerPipeModel(cache, MdBlocks.FAST_FLUID_PIPE, "lead", "connection_lead");
66+
* registerPipeModel(cache, MdBlocks.FAST_FLUID_PIPE_OPAQUE, "lead", "connection_lead");
67+
* registerPipeModel(cache, MdBlocks.CONDUCTIVE_FLUID_PIPE, "lead", "connection_lead");
68+
* registerPipeModel(cache, MdBlocks.CONDUCTIVE_FLUID_PIPE_OPAQUE, "lead", "connection_lead");
69+
* registerPipeModel(cache, MdBlocks.CONDUCTIVE_FAST_FLUID_PIPE, "lead", "connection_lead");
70+
* registerPipeModel(cache, MdBlocks.CONDUCTIVE_FAST_FLUID_PIPE_OPAQUE, "lead", "connection_lead");
71+
*
72+
* registerPipeModel(cache, MdBlocks.BASIC_ENERGY_PIPE, "base/energy/lead", "connector/lead");
73+
* registerPipeModel(cache, MdBlocks.IMPROVED_ENERGY_PIPE, "base/energy/invar", "connector/invar");
74+
* registerPipeModel(cache, MdBlocks.ADVANCED_ENERGY_PIPE, "base/energy/electrum", "connector/electrum");
75+
*
76+
* registerPipeModel(cache, MdBlocks.EMPTY_REINFORCED_ENERGY_PIPE, "lead", "connection_lead");
77+
* registerPipeModel(cache, MdBlocks.EMPTY_SIGNALUM_ENERGY_PIPE, "lead", "connection_lead");
78+
* registerPipeModel(cache, MdBlocks.EMPTY_RESONANT_ENERGY_PIPE, "lead", "connection_lead");
79+
* registerPipeModel(cache, MdBlocks.EMPTY_SUPERCONDUCTING_PIPE, "lead", "connection_lead");
80+
*/
8381
}
8482

8583
private void registerPipeModel(HashCache cache, PipeBlock pipe, String texture, String connectionTexture, boolean transparent)
@@ -115,27 +113,10 @@ private String registerPipePart(HashCache cache, Path baseFolder, PipeBlock pipe
115113
}
116114

117115
private void registerAttachments(HashCache cache) throws IOException {
118-
registerAttachment(cache, MdAttachments.BASIC_FILTER, "attachment/filter_0");
119-
registerAttachment(cache, MdAttachments.IMPROVED_FILTER, "attachment/filter_1");
120-
registerAttachment(cache, MdAttachments.ADVANCED_FILTER, "attachment/filter_2");
121-
122-
registerAttachment(cache, MdAttachments.BASIC_SERVO, "attachment/servo_base_0_0");
123-
registerAttachment(cache, MdAttachments.IMPROVED_SERVO, "attachment/servo_base_0_1");
124-
registerAttachment(cache, MdAttachments.ADVANCED_SERVO, "attachment/servo_base_0_2");
125-
126-
registerAttachment(cache, MdAttachments.BASIC_RETRIEVER, "attachment/retriever_base_0_0");
127-
registerAttachment(cache, MdAttachments.IMPROVED_RETRIEVER, "attachment/retriever_base_0_1");
128-
registerAttachment(cache, MdAttachments.ADVANCED_RETRIEVER, "attachment/retriever_base_0_2");
129-
130-
registerAttachment(cache, MdAttachments.BASIC_SERVO_STUFFED, "attachment/servo_base_1_0");
131-
registerAttachment(cache, MdAttachments.IMPROVED_SERVO_STUFFED, "attachment/servo_base_1_1");
132-
registerAttachment(cache, MdAttachments.ADVANCED_SERVO_STUFFED, "attachment/servo_base_1_2");
133-
134-
registerAttachment(cache, MdAttachments.BASIC_RETRIEVER_STUFFED, "attachment/retriever_base_1_0");
135-
registerAttachment(cache, MdAttachments.IMPROVED_RETRIEVER_STUFFED, "attachment/retriever_base_1_1");
136-
registerAttachment(cache, MdAttachments.ADVANCED_RETRIEVER_STUFFED, "attachment/retriever_base_1_2");
137-
138-
registerAttachment(cache, MdAttachments.INHIBITOR, "attachment/inhibitor");
116+
// Register each model.
117+
for (var attachment : RenderedAttachment.getAllAttachments()) {
118+
registerAttachment(cache, attachment, "attachment/" + attachment.id.toLowerCase(Locale.ROOT));
119+
}
139120

140121
// Now register the base model json.
141122
var obj = new JsonObject();

0 commit comments

Comments
 (0)