Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -140,10 +140,10 @@ private static VoxelShape box(double minX, double minY, double minZ, double maxX
VoxelShapeUtils.setShape(VoxelShapeUtils.combine(
Block.box(4, 4, 16, 12, 12, 16),
Block.box(4, 4, 15, 12, 12, 16),
Block.box(4, 16, 1, 12, 26, 1),
Block.box(1, 16, 4, 1, 26, 12),
Block.box(4, 16, 15, 12, 26, 15),
Block.box(15, 16, 4, 15, 26, 12),
Block.box(4, 16, 1, 12, 26, 2),
Block.box(1, 16, 4, 2, 26, 12),
Block.box(4, 16, 14, 12, 26, 15),
Block.box(14, 16, 4, 15, 26, 12),
Block.box(0, 0, 0, 16, 16, 4),
Block.box(0, 12, 4, 16, 16, 16),
Block.box(1, 4, 4, 15, 12, 15),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.jerry.mekaf.generated.mekaf;

import mekanism.common.integration.computer.IComputerMethodRegistry;

public class ComputerMethodRegistry_mekaf implements IComputerMethodRegistry {

@Override
public void register() {}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.jerry.meklm.generated.meklm;

import mekanism.common.integration.computer.IComputerMethodRegistry;

public class ComputerMethodRegistry_meklm implements IComputerMethodRegistry {

@Override
public void register() {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,26 @@ public RecipeSerializer<BasicRecyclerRecipe> getSerializer() {
return MoreMachineRecipeSerializers.RECYCLER.get();
}

@Override
public boolean equals(Object o) {
if (o == this) {
return true;
} else if (o == null || getClass() != o.getClass()) {
return false;
}
BasicRecyclerRecipe other = (BasicRecyclerRecipe) o;
return input.equals(other.input) && ItemStack.matches(chanceOutput, other.chanceOutput) && chance == other.chance;
}

@Override
public int hashCode() {
int hash = input.hashCode();
hash = 31 * hash + ItemStack.hashItemAndComponents(chanceOutput);
hash = 31 * hash + chanceOutput.getCount();
hash = 31 * hash + Double.hashCode(chance);
return hash;
}

/**
* Represents a precalculated chance based output. This output keeps track of what random value was calculated for
* use in comparing if the secondary output should be
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,18 @@
@NothingNullByDefault
public class BasicStamperRecipe extends StamperRecipe {

protected final ItemStackIngredient mainInput;
protected final ItemStackIngredient extraInput;
protected final ItemStackIngredient input;
protected final ItemStackIngredient mold;
protected final ItemStack output;

/**
* @param mainInput Main input.
* @param extraInput Secondary/extra input.
* @param output Output.
* @param input Input.
* @param mold Mold.
* @param output Output.
*/
public BasicStamperRecipe(ItemStackIngredient mainInput, ItemStackIngredient extraInput, ItemStack output) {
this.mainInput = Objects.requireNonNull(mainInput, "Main input cannot be null.");
this.extraInput = Objects.requireNonNull(extraInput, "Secondary/Extra input cannot be null.");
public BasicStamperRecipe(ItemStackIngredient input, ItemStackIngredient mold, ItemStack output) {
this.input = Objects.requireNonNull(input, "Input cannot be null.");
this.mold = Objects.requireNonNull(mold, "Mold cannot be null.");
Objects.requireNonNull(output, "Output cannot be null.");
if (output.isEmpty()) {
throw new IllegalArgumentException("Output cannot be empty.");
Expand All @@ -41,17 +41,17 @@ public BasicStamperRecipe(ItemStackIngredient mainInput, ItemStackIngredient ext

@Override
public boolean test(ItemStack input, ItemStack extra) {
return mainInput.test(input) && extraInput.test(extra);
return this.input.test(input) && mold.test(extra);
}

@Override
public ItemStackIngredient getInput() {
return mainInput;
return input;
}

@Override
public ItemStackIngredient getMold() {
return extraInput;
return mold;
}

@Override
Expand Down Expand Up @@ -88,12 +88,12 @@ public boolean equals(Object o) {
return false;
}
BasicStamperRecipe other = (BasicStamperRecipe) o;
return mainInput.equals(other.mainInput) && extraInput.equals(other.extraInput) && ItemStack.matches(output, other.output);
return input.equals(other.input) && mold.equals(other.mold) && ItemStack.matches(output, other.output);
}

@Override
public int hashCode() {
int hash = Objects.hash(mainInput, extraInput);
int hash = Objects.hash(input, mold);
hash = 31 * hash + ItemStack.hashItemAndComponents(output);
hash = 31 * hash + output.getCount();
return hash;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,7 @@ protected void addGuiElements() {
}
ChemicalStack chemicalStack = tile.chemicalTank.getStack();
if (chemicalStack.isEmpty()) {
ChemicalStack fallBack = tile.getActiveType();
if (fallBack.isEmpty()) {
list.add(MekanismLang.NO_CHEMICAL.translate());
} else {
list.add(fallBack.getTextComponent());
}
list.add(MekanismLang.NO_CHEMICAL.translate());
} else {
list.add(MekanismLang.GENERIC_STORED_MB.translate(chemicalStack, TextUtils.format(chemicalStack.getAmount())));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ public GuiChemicalReplicator(MekanismTileContainer<TileEntityChemicalReplicator>
protected void addGuiElements() {
super.addGuiElements();
addRenderableWidget(new GuiEnergyTab(this, tile.getEnergyContainer(), tile::getActive));
addRenderableWidget(new GuiChemicalGauge(() -> tile.firstInputTank, () -> tile.getChemicalTanks(null), GaugeType.STANDARD, this, 28, 4))
addRenderableWidget(new GuiChemicalGauge(() -> tile.inputTank, () -> tile.getChemicalTanks(null), GaugeType.STANDARD, this, 28, 4))
.warning(WarningTracker.WarningType.NO_MATCHING_RECIPE, tile.getWarningCheck(CachedRecipe.OperationTracker.RecipeError.NOT_ENOUGH_INPUT));
addRenderableWidget(new GuiChemicalGauge(() -> tile.secondaryInputTank, () -> tile.getChemicalTanks(null), GaugeType.STANDARD, this, 7, 4))
addRenderableWidget(new GuiChemicalGauge(() -> tile.uuTank, () -> tile.getChemicalTanks(null), GaugeType.STANDARD, this, 7, 4))
.warning(WarningTracker.WarningType.NO_MATCHING_RECIPE, tile.getWarningCheck(CachedRecipe.OperationTracker.RecipeError.NOT_ENOUGH_SECONDARY_INPUT));
addRenderableWidget(new GuiChemicalGauge(() -> tile.chemicalOutputTank, () -> tile.getChemicalTanks(null), GaugeType.STANDARD, this, 131, 4))
addRenderableWidget(new GuiChemicalGauge(() -> tile.outputTank, () -> tile.getChemicalTanks(null), GaugeType.STANDARD, this, 131, 4))
.warning(WarningTracker.WarningType.NO_SPACE_IN_OUTPUT, tile.getWarningCheck(CachedRecipe.OperationTracker.RecipeError.NOT_ENOUGH_OUTPUT_SPACE));
addRenderableWidget(new GuiEnergyGauge(tile.getEnergyContainer(), GaugeType.STANDARD, this, 151, 4))
.warning(WarningTracker.WarningType.NOT_ENOUGH_ENERGY, tile.getWarningCheck(CachedRecipe.OperationTracker.RecipeError.NOT_ENOUGH_ENERGY));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ protected void addGuiElements() {
super.addGuiElements();
addRenderableWidget(new GuiDownArrow(this, imageWidth + 8, 90));
addRenderableWidget(new GuiEnergyTab(this, tile.getEnergyContainer(), tile::getActive));
addRenderableWidget(new GuiFluidGauge(() -> tile.fluidInputTank, () -> tile.getFluidTanks(null), GaugeType.STANDARD, this, 28, 4))
addRenderableWidget(new GuiFluidGauge(() -> tile.inputTank, () -> tile.getFluidTanks(null), GaugeType.STANDARD, this, 28, 4))
.warning(WarningTracker.WarningType.NO_MATCHING_RECIPE, tile.getWarningCheck(CachedRecipe.OperationTracker.RecipeError.NOT_ENOUGH_INPUT));
addRenderableWidget(new GuiChemicalGauge(() -> tile.chemicalTank, () -> tile.getChemicalTanks(null), GaugeType.STANDARD, this, 7, 4))
addRenderableWidget(new GuiChemicalGauge(() -> tile.uuTank, () -> tile.getChemicalTanks(null), GaugeType.STANDARD, this, 7, 4))
.warning(WarningTracker.WarningType.NO_MATCHING_RECIPE, tile.getWarningCheck(CachedRecipe.OperationTracker.RecipeError.NOT_ENOUGH_SECONDARY_INPUT));
addRenderableWidget(new GuiFluidGauge(() -> tile.fluidOutputTank, () -> tile.getFluidTanks(null), GaugeType.STANDARD, this, 131, 4))
addRenderableWidget(new GuiFluidGauge(() -> tile.outputTank, () -> tile.getFluidTanks(null), GaugeType.STANDARD, this, 131, 4))
.warning(WarningTracker.WarningType.NO_SPACE_IN_OUTPUT, tile.getWarningCheck(CachedRecipe.OperationTracker.RecipeError.NOT_ENOUGH_OUTPUT_SPACE));
addRenderableWidget(new GuiEnergyGauge(tile.getEnergyContainer(), GaugeType.STANDARD, this, 151, 4))
.warning(WarningTracker.WarningType.NOT_ENOUGH_ENERGY, tile.getWarningCheck(CachedRecipe.OperationTracker.RecipeError.NOT_ENOUGH_ENERGY));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package com.jerry.mekmm.common.tile.machine;

import mekanism.api.chemical.ChemicalStack;
import mekanism.common.integration.computer.*;
import mekanism.common.integration.computer.annotation.MethodFactory;

import net.minecraft.world.item.ItemStack;

@MethodFactory(target = TileEntityAmbientGasCollector.class)
public class TileEntityAmbientGasCollector$ComputerHandler extends ComputerMethodFactory<TileEntityAmbientGasCollector> {

public TileEntityAmbientGasCollector$ComputerHandler() {
register(MethodData.builder("getChemical", TileEntityAmbientGasCollector$ComputerHandler::chemicalTank$getChemical).returnType(ChemicalStack.class).methodDescription("Get the contents of the chemical tank."));
register(MethodData.builder("getChemicalCapacity", TileEntityAmbientGasCollector$ComputerHandler::chemicalTank$getChemicalCapacity).returnType(int.class).methodDescription("Get the capacity of the chemical tank."));
register(MethodData.builder("getChemicalNeeded", TileEntityAmbientGasCollector$ComputerHandler::chemicalTank$getChemicalNeeded).returnType(int.class).methodDescription("Get the amount needed to fill the chemical tank."));
register(MethodData.builder("getChemicalFilledPercentage", TileEntityAmbientGasCollector$ComputerHandler::chemicalTank$getChemicalFilledPercentage).returnType(double.class).methodDescription("Get the filled percentage of the buffer tank."));
register(MethodData.builder("getChemicalItem", TileEntityAmbientGasCollector$ComputerHandler::inputSlot$getChemicalItem).returnType(ItemStack.class).methodDescription("Get the contents of the input slot."));
register(MethodData.builder("getEnergyItem", TileEntityAmbientGasCollector$ComputerHandler::energySlot$getEnergyItem).returnType(ItemStack.class).methodDescription("Get the contents of the energy slot."));
}

public static Object chemicalTank$getChemical(TileEntityAmbientGasCollector subject, BaseComputerHelper helper) throws ComputerException {
return helper.convert(SpecialComputerMethodWrapper.ComputerChemicalTankWrapper.getStack(subject.chemicalTank));
}

public static Object chemicalTank$getChemicalCapacity(TileEntityAmbientGasCollector subject, BaseComputerHelper helper) throws ComputerException {
return helper.convert(SpecialComputerMethodWrapper.ComputerChemicalTankWrapper.getCapacity(subject.chemicalTank));
}

public static Object chemicalTank$getChemicalNeeded(TileEntityAmbientGasCollector subject, BaseComputerHelper helper) throws ComputerException {
return helper.convert(SpecialComputerMethodWrapper.ComputerChemicalTankWrapper.getNeeded(subject.chemicalTank));
}

public static Object chemicalTank$getChemicalFilledPercentage(TileEntityAmbientGasCollector subject, BaseComputerHelper helper) throws ComputerException {
return helper.convert(SpecialComputerMethodWrapper.ComputerChemicalTankWrapper.getFilledPercentage(subject.chemicalTank));
}

public static Object inputSlot$getChemicalItem(TileEntityAmbientGasCollector subject, BaseComputerHelper helper) throws ComputerException {
return helper.convert(SpecialComputerMethodWrapper.ComputerIInventorySlotWrapper.getStack(subject.chemicalSlot));
}

public static Object energySlot$getEnergyItem(TileEntityAmbientGasCollector subject, BaseComputerHelper helper) throws ComputerException {
return helper.convert(SpecialComputerMethodWrapper.ComputerIInventorySlotWrapper.getStack(subject.energySlot));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@
import mekanism.common.capabilities.holder.energy.IEnergyContainerHolder;
import mekanism.common.capabilities.holder.slot.IInventorySlotHolder;
import mekanism.common.capabilities.holder.slot.InventorySlotHelper;
import mekanism.common.integration.computer.SpecialComputerMethodWrapper.ComputerChemicalTankWrapper;
import mekanism.common.integration.computer.SpecialComputerMethodWrapper.ComputerIInventorySlotWrapper;
import mekanism.common.integration.computer.annotation.WrappingComputerMethod;
import mekanism.common.inventory.container.MekanismContainer;
import mekanism.common.inventory.container.slot.SlotOverlay;
import mekanism.common.inventory.container.sync.SyncableBoolean;
import mekanism.common.inventory.container.sync.chemical.SyncableChemicalStack;
import mekanism.common.inventory.slot.EnergyInventorySlot;
import mekanism.common.inventory.slot.chemical.ChemicalInventorySlot;
import mekanism.common.tile.base.TileEntityMekanism;
Expand All @@ -39,6 +41,7 @@
import net.neoforged.neoforge.capabilities.BlockCapabilityCache;
import net.neoforged.neoforge.fluids.FluidType;

import lombok.Getter;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

Expand All @@ -56,12 +59,12 @@ public class TileEntityAmbientGasCollector extends TileEntityMekanism {
private static final int BASE_OUTPUT_RATE = 256;

// 化学品存储槽
@WrappingComputerMethod(wrapper = ComputerChemicalTankWrapper.class,
methodNames = { "getChemical", "getChemicalCapacity", "getChemicalNeeded",
"getChemicalFilledPercentage" },
docPlaceholder = "chemical tank")
public IChemicalTank chemicalTank;
/**
* The type of chemical this collector is collecting
*/
@NotNull
private ChemicalStack activeType = ChemicalStack.EMPTY;

public int ticksRequired = BASE_TICKS_REQUIRED;
/**
* How many ticks this machine has been operating for.
Expand All @@ -73,8 +76,11 @@ public class TileEntityAmbientGasCollector extends TileEntityMekanism {
private boolean noBlocking = true;
private List<BlockCapabilityCache<IChemicalHandler, @Nullable Direction>> chemicalHandlerAbove = Collections.emptyList();

@Getter
private MachineEnergyContainer<TileEntityAmbientGasCollector> energyContainer;
@WrappingComputerMethod(wrapper = ComputerIInventorySlotWrapper.class, methodNames = "getChemicalItem", docPlaceholder = "chemical slot")
ChemicalInventorySlot chemicalSlot;
@WrappingComputerMethod(wrapper = ComputerIInventorySlotWrapper.class, methodNames = "getEnergyItem", docPlaceholder = "energy slot")
EnergyInventorySlot energySlot;

public TileEntityAmbientGasCollector(BlockPos pos, BlockState state) {
Expand Down Expand Up @@ -115,26 +121,14 @@ protected boolean onUpdateServer() {
if (canFunction() && (chemicalTank.isEmpty() || estimateIncrementAmount() <= chemicalTank.getNeeded())) {
long energyPerTick = energyContainer.getEnergyPerTick();
if (energyContainer.extract(energyPerTick, Action.SIMULATE, AutomationType.INTERNAL) == energyPerTick) {
if (!activeType.isEmpty()) {
// If we have an active type of fluid, use energy. This can cause there to be ticks where there
// isn't actually
// anything to suck that use energy, but those will balance out with the first set of ticks where it
// doesn't
// use any energy until it actually picks up the first block
clientEnergyUsed = energyContainer.extract(energyPerTick, Action.EXECUTE, AutomationType.INTERNAL);
}
operatingTicks++;
if (operatingTicks >= ticksRequired) {
operatingTicks = 0;
// 判断收集器上方是否是空气
if (suck(worldPosition.relative(Direction.UP))) {
if (clientEnergyUsed == 0L) {
// If it didn't already have an active type (hasn't used energy this tick), then extract
// energy
clientEnergyUsed = energyContainer.extract(energyPerTick, Action.EXECUTE, AutomationType.INTERNAL);
}
} else {
reset();
// If it didn't already have an active type (hasn't used energy this tick), then extract
// energy
clientEnergyUsed = energyContainer.extract(energyPerTick, Action.EXECUTE, AutomationType.INTERNAL);
}
}
}
Expand All @@ -160,7 +154,6 @@ private boolean suck(BlockPos pos) {
Block block = blockState.getBlock();
if (isAir(block)) {
ChemicalStack chemicalStack = new ChemicalStack(MoreMachineChemicals.UNSTABLE_DIMENSIONAL_GAS, estimateIncrementAmount());
activeType = chemicalStack.copyWithAmount(estimateIncrementAmount());
chemicalTank.insert(chemicalStack, Action.EXECUTE, AutomationType.INTERNAL);
return true;
}
Expand All @@ -176,23 +169,10 @@ public boolean getNotBlocking() {
return noBlocking;
}

public void reset() {
activeType = ChemicalStack.EMPTY;
}

@Override
public void saveAdditional(@NotNull CompoundTag nbtTags, HolderLookup.@NotNull Provider provider) {
super.saveAdditional(nbtTags, provider);
if (!activeType.isEmpty()) {
nbtTags.put(SerializationConstants.CHEMICAL, activeType.save(provider));
}
}

@Override
public void loadAdditional(@NotNull CompoundTag nbt, HolderLookup.@NotNull Provider provider) {
super.loadAdditional(nbt, provider);
operatingTicks = nbt.getInt(SerializationConstants.PROGRESS);
NBTUtils.setChemicalStackIfPresent(provider, nbt, SerializationConstants.CHEMICAL, chemical -> activeType = chemical);
}

@Override
Expand Down Expand Up @@ -225,24 +205,14 @@ public List<Component> getInfo(@NotNull Upgrade upgrade) {
return UpgradeUtils.getMultScaledInfo(this, upgrade);
}

public MachineEnergyContainer<TileEntityAmbientGasCollector> getEnergyContainer() {
return energyContainer;
}

public boolean usedEnergy() {
return usedEnergy;
}

@NotNull
public ChemicalStack getActiveType() {
return this.activeType;
}

@Override
public void addContainerTrackers(MekanismContainer container) {
super.addContainerTrackers(container);
container.track(SyncableBoolean.create(this::usedEnergy, value -> usedEnergy = value));
container.track(SyncableBoolean.create(this::getNotBlocking, value -> noBlocking = value));
container.track(SyncableChemicalStack.create(this::getActiveType, value -> activeType = value));
}
}
Loading
Loading