mirror of
https://github.com/TicTicBoooom-Mods/MasterfulMachinery.git
synced 2026-03-18 21:40:34 +01:00
fixed server recipe and some inconsistencies
This commit is contained in:
@@ -18,7 +18,7 @@ apply plugin: 'net.minecraftforge.gradle'
|
||||
apply plugin: 'eclipse'
|
||||
apply plugin: 'maven-publish'
|
||||
|
||||
version = '1.16.5-0.0.12'
|
||||
version = '1.16.5-0.1.2-T' + System.currentTimeMillis()
|
||||
group = 'com.yourname.modid' // http://maven.apache.org/guides/mini/guide-naming-conventions.html
|
||||
archivesBaseName = 'MasterfulMachinery'
|
||||
|
||||
@@ -146,7 +146,6 @@ dependencies {
|
||||
runtimeOnly fg.deobf("mekanism:Mekanism:${mekanism_version}:generators")// Mekanism: Generators
|
||||
runtimeOnly fg.deobf("mekanism:Mekanism:${mekanism_version}:tools")// Mekanism: Tools
|
||||
|
||||
|
||||
compileOnly fg.deobf("mezz.jei:jei-${mc_version}:${jei_version}:api")
|
||||
// at runtime, use the full JEI jar
|
||||
runtimeOnly fg.deobf("mezz.jei:jei-${mc_version}:${jei_version}")
|
||||
|
||||
@@ -31,6 +31,7 @@ import net.minecraftforge.common.data.ExistingFileHelper;
|
||||
import net.minecraftforge.eventbus.api.IEventBus;
|
||||
import net.minecraftforge.fml.RegistryObject;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.common.thread.EffectiveSide;
|
||||
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
|
||||
import net.minecraftforge.fml.event.server.FMLServerAboutToStartEvent;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
@@ -74,9 +75,11 @@ public class MM {
|
||||
generator = MemoryDataGeneratorFactory.createMemoryDataGenerator();
|
||||
ExistingFileHelper existingFileHelper = new ExistingFileHelper(ImmutableList.of(), ImmutableSet.of(), false);
|
||||
|
||||
generator.addProvider(new MMBlockStateProvider(generator, existingFileHelper));
|
||||
generator.addProvider(new MMItemModelProvider(generator, existingFileHelper));
|
||||
generator.addProvider(new MMLangProvider(generator));
|
||||
if (FMLEnvironment.dist != Dist.DEDICATED_SERVER){
|
||||
generator.addProvider(new MMBlockStateProvider(generator, existingFileHelper));
|
||||
generator.addProvider(new MMItemModelProvider(generator, existingFileHelper));
|
||||
generator.addProvider(new MMLangProvider(generator));
|
||||
}
|
||||
}
|
||||
|
||||
public static void generate() {
|
||||
|
||||
@@ -46,6 +46,7 @@ public class ControllerBlockEntity extends UpdatableTile implements ITickableTil
|
||||
|
||||
@Override
|
||||
public void tick() {
|
||||
update.setMsg("Failed to construct \nthe machine");
|
||||
List<MachineStructureRecipe> recipes = level.getRecipeManager().getAllRecipesFor(RecipeTypes.MACHINE_STRUCTURE);
|
||||
for (MachineStructureRecipe recipe : recipes) {
|
||||
int index = recipe.matches(this.worldPosition, level, controllerId);
|
||||
@@ -55,8 +56,7 @@ public class ControllerBlockEntity extends UpdatableTile implements ITickableTil
|
||||
return;
|
||||
}
|
||||
}
|
||||
update.setMsg("Failed to construct \nthe machine");
|
||||
}
|
||||
}
|
||||
|
||||
private void onStructureFound(MachineStructureRecipe structure, int index) {
|
||||
ArrayList<BlockPos> ports = structure.getPorts(worldPosition, level, index);
|
||||
|
||||
@@ -8,12 +8,9 @@ import mezz.jei.api.JeiPlugin;
|
||||
import mezz.jei.api.registration.IRecipeCategoryRegistration;
|
||||
import mezz.jei.api.registration.IRecipeRegistration;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.item.crafting.IRecipeType;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@JeiPlugin
|
||||
public class MMJeiPlugin implements IModPlugin {
|
||||
|
||||
@@ -150,7 +150,7 @@ public class MachineProcessRecipe implements IRecipe<IInventory> {
|
||||
|
||||
@Override
|
||||
public IRecipeSerializer<?> getSerializer() {
|
||||
return new Serializer();
|
||||
return RecipeTypes.PROCESS.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -217,6 +217,7 @@ public class MachineProcessRecipe implements IRecipe<IInventory> {
|
||||
boolean perTick = buf.readBoolean();
|
||||
MasterfulPortType value = MMPorts.PORTS.get(RLUtils.toRL(inpType));
|
||||
PortState state = value.getParser().createState(buf);
|
||||
state.setConsumePerTick(perTick);
|
||||
result.add(state);
|
||||
}
|
||||
return result;
|
||||
|
||||
@@ -10,9 +10,11 @@ import com.mojang.serialization.JsonOps;
|
||||
import com.ticticboooom.mods.mm.MM;
|
||||
import com.ticticboooom.mods.mm.block.MachinePortBlock;
|
||||
import com.ticticboooom.mods.mm.data.model.structure.MachineStructureBlockPos;
|
||||
import com.ticticboooom.mods.mm.data.model.structure.MachineStructureObject;
|
||||
import com.ticticboooom.mods.mm.data.model.structure.MachineStructureRecipeKeyModel;
|
||||
import com.ticticboooom.mods.mm.registration.RecipeTypes;
|
||||
import lombok.Getter;
|
||||
import lombok.SneakyThrows;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
@@ -38,14 +40,15 @@ import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class MachineStructureRecipe implements IRecipe<IInventory> {
|
||||
private final ResourceLocation rl = new ResourceLocation(MM.ID, "machine_structure");
|
||||
private final ResourceLocation rl;
|
||||
@Getter
|
||||
private List<List<MachineStructureRecipeKeyModel>> models;
|
||||
@Getter
|
||||
private final List<String> controllerId;
|
||||
private String id;
|
||||
|
||||
public MachineStructureRecipe(List<MachineStructureRecipeKeyModel> models, List<String> controllerId, String id) {
|
||||
public MachineStructureRecipe(List<MachineStructureRecipeKeyModel> models, List<String> controllerId, String id, ResourceLocation rl) {
|
||||
this.rl = rl;
|
||||
List<MachineStructureRecipeKeyModel> rotated = new ArrayList<>();
|
||||
List<MachineStructureRecipeKeyModel> rotated1 = new ArrayList<>();
|
||||
List<MachineStructureRecipeKeyModel> rotated2 = new ArrayList<>();
|
||||
@@ -175,12 +178,12 @@ public class MachineStructureRecipe implements IRecipe<IInventory> {
|
||||
|
||||
@Override
|
||||
public ResourceLocation getId() {
|
||||
return new ResourceLocation(MM.ID, "machine_structure");
|
||||
return rl;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IRecipeSerializer<?> getSerializer() {
|
||||
return new Serializer();
|
||||
return RecipeTypes.STRUCTURE.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -205,30 +208,39 @@ public class MachineStructureRecipe implements IRecipe<IInventory> {
|
||||
String id = obj.get("id").getAsString();
|
||||
DataResult<Pair<List<MachineStructureRecipeKeyModel>, JsonElement>> apply = JsonOps.INSTANCE.withDecoder(Codec.list(MachineStructureRecipeKeyModel.CODEC)).apply(obj.getAsJsonArray("blocks"));
|
||||
List<MachineStructureRecipeKeyModel> first = apply.result().get().getFirst();
|
||||
return new MachineStructureRecipe(first, ids, id);
|
||||
return new MachineStructureRecipe(first, ids, id, rl);
|
||||
}
|
||||
|
||||
@SneakyThrows
|
||||
@Nullable
|
||||
@Override
|
||||
public MachineStructureRecipe fromNetwork(ResourceLocation rl, PacketBuffer buf) {
|
||||
List<String> controllerId = Arrays.asList(buf.readUtf().split(","));
|
||||
List<String> controllerId = new ArrayList<>();
|
||||
int idCount = buf.readInt();
|
||||
for (int i = 0; i < idCount; i++) {
|
||||
controllerId.add(buf.readUtf());
|
||||
}
|
||||
String id = buf.readUtf();
|
||||
List<MachineStructureRecipeKeyModel> models = null;
|
||||
try {
|
||||
models = buf.readWithCodec(Codec.list(MachineStructureRecipeKeyModel.CODEC));
|
||||
} catch (IOException e) {
|
||||
MachineStructureObject machineStructureObject = buf.readWithCodec(MachineStructureObject.CODEC);
|
||||
List<MachineStructureRecipeKeyModel> models = machineStructureObject.getInner();
|
||||
return new MachineStructureRecipe(models, controllerId, id, rl);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return new MachineStructureRecipe(models, controllerId, id);
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toNetwork(PacketBuffer buf, MachineStructureRecipe recipe) {
|
||||
buf.writeUtf(String.join(",", recipe.controllerId));
|
||||
buf.writeInt(recipe.controllerId.size());
|
||||
for (String s : recipe.controllerId) {
|
||||
buf.writeUtf(s);
|
||||
}
|
||||
buf.writeUtf(recipe.id);
|
||||
try {
|
||||
buf.writeWithCodec(Codec.list(MachineStructureRecipeKeyModel.CODEC), recipe.models.get(0));
|
||||
} catch (IOException e) {
|
||||
buf.writeWithCodec(MachineStructureObject.CODEC, new MachineStructureObject(recipe.getModels().get(0)));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.ticticboooom.mods.mm.data.model.structure;
|
||||
|
||||
import com.mojang.serialization.Codec;
|
||||
import com.mojang.serialization.codecs.RecordCodecBuilder;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public class MachineStructureObject {
|
||||
public static final Codec<MachineStructureObject> CODEC = RecordCodecBuilder.create(x -> x.group(
|
||||
Codec.list(MachineStructureRecipeKeyModel.CODEC).fieldOf("object").forGetter(z -> z.inner)
|
||||
).apply(x, MachineStructureObject::new));
|
||||
|
||||
private final List<MachineStructureRecipeKeyModel> inner;
|
||||
}
|
||||
@@ -14,7 +14,7 @@ public class MachineStructureRecipeKeyModel {
|
||||
MachineStructureBlockPos.CODEC.fieldOf("pos").forGetter(z -> z.pos),
|
||||
Codec.STRING.optionalFieldOf("tag").forGetter(z -> Optional.of(z.tag)),
|
||||
Codec.STRING.optionalFieldOf("block").forGetter(z -> Optional.of(z.block)),
|
||||
Codec.STRING.optionalFieldOf("tag").forGetter(z -> Optional.of(z.nbt))
|
||||
Codec.STRING.optionalFieldOf("nbt").forGetter(z -> Optional.of(z.nbt))
|
||||
).apply(x, (w0, w, y, z) -> new MachineStructureRecipeKeyModel(w0, w.orElse(""), y.orElse(""), z.orElse(""))));
|
||||
private MachineStructureBlockPos pos;
|
||||
private final String tag;
|
||||
|
||||
@@ -47,7 +47,7 @@ public class MMPackFinder implements IPackFinder {
|
||||
Path rootPath = MemoryDataGeneratorFactory.ROOT_PATH;
|
||||
|
||||
ResourcePackInfo pack = ResourcePackInfo.create("mm_" + type.getSuffix(), true,
|
||||
() -> new InMemoryPack(rootPath), infoFactory, ResourcePackInfo.Priority.BOTTOM, IPackNameDecorator.DEFAULT);
|
||||
() -> new InMemoryPack(rootPath), infoFactory, ResourcePackInfo.Priority.TOP, IPackNameDecorator.DEFAULT);
|
||||
if (pack != null) {
|
||||
infoConsumer.accept(pack);
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ public class MekSlurryPortParser implements IPortParser {
|
||||
@SneakyThrows
|
||||
@Override
|
||||
public PortState createState(PacketBuffer buf) {
|
||||
return buf.readWithCodec(MekGasPortState.CODEC);
|
||||
return buf.readWithCodec(MekSlurryPortState.CODEC);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -60,7 +60,9 @@ public class MekSlurryPortStorage implements IPortStorage {
|
||||
|
||||
@Override
|
||||
public void load(CompoundNBT nbt) {
|
||||
inv.setStack(new SlurryStack(Objects.requireNonNull(MekanismAPI.slurryRegistry().getValue(RLUtils.toRL(nbt.getString("slurry")))), nbt.getLong("amount")));
|
||||
if (nbt.contains("slurry")){
|
||||
inv.setStack(new SlurryStack(Objects.requireNonNull(MekanismAPI.slurryRegistry().getValue(RLUtils.toRL(nbt.getString("slurry")))), nbt.getLong("amount")));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -41,7 +41,7 @@ public class MMLoader {
|
||||
public static final ItemGroup MASTERFUL_ITEM_GROUP = new ItemGroup(MM.ID) {
|
||||
@Override
|
||||
public ItemStack makeIcon() {
|
||||
return new ItemStack(Items.PAPER);
|
||||
return new ItemStack(MMSetup.BLUEPRINT.get());
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -12,8 +12,8 @@ import net.minecraftforge.registries.ForgeRegistries;
|
||||
|
||||
public class RecipeTypes {
|
||||
public static final DeferredRegister<IRecipeSerializer<?>> RECIPE_SERIALIZERS = DeferredRegister.create(ForgeRegistries.RECIPE_SERIALIZERS, MM.ID);
|
||||
public static final IRecipeType<MachineStructureRecipe> MACHINE_STRUCTURE = IRecipeType.register(new ResourceLocation(MM.ID, "machine_structure").toString());
|
||||
public static final IRecipeType<MachineProcessRecipe> MACHINE_PROCESS = IRecipeType.register(new ResourceLocation(MM.ID, "machine_process").toString());
|
||||
public static final IRecipeType<MachineStructureRecipe> MACHINE_STRUCTURE = IRecipeType.register("machine_structure");
|
||||
public static final IRecipeType<MachineProcessRecipe> MACHINE_PROCESS = IRecipeType.register("machine_process");
|
||||
|
||||
public static final RegistryObject<MachineStructureRecipe.Serializer> STRUCTURE = RECIPE_SERIALIZERS.register("machine_structure", MachineStructureRecipe.Serializer::new);
|
||||
public static final RegistryObject<MachineProcessRecipe.Serializer> PROCESS = RECIPE_SERIALIZERS.register("machine_process", MachineProcessRecipe.Serializer::new);
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
{
|
||||
"type": "masterfulmachinery:machine_process",
|
||||
"structureId": "mastermachine_structure",
|
||||
"controllerId": "mastermachine",
|
||||
"ticks": 100,
|
||||
"inputs": [
|
||||
{
|
||||
"type": "masterfulmachinery:items",
|
||||
"data": {
|
||||
"item": "minecraft:wool",
|
||||
"count": 2
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "masterfulmachinery:energy",
|
||||
"data": {
|
||||
"amount": 69420
|
||||
}
|
||||
}
|
||||
],
|
||||
"outputs": [
|
||||
{
|
||||
"type": "masterfulmachinery:items",
|
||||
"data": {
|
||||
"item": "minecraft:nether_star",
|
||||
"count": 1
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "masterfulmachinery:mekanism_slurry",
|
||||
"data": {
|
||||
"slurry": "mekanism:clean_gold",
|
||||
"amount": 42069
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
{
|
||||
"type": "masterfulmachinery:machine_structure",
|
||||
"controllerId": "mastermachine",
|
||||
"id": "mastermachine_structure",
|
||||
"blocks": [
|
||||
{
|
||||
"pos":{
|
||||
"x": -1,
|
||||
"y": 0,
|
||||
"z": 0
|
||||
},
|
||||
"block": "masterfulmachinery:mastermachine_masteritem_port_items_input"
|
||||
},
|
||||
{
|
||||
"pos":{
|
||||
"x": -1,
|
||||
"y": 1,
|
||||
"z": 0
|
||||
},
|
||||
"block": "masterfulmachinery:mastermachine_masteritem_port_items_output"
|
||||
},
|
||||
{
|
||||
"pos":{
|
||||
"x": -1,
|
||||
"y": 2,
|
||||
"z": 0
|
||||
},
|
||||
"block": "masterfulmachinery:mastermachine_battery_port_energy_input"
|
||||
},
|
||||
{
|
||||
"pos":{
|
||||
"x": 0,
|
||||
"y": 1,
|
||||
"z": 0
|
||||
},
|
||||
"block": "minecraft:cobblestone"
|
||||
},
|
||||
{
|
||||
"pos":{
|
||||
"x": 0,
|
||||
"y": 4,
|
||||
"z": 0
|
||||
},
|
||||
"block": "minecraft:cobblestone"
|
||||
},
|
||||
{
|
||||
"pos":{
|
||||
"x": 0,
|
||||
"y": 7,
|
||||
"z": 0
|
||||
},
|
||||
"block": "minecraft:cobblestone"
|
||||
},
|
||||
{
|
||||
"pos":{
|
||||
"x": 0,
|
||||
"y": 10,
|
||||
"z": 0
|
||||
},
|
||||
"block": "minecraft:cobblestone"
|
||||
},
|
||||
{
|
||||
"pos":{
|
||||
"x": 1,
|
||||
"y": 0,
|
||||
"z": 0
|
||||
},
|
||||
"block": "masterfulmachinery:mastermachine_mekslurry_port_mekanism_slurry_input"
|
||||
},
|
||||
{
|
||||
"pos":{
|
||||
"x": 1,
|
||||
"y": 1,
|
||||
"z": 0
|
||||
},
|
||||
"block": "masterfulmachinery:mastermachine_mekslurry_port_mekanism_slurry_output"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"type": "masterfulmachinery:machine_structure",
|
||||
"controllerId": "mastermachine",
|
||||
"id": "mastermachine2_structure",
|
||||
"blocks": [
|
||||
{
|
||||
"pos":{
|
||||
"x": 0,
|
||||
"y": -1,
|
||||
"z": 0
|
||||
},
|
||||
"block": "minecraft:cobblestone"
|
||||
},
|
||||
{
|
||||
"pos":{
|
||||
"x": 0,
|
||||
"y": -2,
|
||||
"z": 0
|
||||
},
|
||||
"block": "minecraft:cobblestone"
|
||||
}
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user