Skip to content

Commit

Permalink
Revert "Revert "Merge branch 'main' of https://github.com/RuiXuqi/MEK…
Browse files Browse the repository at this point in the history
…-1.12.2-v10""

This reverts commit 1498f1e.
  • Loading branch information
RuiXuqi committed Jan 25, 2023
1 parent 1498f1e commit 880f0dc
Show file tree
Hide file tree
Showing 6 changed files with 101 additions and 15 deletions.
6 changes: 5 additions & 1 deletion GroovyScript-examples/mekanism.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,8 @@ mods.Mekanism.CellExtractor.removeByInput(item('minecraft:iron_ore'))

//CellSeparator
mods.Mekanism.CellSeparator.add(item('minecraft:stone'),item('minecraft:stone:1'),item('minecraft:stone:2'),1)
mods.Mekanism.CellSeparator.removeByInput(item('minecraft:iron_ore'))
mods.Mekanism.CellSeparator.removeByInput(item('minecraft:iron_ore'))

//Energized Smelter
//mods.mekanism.Smelter.removeByInput(item('minecraft:gold_ore'))
mods.mekanism.Smelter.add(item('minecraft:iron_ore'),item('minecraft:iron_ingot'))
27 changes: 19 additions & 8 deletions src/main/java/mekanism/client/gui/GuiFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -84,36 +84,47 @@ public void initGui() {
this.buttonList.add(this.infuserDumpButton = new GuiButtonImage(1, this.guiLeft+148, this.guiTop+77, 21, 10, 147, 72, 0, MekanismUtils.getResource(ResourceType.GUI, "GuiMetallurgicInfuser.png")){
@Override
public void drawButton(@NotNull Minecraft mc, int mouseX, int mouseY, float partialTicks) {
if (GuiFactory.this.tileEntity.getRecipeType() == RecipeType.INFUSING || GuiFactory.this.tileEntity.getRecipeType().getFuelType() == MachineFuelType.ADVANCED|| GuiFactory.this.tileEntity.getRecipeType().getFuelType() == MachineFuelType.FARM) {
if (GuiFactory.this.tileEntity.getRecipeType() == RecipeType.INFUSING
|| GuiFactory.this.tileEntity.getRecipeType().getFuelType() == MachineFuelType.ADVANCED
|| GuiFactory.this.tileEntity.getRecipeType().getFuelType() == MachineFuelType.FARM
) {
super.drawButton(mc, mouseX, mouseY, partialTicks);
}
}

@Override
public boolean mousePressed(@NotNull Minecraft mc, int mouseX, int mouseY) {
return GuiFactory.this.tileEntity.getRecipeType() == RecipeType.INFUSING || GuiFactory.this.tileEntity.getRecipeType().getFuelType() == MachineFuelType.ADVANCED|| GuiFactory.this.tileEntity.getRecipeType().getFuelType() == MachineFuelType.FARM && super.mousePressed(mc, mouseX, mouseY);
return (GuiFactory.this.tileEntity.getRecipeType() == RecipeType.INFUSING
|| GuiFactory.this.tileEntity.getRecipeType().getFuelType() == MachineFuelType.ADVANCED
|| GuiFactory.this.tileEntity.getRecipeType().getFuelType() == MachineFuelType.FARM
) && super.mousePressed(mc, mouseX, mouseY);
}
});
}else if (tileEntity.tier == FactoryTier.ULTIMATE){
this.buttonList.add(this.infuserDumpButton = new GuiButtonImage(1, this.guiLeft+182, this.guiTop+77, 21, 10, 147, 72, 0, MekanismUtils.getResource(ResourceType.GUI, "GuiMetallurgicInfuser.png")){
@Override
public void drawButton(@NotNull Minecraft mc, int mouseX, int mouseY, float partialTicks) {
if (GuiFactory.this.tileEntity.getRecipeType() == RecipeType.INFUSING || GuiFactory.this.tileEntity.getRecipeType().getFuelType() == MachineFuelType.ADVANCED|| GuiFactory.this.tileEntity.getRecipeType().getFuelType() == MachineFuelType.FARM) {
if (GuiFactory.this.tileEntity.getRecipeType() == RecipeType.INFUSING
|| GuiFactory.this.tileEntity.getRecipeType().getFuelType() == MachineFuelType.ADVANCED
|| GuiFactory.this.tileEntity.getRecipeType().getFuelType() == MachineFuelType.FARM) {
super.drawButton(mc, mouseX, mouseY, partialTicks);
}
}

@Override
public boolean mousePressed(@NotNull Minecraft mc, int mouseX, int mouseY) {
return (GuiFactory.this.tileEntity.getRecipeType() == RecipeType.INFUSING || GuiFactory.this.tileEntity.getRecipeType().getFuelType() == MachineFuelType.ADVANCED || GuiFactory.this.tileEntity.getRecipeType().getFuelType() == MachineFuelType.FARM )&& super.mousePressed(mc, mouseX, mouseY);
return (GuiFactory.this.tileEntity.getRecipeType() == RecipeType.INFUSING
|| GuiFactory.this.tileEntity.getRecipeType().getFuelType() == MachineFuelType.ADVANCED
|| GuiFactory.this.tileEntity.getRecipeType().getFuelType() == MachineFuelType.FARM
)&& super.mousePressed(mc, mouseX, mouseY);
}
});
}else {
this.buttonList.add(this.infuserDumpButton = new GuiButtonImage(1, this.guiLeft+220, this.guiTop+77, 21, 10, 147, 72, 0, MekanismUtils.getResource(ResourceType.GUI, "GuiMetallurgicInfuser.png")){
@Override
public void drawButton(@NotNull Minecraft mc, int mouseX, int mouseY, float partialTicks) {
if (GuiFactory.this.tileEntity.getRecipeType() == RecipeType.INFUSING
//|| GuiFactory.this.tileEntity.getRecipeType().getFuelType() == MachineFuelType.ADVANCED
|| GuiFactory.this.tileEntity.getRecipeType().getFuelType() == MachineFuelType.ADVANCED
|| GuiFactory.this.tileEntity.getRecipeType().getFuelType() == MachineFuelType.FARM
) {
super.drawButton(mc, mouseX, mouseY, partialTicks);
Expand All @@ -122,10 +133,10 @@ public void drawButton(@NotNull Minecraft mc, int mouseX, int mouseY, float part

@Override
public boolean mousePressed(@NotNull Minecraft mc, int mouseX, int mouseY) {
return GuiFactory.this.tileEntity.getRecipeType() == RecipeType.INFUSING
//|| GuiFactory.this.tileEntity.getRecipeType().getFuelType() == MachineFuelType.ADVANCED
return (GuiFactory.this.tileEntity.getRecipeType() == RecipeType.INFUSING
|| GuiFactory.this.tileEntity.getRecipeType().getFuelType() == MachineFuelType.ADVANCED
|| GuiFactory.this.tileEntity.getRecipeType().getFuelType() == MachineFuelType.FARM
&& super.mousePressed(mc, mouseX, mouseY);
)&& super.mousePressed(mc, mouseX, mouseY);
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ public class GrSMekanismAdd extends Mekanism {
public Alloy alloy = new Alloy();
public CellExtractor cellExtractor = new CellExtractor();
public CellSeparator cellSeparator = new CellSeparator();
public Smelter smelter = new Smelter();


public GrSMekanismAdd(){
addRegistry(nutritionalLiquifier);
Expand All @@ -35,7 +37,7 @@ public GrSMekanismAdd(){
addRegistry(alloy);
addRegistry(cellExtractor);
addRegistry(cellSeparator);

addRegistry(smelter);
}


Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package mekanism.common.integration.groovyscript.machinerecipe;

import com.cleanroommc.groovyscript.api.GroovyLog;
import com.cleanroommc.groovyscript.api.IIngredient;
import com.cleanroommc.groovyscript.compat.mods.mekanism.recipe.VirtualizedMekanismRegistry;
import com.cleanroommc.groovyscript.helper.ingredient.IngredientHelper;
import mekanism.common.recipe.RecipeHandler;
import mekanism.common.recipe.inputs.ItemStackInput;
import mekanism.common.recipe.machines.SmeltingRecipe;
import net.minecraft.item.ItemStack;

public class Smelter extends VirtualizedMekanismRegistry<SmeltingRecipe> {

public Smelter(){
super(RecipeHandler.Recipe.ENERGIZED_SMELTER,"Smelter","smelter","Energized_Smelter");
}

public SmeltingRecipe add(IIngredient ingredient, ItemStack output){
GroovyLog.Msg msg = GroovyLog.msg("Error adding Energized Smelter recipe").error();
msg.add(IngredientHelper.isEmpty(ingredient), () -> "input must not be empty");
msg.add(IngredientHelper.isEmpty(output), () -> "output must not be empty");
if (msg.postIfNotEmpty()) return null;
output = output.copy();
SmeltingRecipe recipe1 = null;
for (ItemStack itemStack : ingredient.getMatchingStacks()) {
SmeltingRecipe recipe = new SmeltingRecipe(itemStack.copy(), output);
if (recipe1 == null) recipe1 = recipe;
recipeRegistry.put(recipe);
addScripted(recipe);
}
return recipe1;
}
public boolean removeByInput(IIngredient ingredient) {
if (IngredientHelper.isEmpty(ingredient)) {
removeError("input must not be empty");
return false;
}
boolean found = false;
for (ItemStack itemStack : ingredient.getMatchingStacks()) {
SmeltingRecipe recipe = recipeRegistry.get().remove(new ItemStackInput(itemStack));
if (recipe != null) {
addBackup(recipe);
found = true;
}
}
if (!found) {
removeError("could not find recipe for %s", ingredient);
}
return found;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,16 +55,22 @@ public boolean isItemValid(ItemStack stack) {
});
addSlotToContainer(new SlotOutput(tileEntity, 3, 180 + 72, 112 ));
}
addSlotToContainer(new Slot(tileEntity, 4, 7, 57));

//如果是这些类型的工厂,则添加额外插槽 --可能会导致shift左键放不进第一个插槽
if(tileEntity.getRecipeType().getFuelType() == MachineFuelType.ADVANCED
|| tileEntity.getRecipeType().getFuelType() == MachineFuelType.FARM
|| tileEntity.getRecipeType() == RecipeType.INFUSING
|| tileEntity.getRecipeType().getFuelType() == MachineFuelType.CHANCE
|| tileEntity.getRecipeType().getFuelType() == MachineFuelType.DOUBLE
){
addSlotToContainer(new Slot(tileEntity, 4, 7, 57));
}
if (tileEntity.tier == FactoryTier.BASIC) {
for (int i = 0; i < tileEntity.tier.processes; i++) {
addSlotToContainer(new FactoryInputSlot(tileEntity, getInputSlotIndex(i), 55 + (i * 38), 13, i));
}
for (int i = 0; i < tileEntity.tier.processes; i++) {
addSlotToContainer(new SlotOutput(tileEntity, getOutputSlotIndex(i), 55 + (i * 38), 57));
// if (tileEntity.getRecipeType() == RecipeType.SAWING||tileEntity.getRecipeType() == RecipeType.FARM){
// addSlotToContainer(new SlotOutput(tileEntity,getsecondaryOutputSlotIndex(i),55+(i * 38), 57+18));
// }
}

} else if (tileEntity.tier == FactoryTier.ADVANCED) {
Expand Down Expand Up @@ -97,6 +103,8 @@ public boolean isItemValid(ItemStack stack) {
addSlotToContainer(new SlotOutput(tileEntity, getOutputSlotIndex(i), 27 + (i * 19), 57));
}
}


}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,17 @@ public boolean canReceiveGas(EnumFacing side, Gas type) {
@Override
public int receiveGas(EnumFacing side, GasStack stack, boolean doTransfer) {
if (canReceiveGas(side, stack.getGas())) {
return inputTank.receive(stack, doTransfer);
if (stack == null) {
return 0;
}
int recipeAmount = Recipe.CHEMICAL_CRYSTALLIZER.get().get(new GasInput(stack)).recipeInput.ingredient.amount;
int receivable = inputTank.receive(stack, false);
int stored = inputTank.stored != null ? inputTank.stored.amount : 0;
int newStored = stored + receivable;

int amount = newStored - stored - newStored % recipeAmount;

return inputTank.receive(stack.copy().withAmount(amount), doTransfer);
}
return 0;
}
Expand Down

0 comments on commit 880f0dc

Please sign in to comment.