added loot tables, io textures for compat ports, consume instantly flag

This commit is contained in:
ticticboooom
2021-05-29 16:08:40 +01:00
parent d28de7f319
commit aa0c3a963d
65 changed files with 531 additions and 52 deletions

View File

@@ -7,7 +7,7 @@ buildscript {
}
dependencies {
classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '4.1.+', changing: true
classpath 'org.spongepowered:mixingradle:0.7-SNAPSHOT'
}
}
@@ -19,9 +19,10 @@ apply plugin: 'net.minecraftforge.gradle'
// Only edit below this line, the above code adds and enables the necessary things for Forge to be setup.
apply plugin: 'eclipse'
apply plugin: 'maven-publish'
apply plugin: 'org.spongepowered.mixin'
version = '1.16.5-0.1.43-B' + getVersionNumber()
group = 'com.yourname.modid' // http://maven.apache.org/guides/mini/guide-naming-conventions.html
version = '1.16.5-0.1.47-B' + getVersionNumber()
group = 'com.ticticboooom.mods.mm' // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = 'MasterfulMachinery'
java.toolchain.languageVersion = JavaLanguageVersion.of(8) // Mojang ships Java 8 to end users, so your mod should target Java 8.
@@ -45,7 +46,7 @@ minecraft {
// Simply re-run your setup task after changing the mappings to update your workspace.
mappings channel: 'snapshot', version: '20210309-1.16.5'
// makeObfSourceJar = false // an Srg named sources jar is made by default. uncomment this to disable.
// accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg')
// Default run configurations.
@@ -53,6 +54,7 @@ minecraft {
runs {
client {
workingDirectory project.file('run')
arg '-mixin.config=masterfulmachinery.mixins.json'
// Recommended logging data for a userdev environment
// The markers can be changed as needed.
@@ -76,7 +78,7 @@ minecraft {
server {
workingDirectory project.file('run')
arg '-mixin.config=masterfulmachinery.mixins.json'
// Recommended logging data for a userdev environment
// The markers can be changed as needed.
// "SCAN": For mods scan.
@@ -174,6 +176,9 @@ dependencies {
annotationProcessor 'org.projectlombok:lombok:1.18.18'
minecraft 'net.minecraftforge:forge:1.16.5-36.1.23'
compileOnly 'com.google.code.gson:gson:2.8.7'
implementation 'org.spongepowered:mixin:0.8-SNAPSHOT'
annotationProcessor 'org.spongepowered:mixin:0.8.2:processor'
shade 'com.github.marschall:memoryfilesystem:2.1.0'
implementation fg.deobf("mekanism:Mekanism:${mekanism_version}")// core
@@ -225,13 +230,14 @@ dependencies {
jar {
manifest {
attributes([
"Specification-Title": "examplemod",
"Specification-Vendor": "examplemodsareus",
"Specification-Version": "1", // We are version 1 of ourselves
"Implementation-Title": project.name,
"Implementation-Version": "${version}",
"Implementation-Vendor" :"examplemodsareus",
"Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")
"MixinConfigs" : "masterfulmachinery.mixins.json",
"Specification-Title" : "masterfulmachinery",
"Specification-Vendor" : "ticticboooom",
"Specification-Version" : "1", // We are version 1 of ourselves
"Implementation-Title" : project.name,
"Implementation-Version" : "${version}",
"Implementation-Vendor" : "TicTicBoooom",
"Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")
])
}
}
@@ -265,7 +271,7 @@ reobf {
def getVersionNumber() {
def vFile = file('version.properties')
def Integer buildNumber = 0
if (vFile.canRead()){
if (vFile.canRead()) {
def Properties versionProps = new Properties();
versionProps.load(new FileInputStream(vFile))
@@ -277,4 +283,20 @@ def getVersionNumber() {
versionProps.store(vFile.newWriter(), null)
}
return buildNumber.toString()
}
mixin {
add sourceSets.main, "masterfulmachinery.refmap.json"
}
artifacts {
archives shadowJar
shadow shadowJar
}
reobf {
shadowJar {
dependsOn createMcpToSrg
mappings = createMcpToSrg.outputs.files.singleFile
}
}

View File

@@ -18,6 +18,7 @@ import com.ticticboooom.mods.mm.datagen.PackType;
import com.ticticboooom.mods.mm.datagen.gen.MMBlockStateProvider;
import com.ticticboooom.mods.mm.datagen.gen.MMItemModelProvider;
import com.ticticboooom.mods.mm.datagen.gen.MMLangProvider;
import com.ticticboooom.mods.mm.datagen.gen.MMLootTableProvider;
import com.ticticboooom.mods.mm.network.PacketHandler;
import com.ticticboooom.mods.mm.registration.MMLoader;
import com.ticticboooom.mods.mm.registration.MMPorts;
@@ -30,10 +31,12 @@ import net.minecraft.client.renderer.RenderTypeLookup;
import net.minecraft.client.renderer.tileentity.TileEntityRenderer;
import net.minecraft.data.DataGenerator;
import net.minecraft.inventory.container.ContainerType;
import net.minecraft.resources.ResourcePackList;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.common.data.ExistingFileHelper;
import net.minecraftforge.eventbus.api.IEventBus;
import net.minecraftforge.fml.DistExecutor;
import net.minecraftforge.fml.RegistryObject;
import net.minecraftforge.fml.client.registry.ClientRegistry;
import net.minecraftforge.fml.common.Mod;
@@ -80,6 +83,7 @@ public class MM {
private void registerDataGen() {
generator = MemoryDataGeneratorFactory.createMemoryDataGenerator();
ExistingFileHelper existingFileHelper = new ExistingFileHelper(ImmutableList.of(), ImmutableSet.of(), false);
generator.addProvider(new MMLootTableProvider(generator));
if (FMLEnvironment.dist != Dist.DEDICATED_SERVER){
generator.addProvider(new MMBlockStateProvider(generator, existingFileHelper));
@@ -130,4 +134,11 @@ public class MM {
ScreenManager.registerFactory(MMSetup.STRUCTURE_CONTAINER.get(), StructureGenBlockContainerScreen::new);
ClientRegistry.bindTileEntityRenderer(MMSetup.STRUCTURE_TILE.get(), StructureGenTileEntityRenderer::new);
}
public static void injectDatapackFinder (ResourcePackList resourcePacks) {
if (DistExecutor.unsafeRunForDist( () -> () -> resourcePacks != Minecraft.getInstance().getResourcePackList(), () -> () -> true)) {
resourcePacks.addPackFinder(new MMPackFinder(PackType.RESOURCE));
MM.LOG.info("Injecting data pack finder.");
}
}
}

View File

@@ -41,8 +41,7 @@ public class ControllerBlock extends DirectionalBlock {
private String texOverride;
public ControllerBlock(RegistryObject<TileEntityType<?>> type, String name, String id, String texOverride) {
super(AbstractBlock.Properties.create(Material.IRON)
.harvestLevel(1)
super(AbstractBlock.Properties.create(Material.IRON).setRequiresTool().hardnessAndResistance(5.0F, 6.0F).sound(SoundType.METAL).harvestLevel(0)
.harvestTool(ToolType.PICKAXE));
this.type = type;
this.controllerName = name;

View File

@@ -7,6 +7,7 @@ import lombok.Getter;
import net.minecraft.block.AbstractBlock;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.ServerPlayerEntity;
@@ -20,6 +21,7 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.world.IBlockReader;
import net.minecraft.world.World;
import net.minecraftforge.common.ToolType;
import net.minecraftforge.common.util.LazyOptional;
import net.minecraftforge.fml.RegistryObject;
import net.minecraftforge.fml.network.NetworkHooks;
@@ -39,7 +41,8 @@ public class MachinePortBlock extends Block {
private ResourceLocation overlay;
public MachinePortBlock(RegistryObject<TileEntityType<?>> type, String name, String controllerId, String textureOverride, ResourceLocation overlay) {
super(AbstractBlock.Properties.create(Material.IRON));
super(AbstractBlock.Properties.create(Material.IRON).setRequiresTool().hardnessAndResistance(5.0F, 6.0F).sound(SoundType.METAL).harvestLevel(0)
.harvestTool(ToolType.PICKAXE));
this.type = type;
this.langName = name;
this.controllerId = controllerId;

View File

@@ -1,9 +1,7 @@
package com.ticticboooom.mods.mm.block;
import com.ticticboooom.mods.mm.registration.MMSetup;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.HorizontalBlock;
import net.minecraft.block.*;
import net.minecraft.block.material.Material;
import net.minecraft.item.BlockItemUseContext;
import net.minecraft.state.DirectionProperty;
@@ -16,13 +14,15 @@ import net.minecraft.util.math.shapes.ISelectionContext;
import net.minecraft.util.math.shapes.VoxelShape;
import net.minecraft.util.math.shapes.VoxelShapes;
import net.minecraft.world.IBlockReader;
import net.minecraftforge.common.ToolType;
import javax.annotation.Nullable;
import java.util.stream.Stream;
public class ProjectorBlock extends Block {
public ProjectorBlock() {
super(Properties.create(Material.IRON));
super(AbstractBlock.Properties.create(Material.IRON).setRequiresTool().hardnessAndResistance(5.0F, 6.0F).sound(SoundType.METAL).harvestLevel(0)
.harvestTool(ToolType.PICKAXE));
this.setDefaultState(this.getDefaultState().with(FACING, Direction.NORTH));
}

View File

@@ -3,9 +3,7 @@ package com.ticticboooom.mods.mm.block;
import com.ticticboooom.mods.mm.block.tile.ControllerBlockEntity;
import com.ticticboooom.mods.mm.block.tile.StructureGenBlockEntity;
import com.ticticboooom.mods.mm.registration.MMSetup;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.HorizontalBlock;
import net.minecraft.block.*;
import net.minecraft.block.material.Material;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.ServerPlayerEntity;
@@ -24,6 +22,7 @@ import net.minecraft.util.math.shapes.VoxelShape;
import net.minecraft.util.math.shapes.VoxelShapes;
import net.minecraft.world.IBlockReader;
import net.minecraft.world.World;
import net.minecraftforge.common.ToolType;
import net.minecraftforge.fml.network.NetworkHooks;
import javax.annotation.Nullable;
@@ -31,7 +30,8 @@ import java.util.stream.Stream;
public class StructureGenBlock extends Block {
public StructureGenBlock() {
super(Properties.create(Material.IRON));
super(AbstractBlock.Properties.create(Material.IRON).setRequiresTool().hardnessAndResistance(5.0F, 6.0F).sound(SoundType.METAL).harvestLevel(0)
.harvestTool(ToolType.PICKAXE));
this.setDefaultState(this.getDefaultState().with(FACING, Direction.NORTH));
}

View File

@@ -33,7 +33,7 @@ public class ControllerBlockEntity extends UpdatableTile implements ITickableTil
private RegistryObject<ContainerType<ControllerBlockContainer>> container;
private String controllerId;
@Getter
private ProcessUpdate update = new ProcessUpdate(0, "", "", "");
private ProcessUpdate update = new ProcessUpdate(0, "", "", "", new ArrayList<>());
public ControllerBlockEntity(RegistryObject<TileEntityType<?>> type, RegistryObject<ContainerType<ControllerBlockContainer>> container, String controllerId) {
super(type.get());
@@ -87,7 +87,7 @@ public class ControllerBlockEntity extends UpdatableTile implements ITickableTil
List<MachineProcessRecipe> processRecipes = world.getRecipeManager().getRecipesForType(RecipeTypes.MACHINE_PROCESS);
boolean processed = false;
for (MachineProcessRecipe recipe : processRecipes) {
if (recipe.matches(inputPorts, structure.getStructureId())) {
if (recipe.matches(inputPorts, structure.getStructureId(), update)) {
if (!update.getId().equals(recipe.getId().toString())){
update.setTicksTaken(0);
}

View File

@@ -36,6 +36,10 @@ public class MMJeiPlugin implements IModPlugin {
public static final ManaIngredientRenderer MANA_TYPE_RENDERER = new ManaIngredientRenderer();
public static final ManaIngredientHelper MANA_TYPE_HELPER = new ManaIngredientHelper();
public static final StarlightIngredientType STAR_TYPE = new StarlightIngredientType();
public static final StarlightIngredientRenderer STAR_TYPE_RENDERER = new StarlightIngredientRenderer();
public static final StarlightIngredientHelper STAR_TYPE_HELPER = new StarlightIngredientHelper();
@Override
public ResourceLocation getPluginUid() {
return new ResourceLocation(MM.ID, "jei_main");
@@ -46,11 +50,15 @@ public class MMJeiPlugin implements IModPlugin {
registration.register(MMJeiPlugin.ENERGY_TYPE, ImmutableList.of(), ENERGY_TYPE_HELPER, ENERGY_TYPE_RENDERER);
registration.register(MMJeiPlugin.PRESSURE_TYPE, ImmutableList.of(), PRESSURE_TYPE_HELPER, PRESSURE_TYPE_RENDERER);
registration.register(MMJeiPlugin.MANA_TYPE, ImmutableList.of(), MANA_TYPE_HELPER, MANA_TYPE_RENDERER);
registration.register(MMJeiPlugin.STAR_TYPE, ImmutableList.of(), STAR_TYPE_HELPER, STAR_TYPE_RENDERER);
}
@Override
public void registerRecipes(IRecipeRegistration registration) {
ENERGY_TYPE_RENDERER.setHelpers(registration.getJeiHelpers());
PRESSURE_TYPE_RENDERER.setHelpers(registration.getJeiHelpers());
MANA_TYPE_RENDERER.setHelpers(registration.getJeiHelpers());
STAR_TYPE_RENDERER.setHelpers(registration.getJeiHelpers());
List<MachineStructureRecipe> structureRecipes = Minecraft.getInstance().world.getRecipeManager().getRecipesForType(RecipeTypes.MACHINE_STRUCTURE);
for (RegistryObject<ControllerBlock> block : MMLoader.BLOCKS) {
registration.addRecipes(structureRecipes.stream().filter(x -> x.getControllerId().contains(block.get().getControllerId())).collect(Collectors.toList()), new ResourceLocation(MM.ID, "machine_structure_" + block.get().getControllerId()));

View File

@@ -2,10 +2,15 @@ package com.ticticboooom.mods.mm.client.jei.ingredients;
import com.google.common.collect.Lists;
import com.mojang.blaze3d.matrix.MatrixStack;
import com.ticticboooom.mods.mm.MM;
import com.ticticboooom.mods.mm.client.jei.ingredients.model.PressureStack;
import com.ticticboooom.mods.mm.inventory.botania.PortManaInventory;
import lombok.Setter;
import mezz.jei.api.gui.drawable.IDrawableStatic;
import mezz.jei.api.helpers.IJeiHelpers;
import mezz.jei.api.ingredients.IIngredientRenderer;
import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.StringTextComponent;
@@ -13,9 +18,15 @@ import javax.annotation.Nullable;
import java.util.List;
public class ManaIngredientRenderer implements IIngredientRenderer<PortManaInventory> {
@Setter
private IJeiHelpers helpers;
@Override
public void render(MatrixStack matrixStack, int xPosition, int yPosition, @Nullable PortManaInventory ingredient) {
if (ingredient != null) {
IDrawableStatic drawable = helpers.getGuiHelper().createDrawable(new ResourceLocation(MM.ID, "textures/gui/slot_parts.png"), 19, 80, 16, 16);
drawable.draw(matrixStack, xPosition, yPosition);
}
}
@Override

View File

@@ -2,10 +2,15 @@ package com.ticticboooom.mods.mm.client.jei.ingredients;
import com.google.common.collect.Lists;
import com.mojang.blaze3d.matrix.MatrixStack;
import com.ticticboooom.mods.mm.MM;
import com.ticticboooom.mods.mm.client.jei.ingredients.model.PressureStack;
import lombok.Setter;
import mezz.jei.api.gui.drawable.IDrawableStatic;
import mezz.jei.api.helpers.IJeiHelpers;
import mezz.jei.api.ingredients.IIngredientRenderer;
import mezz.jei.api.ingredients.IIngredientType;
import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.StringTextComponent;
@@ -13,16 +18,22 @@ import javax.annotation.Nullable;
import java.util.List;
public class PNCPressureIngredientRenderer implements IIngredientRenderer<PressureStack> {
@Setter
private IJeiHelpers helpers;
@Override
public void render(MatrixStack matrixStack, int xPosition, int yPosition, @Nullable PressureStack ingredient) {
if (ingredient != null) {
IDrawableStatic drawable = helpers.getGuiHelper().createDrawable(new ResourceLocation(MM.ID, "textures/gui/slot_parts.png"), 1, 62, 16, 16);
drawable.draw(matrixStack, xPosition, yPosition);
}
}
@Override
public List<ITextComponent> getTooltip(PressureStack ingredient, ITooltipFlag tooltipFlag) {
return Lists.newArrayList(
new StringTextComponent("PNC Pressure"),
new StringTextComponent(ingredient.getAmount() + "Units")
new StringTextComponent(ingredient.getAmount() + " Units")
);
}
}

View File

@@ -0,0 +1,46 @@
package com.ticticboooom.mods.mm.client.jei.ingredients;
import com.ticticboooom.mods.mm.client.jei.ingredients.model.PressureStack;
import com.ticticboooom.mods.mm.client.jei.ingredients.model.StarlightStack;
import mezz.jei.api.ingredients.IIngredientHelper;
import javax.annotation.Nullable;
public class StarlightIngredientHelper implements IIngredientHelper<StarlightStack> {
@Nullable
@Override
public StarlightStack getMatch(Iterable<StarlightStack> ingredients, StarlightStack ingredientToMatch) {
return ingredientToMatch;
}
@Override
public String getDisplayName(StarlightStack ingredient) {
return "Starlight";
}
@Override
public String getUniqueId(StarlightStack ingredient) {
return ingredient.getAmount() + "";
}
@Override
public String getModId(StarlightStack ingredient) {
return "astralsorcery";
}
@Override
public String getResourceId(StarlightStack ingredient) {
return "starlight";
}
@Override
public StarlightStack copyIngredient(StarlightStack ingredient) {
return new StarlightStack(ingredient.getAmount());
}
@Override
public String getErrorInfo(@Nullable StarlightStack ingredient) {
return "Error";
}
}

View File

@@ -0,0 +1,39 @@
package com.ticticboooom.mods.mm.client.jei.ingredients;
import com.google.common.collect.Lists;
import com.mojang.blaze3d.matrix.MatrixStack;
import com.ticticboooom.mods.mm.MM;
import com.ticticboooom.mods.mm.client.jei.ingredients.model.PressureStack;
import com.ticticboooom.mods.mm.client.jei.ingredients.model.StarlightStack;
import lombok.Setter;
import mezz.jei.api.gui.drawable.IDrawableStatic;
import mezz.jei.api.helpers.IJeiHelpers;
import mezz.jei.api.ingredients.IIngredientRenderer;
import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.StringTextComponent;
import javax.annotation.Nullable;
import java.util.List;
public class StarlightIngredientRenderer implements IIngredientRenderer<StarlightStack> {
@Setter
private IJeiHelpers helpers;
@Override
public void render(MatrixStack matrixStack, int xPosition, int yPosition, @Nullable StarlightStack ingredient) {
if (ingredient != null) {
IDrawableStatic drawable = helpers.getGuiHelper().createDrawable(new ResourceLocation(MM.ID, "textures/gui/slot_parts.png"), 37, 80, 16, 16);
drawable.draw(matrixStack, xPosition, yPosition);
}
}
@Override
public List<ITextComponent> getTooltip(StarlightStack ingredient, ITooltipFlag tooltipFlag) {
return Lists.newArrayList(
new StringTextComponent("Astral Starlight"),
new StringTextComponent(ingredient.getAmount() + " S")
);
}
}

View File

@@ -0,0 +1,12 @@
package com.ticticboooom.mods.mm.client.jei.ingredients;
import com.ticticboooom.mods.mm.client.jei.ingredients.model.PressureStack;
import com.ticticboooom.mods.mm.client.jei.ingredients.model.StarlightStack;
import mezz.jei.api.ingredients.IIngredientType;
public class StarlightIngredientType implements IIngredientType<StarlightStack> {
@Override
public Class<? extends StarlightStack> getIngredientClass() {
return StarlightStack.class;
}
}

View File

@@ -0,0 +1,15 @@
package com.ticticboooom.mods.mm.client.jei.ingredients.model;
import lombok.Getter;
import lombok.Setter;
public class StarlightStack {
@Getter
@Setter
private int amount;
public StarlightStack(int amount){
this.amount = amount;
}
}

View File

@@ -0,0 +1,50 @@
/*
* MIT License
*
* Copyright (c) 2020 Ridanisaurus
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.ticticboooom.mods.mm.core.mixin;
import com.ticticboooom.mods.mm.MM;
import net.minecraft.resources.ResourcePackInfo;
import net.minecraft.resources.ResourcePackList;
import net.minecraftforge.fml.loading.moddiscovery.ModFile;
import net.minecraftforge.fml.packs.ModFileResourcePack;
import net.minecraftforge.fml.packs.ResourcePackLoader;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import java.util.Map;
import java.util.function.BiConsumer;
import java.util.function.BiFunction;
@Mixin(ResourcePackLoader.class)
public class ResourceLoaderMixin {
@Inject(method = "loadResourcePacks(Lnet/minecraft/resources/ResourcePackList;Ljava/util/function/BiFunction;)V", at = @At("RETURN"), remap = false)
private static <T extends ResourcePackInfo> void injectPacks(ResourcePackList resourcePacks, BiFunction<Map<ModFile, ? extends ModFileResourcePack>,
BiConsumer<? super ModFileResourcePack, T>, ResourcePackLoader.IPackInfoFinder> packFinder, CallbackInfo callback) {
MM.injectDatapackFinder(resourcePacks);
}
}

View File

@@ -53,17 +53,23 @@ public class MachineProcessRecipe implements IRecipe<IInventory> {
this.rl = rl;
}
public boolean matches(List<PortStorage> inputPorts, String structureId) {
return structureId.equals(this.structureId) && canTake(inputPorts);
public boolean matches(List<PortStorage> inputPorts, String structureId, ProcessUpdate update) {
return structureId.equals(this.structureId) && canTake(inputPorts, update.getTakenIndices());
}
private boolean canTake(List<PortStorage> inputPorts) {
private boolean canTake(List<PortStorage> inputPorts, List<Integer> takenIndices) {
int i = -1;
for (PortState input : inputs) {
i++;
if (takenIndices.contains(i)) {
continue;
}
if (!input.isConsumePerTick()) {
if (!input.validateRequirement(inputPorts)) {
return false;
}
}
}
return true;
}
@@ -98,7 +104,7 @@ public class MachineProcessRecipe implements IRecipe<IInventory> {
public ProcessUpdate process(List<PortStorage> inputPorts, List<PortStorage> outputPorts, ProcessUpdate update) {
resetChances();
boolean canTake = canTake(inputPorts);
boolean canTake = canTake(inputPorts, update.getTakenIndices());
boolean canPut = canPut(outputPorts);
if (!canTake || !canPut) {
@@ -106,9 +112,24 @@ public class MachineProcessRecipe implements IRecipe<IInventory> {
return update;
}
int takenIndex = 0;
if (update.getTicksTaken() <= 0) {
for (PortState input : inputs) {
if (input.isInstantConsume() && input.validateRequirement(inputPorts)) {
update.getTakenIndices().add(takenIndex);
input.processRequirement(inputPorts);
}
takenIndex++;
}
}
int index = 0;
if (update.getTicksTaken() >= ticks) {
update.getTakenIndices().clear();
for (PortState input : inputs) {
if (input.isConsumePerTick() || input.isInstantConsume()) {
continue;
}
if (inputRolls.get(index) < input.getChance()) {
input.processRequirement(inputPorts);
index++;
@@ -116,17 +137,24 @@ public class MachineProcessRecipe implements IRecipe<IInventory> {
}
index = 0;
for (PortState output : outputs) {
if (output.isConsumePerTick()) {
continue;
}
if (outputRolls.get(index) < output.getChance()) {
output.processResult(outputPorts);
}
}
update.setMsg("");
update.setTicksTaken(0);
update.setTakenIndices(new ArrayList<>());
return update;
}
boolean canTick = true;
index = 0;
for (PortState input : inputs) {
if (input.isConsumePerTick()) {
@@ -247,10 +275,16 @@ public class MachineProcessRecipe implements IRecipe<IInventory> {
chance = out.get("chance").getAsDouble();
}
boolean consumeInstantly = false;
if (out.has("consumeInstantly")) {
consumeInstantly = out.get("consumeInstantly").getAsBoolean();
}
MasterfulPortType value = MMPorts.PORTS.get(typeRl);
PortState data = value.getParser().createState(out.get("data").getAsJsonObject());
data.setConsumePerTick(perTick);
data.setChance(chance);
data.setInstantConsume(consumeInstantly);
ioStates.add(data);
}
return ioStates;

View File

@@ -0,0 +1,141 @@
/*
* MIT License
*
* Copyright (c) 2020 Ridanisaurus
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.ticticboooom.mods.mm.datagen.gen;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.ticticboooom.mods.mm.MM;
import net.minecraft.advancements.criterion.EnchantmentPredicate;
import net.minecraft.advancements.criterion.ItemPredicate;
import net.minecraft.advancements.criterion.MinMaxBounds;
import net.minecraft.block.Block;
import net.minecraft.data.DataGenerator;
import net.minecraft.data.DirectoryCache;
import net.minecraft.data.IDataProvider;
import net.minecraft.data.LootTableProvider;
import net.minecraft.enchantment.Enchantments;
import net.minecraft.item.Item;
import net.minecraft.loot.*;
import net.minecraft.loot.conditions.MatchTool;
import net.minecraft.loot.conditions.SurvivesExplosion;
import net.minecraft.loot.functions.ApplyBonus;
import net.minecraft.loot.functions.ExplosionDecay;
import net.minecraft.loot.functions.SetCount;
import net.minecraft.util.IItemProvider;
import net.minecraft.util.ResourceLocation;
import java.io.IOException;
import java.nio.file.Path;
import java.util.HashMap;
import java.util.Map;
public abstract class BaseLootTableProvider extends LootTableProvider {
private static final Gson GSON = new GsonBuilder().setPrettyPrinting().disableHtmlEscaping().create();
// Filled by subclasses
protected final Map<Block, LootTable.Builder> blockLootTable = new HashMap<>();
protected final Map<Item, LootTable.Builder> itemLootTable = new HashMap<>();
private final DataGenerator generator;
public BaseLootTableProvider(DataGenerator dataGeneratorIn) {
super(dataGeneratorIn);
this.generator = dataGeneratorIn;
}
@Override
// Entry point
public void act(DirectoryCache cache) {
this.addTables();
Map<ResourceLocation, LootTable> tables = new HashMap<>();
for (Map.Entry<Block, LootTable.Builder> entry : this.blockLootTable.entrySet()) {
tables.put(entry.getKey().getLootTable(),
entry.getValue().setParameterSet(LootParameterSets.BLOCK).build());
}
this.writeTables(cache, tables);
}
@Override
public String getName() {
return "MM LootTables";
}
// Subclasses can override this to fill the 'lootTables' map.
protected abstract void addTables();
protected LootTable.Builder createBlockLootTable(Block block) {
LootPool.Builder builder = LootPool.builder()
.rolls(ConstantRange.of(1))
.addEntry(ItemLootEntry.builder(block))
.acceptCondition(SurvivesExplosion.builder());
return LootTable.builder().addLootPool(builder);
}
protected LootTable.Builder createItemLootTable(Item item) {
LootPool.Builder builder = LootPool.builder()
.rolls(ConstantRange.of(1))
.addEntry(ItemLootEntry.builder(item))
.acceptCondition(SurvivesExplosion.builder());
return LootTable.builder().addLootPool(builder);
}
protected LootTable.Builder createSpecialTable(Item item, IItemProvider itemProvider) {
LootPool.Builder builder = LootPool.builder()
.rolls(ConstantRange.of(1))
.addEntry(ItemLootEntry.builder(item)
.acceptCondition(MatchTool.builder(ItemPredicate.Builder.create().enchantment(new EnchantmentPredicate(Enchantments.SILK_TOUCH, MinMaxBounds.IntBound.atLeast(1)))))
.alternatively(ItemLootEntry.builder(itemProvider)
.acceptFunction(ApplyBonus.oreDrops(Enchantments.FORTUNE))
.acceptFunction(ExplosionDecay.builder())));
return LootTable.builder().addLootPool(builder);
}
protected LootTable.Builder createCountTable(Item item, IItemProvider itemProvider, float minCount, float maxCount) {
LootPool.Builder builder = LootPool.builder()
.rolls(ConstantRange.of(1))
.addEntry(ItemLootEntry.builder(item)
.acceptCondition(MatchTool.builder(ItemPredicate.Builder.create().enchantment(new EnchantmentPredicate(Enchantments.SILK_TOUCH, MinMaxBounds.IntBound.atLeast(1)))))
.alternatively(ItemLootEntry.builder(itemProvider)
.acceptFunction(SetCount.builder(RandomValueRange.of(minCount, maxCount)))
.acceptFunction(ApplyBonus.oreDrops(Enchantments.FORTUNE))
.acceptFunction(ExplosionDecay.builder())));
return LootTable.builder().addLootPool(builder);
}
// Actually write out the tables in the output folder
private void writeTables(DirectoryCache cache, Map<ResourceLocation, LootTable> tables) {
Path outputFolder = this.generator.getOutputFolder();
tables.forEach((key, lootTable) -> {
Path path = outputFolder.resolve("data/" + key.getNamespace() + "/loot_tables/" + key.getPath() + ".json");
try {
IDataProvider.save(GSON, cache, LootTableManager.toJson(lootTable), path);
} catch (IOException e) {
MM.LOG.error("Couldn't write loot table {}", path, e);
}
});
}
}

View File

@@ -33,6 +33,9 @@ public class MMBlockStateProvider extends BlockStateProvider {
@Override
protected void registerStatesAndModels() {
for (RegistryObject<ControllerBlock> controller : MMLoader.BLOCKS) {
if (!controller.isPresent()){
return;
}
dynamicBlockNorthOverlay(controller.getId(), controller.get().getTexOverride() != null ? RLUtils.toRL(controller.get().getTexOverride()) : BASE_TEXTURE, CONTROLLER_TEXTURE);
VariantBlockStateBuilder variantBuilder = getVariantBuilder(controller.get());
variantBuilder.partialState().with(DirectionalBlock.FACING, Direction.NORTH).modelForState().modelFile(new ModelFile.UncheckedModelFile(new ResourceLocation(MM.ID, "block/" + controller.getId().getPath()))).rotationY(0).addModel();

View File

@@ -23,6 +23,9 @@ public class MMItemModelProvider extends ItemModelProvider {
@Override
protected void registerModels() {
for (RegistryObject<ControllerBlock> controller : MMLoader.BLOCKS) {
if (!controller.isPresent()){
return;
}
this.getBuilder(controller.getId().toString()).parent(new ModelFile.UncheckedModelFile(new ResourceLocation(controller.getId().getNamespace(), "block/" + controller.getId().getPath())));
}
for (RegistryObject<MachinePortBlock> port : MMLoader.OPORT_BLOCKS) {

View File

@@ -17,6 +17,9 @@ public class MMLangProvider extends LanguageProvider {
@Override
protected void addTranslations() {
for (RegistryObject<ControllerBlock> block : MMLoader.BLOCKS) {
if (!block.isPresent()){
return;
}
this.add(block.get(), block.get().getControllerName() + " Controller");
this.add("container.masterfulmachinery." + block.get().getControllerId() + "_controller.name", block.get().getControllerName() + " Controller");
for (RegistryObject<MachinePortBlock> port : MMLoader.IPORT_BLOCKS) {

View File

@@ -0,0 +1,36 @@
package com.ticticboooom.mods.mm.datagen.gen;
import com.ticticboooom.mods.mm.block.ControllerBlock;
import com.ticticboooom.mods.mm.block.MachinePortBlock;
import com.ticticboooom.mods.mm.registration.MMLoader;
import com.ticticboooom.mods.mm.registration.MMSetup;
import net.minecraft.data.DataGenerator;
import net.minecraftforge.fml.RegistryObject;
import net.minecraftforge.registries.ForgeRegistries;
public class MMLootTableProvider extends BaseLootTableProvider {
public MMLootTableProvider(DataGenerator dataGeneratorIn) {
super(dataGeneratorIn);
}
@Override
protected void addTables() {
for (RegistryObject<ControllerBlock> controller : MMLoader.BLOCKS) {
if (!controller.isPresent()){
return;
}
blockLootTable.put(controller.get(), createItemLootTable(ForgeRegistries.ITEMS.getValue(controller.getId())));
}
for (RegistryObject<MachinePortBlock> port : MMLoader.IPORT_BLOCKS) {
blockLootTable.put(port.get(), createItemLootTable(ForgeRegistries.ITEMS.getValue(port.getId())));
}
for (RegistryObject<MachinePortBlock> port : MMLoader.OPORT_BLOCKS) {
blockLootTable.put(port.get(), createItemLootTable(ForgeRegistries.ITEMS.getValue(port.getId())));
}
blockLootTable.put(MMSetup.PROJECTOR_BLOCK.get(), createCountTable(MMSetup.PROJECTOR_ITEM.get(), MMSetup.PROJECTOR_ITEM.get(), 1, 1));
blockLootTable.put(MMSetup.STRUCTURE_BLOCK.get(), createBlockLootTable(MMSetup.STRUCTURE_BLOCK.get()));
}
}

View File

@@ -31,6 +31,9 @@ public class MMIndependentStarlightSource implements IIndependentStarlightSource
@Override
public float produceStarlightTick(ServerWorld serverWorld, BlockPos blockPos) {
if (storage == null){
return 0;
}
return storage.getInv().extractStarlight(Integer.MAX_VALUE, false);
}

View File

@@ -5,6 +5,8 @@ import lombok.Getter;
import lombok.Setter;
import net.minecraft.util.ResourceLocation;
import java.util.List;
@Getter
@Setter
@AllArgsConstructor
@@ -13,4 +15,5 @@ public class ProcessUpdate {
private String msg;
private String id;
private String sid;
private List<Integer> takenIndices;
}

View File

@@ -46,6 +46,10 @@ public class NBTActionParser {
}
public static void write(PacketBuffer buf, NBTModel model) {
if (model == null) {
buf.writeInt(0);
return;
}
buf.writeInt(model.getActions().size());
for (NBTActionModel action : model.getActions()) {
buf.writeString(action.getAction());

View File

@@ -48,12 +48,12 @@ public class ManaPortParser extends PortFactory {
@Override
public ResourceLocation getInputOverlay() {
return new ResourceLocation(MM.ID, "block/compat_ports/botania_mana_cutout");
return new ResourceLocation(MM.ID, "block/compat_ports/botania_mana_input_cutout");
}
@Override
public ResourceLocation getOutputOverlay() {
return new ResourceLocation(MM.ID, "block/compat_ports/botania_mana_cutout");
return new ResourceLocation(MM.ID, "block/compat_ports/botania_mana_output_cutout");
}
@Override

View File

@@ -59,11 +59,11 @@ public class MekGasPortParser extends PortFactory {
@Override
public ResourceLocation getInputOverlay() {
return new ResourceLocation(MM.ID, "block/compat_ports/mekanism_gas_cutout");
return new ResourceLocation(MM.ID, "block/compat_ports/mekanism_gas_input_cutout");
}
@Override
public ResourceLocation getOutputOverlay() {
return new ResourceLocation(MM.ID, "block/compat_ports/mekanism_gas_cutout");
return new ResourceLocation(MM.ID, "block/compat_ports/mekanism_gas_output_cutout");
}
}

View File

@@ -61,11 +61,11 @@ public class MekInfusePortParser extends PortFactory {
@Override
public ResourceLocation getInputOverlay() {
return new ResourceLocation(MM.ID, "block/compat_ports/mekanism_slurry_cutout");
return new ResourceLocation(MM.ID, "block/compat_ports/mekanism_infusion_input_cutout");
}
@Override
public ResourceLocation getOutputOverlay() {
return new ResourceLocation(MM.ID, "block/compat_ports/mekanism_slurry_cutout");
return new ResourceLocation(MM.ID, "block/compat_ports/mekanism_infusion_input_cutout");
}
}

View File

@@ -59,11 +59,11 @@ public class MekSlurryPortParser extends PortFactory {
@Override
public ResourceLocation getInputOverlay() {
return new ResourceLocation(MM.ID, "block/compat_ports/mekanism_slurry_cutout");
return new ResourceLocation(MM.ID, "block/compat_ports/mekanism_slurry_input_cutout");
}
@Override
public ResourceLocation getOutputOverlay() {
return new ResourceLocation(MM.ID, "block/compat_ports/mekanism_slurry_cutout");
return new ResourceLocation(MM.ID, "block/compat_ports/mekanism_slurry_output_cutout");
}
}

View File

@@ -46,12 +46,12 @@ public class PneumaticPortParser extends PortFactory {
@Override
public ResourceLocation getInputOverlay() {
return new ResourceLocation(MM.ID, "block/compat_ports/pncr_pressure_cutout");
return new ResourceLocation(MM.ID, "block/compat_ports/pncr_pressure_input_cutout");
}
@Override
public ResourceLocation getOutputOverlay() {
return new ResourceLocation(MM.ID, "block/compat_ports/pncr_pressure_cutout");
return new ResourceLocation(MM.ID, "block/compat_ports/pncr_pressure_output_cutout");
}
@Override

View File

@@ -51,12 +51,12 @@ public class RotationPortParser extends PortFactory {
@Override
public ResourceLocation getInputOverlay() {
return new ResourceLocation(MM.ID, "block/compat_ports/create_rotation_cutout");
return new ResourceLocation(MM.ID, "block/compat_ports/create_rotation_input_cutout");
}
@Override
public ResourceLocation getOutputOverlay() {
return new ResourceLocation(MM.ID, "block/compat_ports/create_rotation_cutout");
return new ResourceLocation(MM.ID, "block/compat_ports/create_rotation_output_cutout");
}
@Override

View File

@@ -49,12 +49,12 @@ public class StarlightPortParser extends PortFactory {
@Override
public ResourceLocation getInputOverlay() {
return new ResourceLocation(MM.ID, "block/compat_ports/starlight_cutout");
return new ResourceLocation(MM.ID, "block/compat_ports/astral_starlight_input_cutout");
}
@Override
public ResourceLocation getOutputOverlay() {
return new ResourceLocation(MM.ID, "block/compat_ports/starlight_cutout");
return new ResourceLocation(MM.ID, "block/compat_ports/astral_starlight_output_cutout");
}
@Override

View File

@@ -91,7 +91,7 @@ public class PneumaticPortState extends PortState {
@Override
public void setupRecipe(IRecipeLayout layout, Integer typeIndex, int x, int y, boolean input) {
IGuiIngredientGroup<PressureStack> group = layout.getIngredientsGroup(MMJeiPlugin.PRESSURE_TYPE);
group.init(typeIndex, input, x, y);
group.init(typeIndex, input, x+ 1, y +1);
group.set(typeIndex, new PressureStack(pressure));
}

View File

@@ -21,6 +21,10 @@ public abstract class PortState {
@Getter
@Setter
private double chance = 0;
@Getter
@Setter
private boolean instantConsume = false;
public abstract void processRequirement(List<PortStorage> storage);
public abstract boolean validateRequirement(List<PortStorage> storage);
public abstract void processResult(List<PortStorage> storage);

View File

@@ -5,6 +5,8 @@ import com.mojang.serialization.Codec;
import com.mojang.serialization.codecs.RecordCodecBuilder;
import com.ticticboooom.mods.mm.MM;
import com.ticticboooom.mods.mm.client.jei.category.MMJeiPlugin;
import com.ticticboooom.mods.mm.client.jei.ingredients.model.PressureStack;
import com.ticticboooom.mods.mm.client.jei.ingredients.model.StarlightStack;
import com.ticticboooom.mods.mm.ports.storage.StarlightPortStorage;
import com.ticticboooom.mods.mm.ports.storage.PortStorage;
import com.ticticboooom.mods.mm.ports.storage.StarlightPortStorage;
@@ -12,6 +14,7 @@ import hellfirepvp.astralsorcery.common.block.base.BlockStarlightRecipient;
import hellfirepvp.astralsorcery.common.constellation.IWeakConstellation;
import mezz.jei.api.gui.IRecipeLayout;
import mezz.jei.api.gui.drawable.IDrawableStatic;
import mezz.jei.api.gui.ingredient.IGuiIngredientGroup;
import mezz.jei.api.helpers.IJeiHelpers;
import mezz.jei.api.ingredients.IIngredientType;
import net.minecraft.util.ResourceLocation;
@@ -99,7 +102,6 @@ public class StarlightPortState extends PortState {
@Override
public IIngredientType<?> getJeiIngredientType() {
// Am guessing is placeholder?
return MMJeiPlugin.PRESSURE_TYPE;
}
@@ -110,7 +112,9 @@ public class StarlightPortState extends PortState {
@Override
public void setupRecipe(IRecipeLayout layout, Integer typeIndex, int x, int y, boolean input) {
IGuiIngredientGroup<StarlightStack> group = layout.getIngredientsGroup(MMJeiPlugin.STAR_TYPE);
group.init(typeIndex, input, x + 1, y+1);
group.set(typeIndex, new StarlightStack(amount));
}
@Override

Binary file not shown.

After

Width:  |  Height:  |  Size: 405 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 393 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 39 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 384 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 374 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 368 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 358 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 39 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 312 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 290 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 326 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 315 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 311 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 296 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 310 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 296 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 320 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 308 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 315 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 295 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 372 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 358 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 39 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 KiB

After

Width:  |  Height:  |  Size: 3.4 KiB

View File

@@ -0,0 +1,14 @@
{
"required": true,
"package": "com.ticticboooom.mods.mm.core.mixin",
"compatibilityLevel": "JAVA_8",
"refmap": "masterfulmachinery.refmap.json",
"mixins": [
"ResourceLoaderMixin"
],
"injectors": {
"maxShiftBy": 3,
"defaultRequire": 1
},
"minVersion": "0.8"
}

View File

@@ -1,2 +1,2 @@
#Wed May 26 12:18:11 BST 2021
VERSION_CODE=189
#Sat May 29 16:05:26 BST 2021
VERSION_CODE=333