Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…e crash; also add empty/fill sounds
  • Loading branch information
Technici4n committed Jun 25, 2022
1 parent 0c579cb commit c5d7ba4
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

import org.jetbrains.annotations.Nullable;

import net.minecraft.sounds.SoundEvents;
import net.minecraft.sounds.SoundSource;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.inventory.AbstractContainerMenu;
import net.minecraft.world.item.ItemStack;
Expand Down Expand Up @@ -115,10 +117,12 @@ public long insert(Context context, MekanismKey what, long amount, Actionable mo

@Override
public void playFillSound(Player player, MekanismKey what) {
player.playNotifySound(SoundEvents.BUCKET_FILL, SoundSource.PLAYERS, 1.0F, 1.0F);
}

@Override
public void playEmptySound(Player player, MekanismKey what) {
player.playNotifySound(SoundEvents.BUCKET_EMPTY, SoundSource.PLAYERS, 1.0F, 1.0F);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,16 @@
import appeng.api.behaviors.GenericInternalInventory;
import appeng.api.config.Actionable;

@SuppressWarnings("UnstableApiUsage")
public abstract sealed class GenericStackChemicalStorage<C extends Chemical<C>, S extends ChemicalStack<C>>
implements IChemicalHandler<C, S> {

private final GenericInternalInventory inv;
private final byte form;

private GenericStackChemicalStorage(GenericInternalInventory inv) {
private GenericStackChemicalStorage(GenericInternalInventory inv, byte form) {
this.inv = inv;
this.form = form;
}

@Override
Expand All @@ -37,7 +40,7 @@ public int getTanks() {

@Override
public S getChemicalInTank(int tank) {
if (inv.getKey(tank)instanceof MekanismKey what) {
if (inv.getKey(tank)instanceof MekanismKey what && what.getForm() == form) {
return (S) ChemicalBridge.withAmount(what.getStack(), inv.getAmount(tank));
}

Expand Down Expand Up @@ -80,7 +83,7 @@ public S insertChemical(int tank, S stack, Action action) {

@Override
public S extractChemical(int tank, long amount, Action action) {
if (!(inv.getKey(tank)instanceof MekanismKey what)) {
if (!(inv.getKey(tank)instanceof MekanismKey what) || what.getForm() != form) {
return getEmptyStack();
}

Expand All @@ -95,28 +98,28 @@ public S extractChemical(int tank, long amount, Action action) {

public static final class OfGas extends GenericStackChemicalStorage<Gas, GasStack> implements IGasHandler {
public OfGas(GenericInternalInventory inv) {
super(inv);
super(inv, MekanismKey.GAS);
}
}

public static final class OfInfusion extends GenericStackChemicalStorage<InfuseType, InfusionStack>
implements IInfusionHandler {
public OfInfusion(GenericInternalInventory inv) {
super(inv);
super(inv, MekanismKey.INFUSION);
}
}

public static final class OfPigment extends GenericStackChemicalStorage<Pigment, PigmentStack>
implements IPigmentHandler {
public OfPigment(GenericInternalInventory inv) {
super(inv);
super(inv, MekanismKey.PIGMENT);
}
}

public static final class OfSlurry extends GenericStackChemicalStorage<Slurry, SlurryStack>
implements ISlurryHandler {
public OfSlurry(GenericInternalInventory inv) {
super(inv);
super(inv, MekanismKey.SLURRY);
}
}
}

0 comments on commit c5d7ba4

Please sign in to comment.