Skip to content
This repository has been archived by the owner on Nov 5, 2024. It is now read-only.

Commit

Permalink
updated antimatter and gt utility, made conveyor and pump covers obse…
Browse files Browse the repository at this point in the history
…rve the filter in the filter slot now
  • Loading branch information
Trinsdar committed Oct 7, 2023
1 parent d384541 commit ef4baf8
Show file tree
Hide file tree
Showing 17 changed files with 136 additions and 41 deletions.
2 changes: 1 addition & 1 deletion AntimatterAPI
Submodule AntimatterAPI updated 21 files
+1 −1 common/gradle.properties
+2 −3 common/src/main/java/muramasa/antimatter/blockentity/BlockEntityMachine.java
+4 −5 common/src/main/java/muramasa/antimatter/blockentity/multi/BlockEntityHatch.java
+3 −3 common/src/main/java/muramasa/antimatter/capability/FluidHandler.java
+4 −4 common/src/main/java/muramasa/antimatter/capability/fluid/FluidTanks.java
+2 −3 common/src/main/java/muramasa/antimatter/capability/item/FakeTrackedItemHandler.java
+5 −8 common/src/main/java/muramasa/antimatter/capability/item/TrackedItemHandler.java
+2 −2 common/src/main/java/muramasa/antimatter/capability/machine/MachineEnergyHandler.java
+8 −13 common/src/main/java/muramasa/antimatter/capability/machine/MachineFluidHandler.java
+3 −3 common/src/main/java/muramasa/antimatter/capability/machine/MachineItemHandler.java
+2 −2 common/src/main/java/muramasa/antimatter/capability/machine/MachineRFHandler.java
+4 −6 common/src/main/java/muramasa/antimatter/capability/machine/MachineRecipeHandler.java
+2 −2 common/src/main/java/muramasa/antimatter/cover/BaseCover.java
+2 −1 common/src/main/java/muramasa/antimatter/cover/CoverOutput.java
+1 −1 common/src/main/java/muramasa/antimatter/cover/ICover.java
+17 −19 common/src/main/java/muramasa/antimatter/gui/SlotType.java
+6 −0 common/src/main/java/muramasa/antimatter/machine/BlockMachine.java
+0 −11 common/src/main/java/muramasa/antimatter/machine/event/ContentEvent.java
+11 −0 common/src/main/java/muramasa/antimatter/machine/types/Machine.java
+1 −1 fabric/gradle.properties
+1 −1 forge/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,10 @@ public long insertFluid(FluidHolder fluid, boolean simulate) {
}
}
if (!tile.tankMachine.isAcidProof() && fluid.getFluid().is(AntimatterTags.ACID)){
tile.getLevel().setBlock(tile.getBlockPos(), Blocks.AIR.defaultBlockState(), 3);
return 16;
if (!simulate) {
tile.getLevel().setBlock(tile.getBlockPos(), Blocks.AIR.defaultBlockState(), 3);
}
return Math.min(16L, fluid.getFluidAmount());
}
return super.insertFluid(fluid, simulate);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import muramasa.antimatter.gui.widget.WidgetSupplier;
import muramasa.antimatter.integration.jeirei.renderer.IInfoRenderer;
import muramasa.antimatter.machine.MachineState;
import muramasa.antimatter.machine.event.ContentEvent;
import muramasa.antimatter.machine.event.IMachineEvent;
import muramasa.antimatter.machine.types.Machine;
import muramasa.antimatter.recipe.IRecipe;
Expand Down Expand Up @@ -72,7 +71,7 @@ public void checkRecipe() {
@Override
public void onMachineEvent(IMachineEvent event, Object... data) {
super.onMachineEvent(event, data);
if (event == ContentEvent.ITEM_INPUT_CHANGED){
if (event == SlotType.IT_IN){
ItemStack stack = itemHandler.map(i -> i.getHandler(SlotType.STORAGE).getStackInSlot(0)).orElse(ItemStack.EMPTY);
ItemTurbineRotor rotor = stack.getItem() instanceof ItemTurbineRotor rotor1 ? rotor1 : null;
if (rotor == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,11 @@
import muramasa.antimatter.gui.SlotType;
import muramasa.antimatter.gui.event.GuiEvents;
import muramasa.antimatter.gui.event.IGuiEvent;
import muramasa.antimatter.machine.event.ContentEvent;
import muramasa.antimatter.machine.types.Machine;
import muramasa.antimatter.tool.AntimatterToolType;
import muramasa.antimatter.util.AntimatterPlatformUtils;
import muramasa.antimatter.util.Utils;
import muramasa.gregtech.data.Machines;
import muramasa.gregtech.data.SlotTypes;
import muramasa.gregtech.gui.ButtonOverlays;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
Expand Down Expand Up @@ -189,7 +187,7 @@ public static class BufferItemHandler extends MachineItemHandler<BlockEntityBuff
public BufferItemHandler(BlockEntityBuffer tile) {
super(tile);
int count = tile.getMachineType() == Machines.SUPER_BUFFER ? 256 : tile.getMachineType().getCount(tile.getMachineTier(), SlotType.STORAGE);
this.inventories.put(SlotType.STORAGE, new TrackedItemHandler<>(tile, SlotType.STORAGE, count, true, true, (t, s) -> true, ContentEvent.ITEM_INPUT_CHANGED){
this.inventories.put(SlotType.STORAGE, new TrackedItemHandler<>(tile, SlotType.STORAGE, count, true, true, (t, s) -> true){
@NotNull
@Override
public ItemStack extractItem(int slot, int amount, boolean simulate) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
import muramasa.antimatter.capability.fluid.FluidTanks;
import muramasa.antimatter.capability.machine.MachineFluidHandler;
import muramasa.antimatter.capability.machine.MachineRecipeHandler;
import muramasa.antimatter.gui.SlotType;
import muramasa.antimatter.machine.MachineState;
import muramasa.antimatter.machine.event.ContentEvent;
import muramasa.antimatter.machine.types.Machine;
import muramasa.antimatter.blockentity.BlockEntityMachine;
import muramasa.antimatter.util.Utils;
Expand Down Expand Up @@ -267,11 +267,11 @@ public static class CoalBoilerFluidHandler extends MachineFluidHandler<BlockEnti

public CoalBoilerFluidHandler(BlockEntityCoalBoiler tile) {
super(tile, 16000, 1000 * (250 + tile.getMachineTier().getIntegerId()));
tanks.put(FluidDirection.INPUT, FluidTanks.create(tile, ContentEvent.FLUID_INPUT_CHANGED, b -> {
tanks.put(FluidDirection.INPUT, FluidTanks.create(tile, SlotType.FL_IN, b -> {
b.tank(16000);
return b;
}));
tanks.put(FluidDirection.OUTPUT, FluidTanks.create(tile, ContentEvent.FLUID_OUTPUT_CHANGED, b -> {
tanks.put(FluidDirection.OUTPUT, FluidTanks.create(tile, SlotType.FL_OUT, b -> {
b.tank(16000);
return b;
}));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import muramasa.antimatter.capability.machine.MachineFluidHandler;
import muramasa.antimatter.cover.CoverOutput;
import muramasa.antimatter.cover.ICover;
import muramasa.antimatter.machine.event.ContentEvent;
import muramasa.antimatter.gui.SlotType;
import muramasa.antimatter.machine.types.Machine;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
Expand Down Expand Up @@ -77,7 +77,7 @@ protected static class InfiniteFluidHandler extends MachineFluidHandler<BlockEnt

public InfiniteFluidHandler(BlockEntityInfiniteFluid tile) {
super(tile);
tanks.put(FluidDirection.OUTPUT, FluidTanks.create(tile, ContentEvent.FLUID_OUTPUT_CHANGED, b -> {
tanks.put(FluidDirection.OUTPUT, FluidTanks.create(tile, SlotType.FL_OUT, b -> {
b.tank(Integer.MAX_VALUE);
return b;
}));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import muramasa.antimatter.gui.SlotType;
import muramasa.antimatter.gui.event.GuiEvents;
import muramasa.antimatter.gui.event.IGuiEvent;
import muramasa.antimatter.machine.event.ContentEvent;
import muramasa.antimatter.machine.event.IMachineEvent;
import muramasa.antimatter.machine.types.Machine;
import muramasa.antimatter.util.AntimatterPlatformUtils;
Expand Down Expand Up @@ -122,7 +121,7 @@ public void serverTick(Level level, BlockPos pos, BlockState state) {
@Override
public void onMachineEvent(IMachineEvent event, Object... data) {
super.onMachineEvent(event, data);
if ((event == ContentEvent.ITEM_OUTPUT_CHANGED || event == ContentEvent.ITEM_INPUT_CHANGED) && outputRedstone && !this.getLevel().isClientSide()){
if ((event == SlotType.IT_OUT || event == SlotType.IT_IN) && outputRedstone && !this.getLevel().isClientSide()){
// level.updateNeighborsAt(this.getBlockPos(), this.getBlockState().getBlock());
AntimatterPlatformUtils.markAndNotifyBlock(level, this.getBlockPos(), this.level.getChunkAt(this.getBlockPos()), this.getBlockState(), this.getBlockState(), 1, 512);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import muramasa.antimatter.capability.fluid.FluidTanks;
import muramasa.antimatter.capability.machine.MachineFluidHandler;
import muramasa.antimatter.capability.machine.MachineRecipeHandler;
import muramasa.antimatter.machine.event.ContentEvent;
import muramasa.antimatter.gui.SlotType;
import muramasa.antimatter.machine.types.Machine;
import muramasa.antimatter.util.Utils;
import net.minecraft.core.BlockPos;
Expand Down Expand Up @@ -189,12 +189,12 @@ public void deserialize(CompoundTag nbt) {
public static class LavaBoilerFluidHandler extends MachineFluidHandler<BlockEntityLavaBoiler> {
public LavaBoilerFluidHandler(BlockEntityLavaBoiler tile) {
super(tile, 16000, 1000 * (250 + tile.getMachineTier().getIntegerId()));
tanks.put(FluidDirection.INPUT, FluidTanks.create(tile, ContentEvent.FLUID_INPUT_CHANGED, b -> {
tanks.put(FluidDirection.INPUT, FluidTanks.create(tile, SlotType.FL_IN, b -> {
b.tank(p -> p.getFluid() == Fluids.WATER || p.getFluid() == DistilledWater.getLiquid(), 16000)
.tank(p -> p.getFluid() == Fluids.LAVA, 16000);
return b;
}));
tanks.put(FluidDirection.OUTPUT, FluidTanks.create(tile, ContentEvent.FLUID_OUTPUT_CHANGED, b -> {
tanks.put(FluidDirection.OUTPUT, FluidTanks.create(tile, SlotType.FL_OUT, b -> {
b.tank(16000);
return b;
}));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import muramasa.antimatter.capability.fluid.FluidTanks;
import muramasa.antimatter.capability.machine.MachineFluidHandler;
import muramasa.antimatter.capability.machine.MachineRecipeHandler;
import muramasa.antimatter.machine.event.ContentEvent;
import muramasa.antimatter.gui.SlotType;
import muramasa.antimatter.machine.types.Machine;
import muramasa.antimatter.blockentity.BlockEntityMachine;
import muramasa.antimatter.util.Utils;
Expand Down Expand Up @@ -179,11 +179,11 @@ public void deserialize(CompoundTag nbt) {
public static class LavaBoilerFluidHandler extends MachineFluidHandler<BlockEntitySolarBoiler> {
public LavaBoilerFluidHandler(BlockEntitySolarBoiler tile) {
super(tile, 16000, 1000 * (250 + tile.getMachineTier().getIntegerId()));
tanks.put(FluidDirection.INPUT, FluidTanks.create(tile, ContentEvent.FLUID_INPUT_CHANGED, b -> {
tanks.put(FluidDirection.INPUT, FluidTanks.create(tile, SlotType.FL_IN, b -> {
b.tank(p -> p.getFluid() == Fluids.WATER || p.getFluid() == DistilledWater.getLiquid(), 16000);
return b;
}));
tanks.put(FluidDirection.OUTPUT, FluidTanks.create(tile, ContentEvent.FLUID_OUTPUT_CHANGED, b -> {
tanks.put(FluidDirection.OUTPUT, FluidTanks.create(tile, SlotType.FL_OUT, b -> {
b.tank(16000);
return b;
}));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import earth.terrarium.botarium.common.fluid.base.FluidHolder;
import muramasa.antimatter.blockentity.BlockEntityMachine;
import muramasa.antimatter.capability.machine.MachineRecipeHandler;
import muramasa.antimatter.gui.SlotType;
import muramasa.antimatter.machine.Tier;
import muramasa.antimatter.machine.event.ContentEvent;
import muramasa.antimatter.machine.event.IMachineEvent;
import muramasa.antimatter.machine.types.Machine;
import muramasa.antimatter.recipe.IRecipe;
Expand Down Expand Up @@ -88,12 +88,10 @@ protected boolean consumeGeneratorResources(boolean simulate) {
@Override
public void onMachineEvent(IMachineEvent event, Object... data) {
super.onMachineEvent(event, data);
if (event instanceof ContentEvent) {
if (event == ContentEvent.FLUID_INPUT_CHANGED) {
if (data != null && data.length > 0) {
if (data[0] instanceof FluidHolder && ((FluidHolder)data[0]).getFluid().builtInRegistryHolder().is(GregTechTags.STEAM)) {
checkRecipe();
}
if (event == SlotType.FL_IN) {
if (data != null && data.length > 0) {
if (data[0] instanceof FluidHolder && ((FluidHolder) data[0]).getFluid().builtInRegistryHolder().is(GregTechTags.STEAM)) {
checkRecipe();
}
}
}
Expand Down
47 changes: 41 additions & 6 deletions common/src/main/java/muramasa/gregtech/cover/CoverConveyor.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@

import com.google.common.collect.ImmutableMap;
import muramasa.antimatter.AntimatterAPI;
import muramasa.antimatter.blockentity.BlockEntityMachine;
import muramasa.antimatter.capability.ICoverHandler;
import muramasa.antimatter.capability.IGuiHandler;
import muramasa.antimatter.cover.CoverFactory;
import muramasa.antimatter.gui.*;
import muramasa.antimatter.gui.event.IGuiEvent;
import muramasa.antimatter.machine.Tier;
import muramasa.antimatter.machine.event.IMachineEvent;
import muramasa.antimatter.util.Utils;
import muramasa.gregtech.cover.base.CoverBasicTransport;
import muramasa.gregtech.data.GregTechData;
Expand Down Expand Up @@ -37,6 +40,7 @@ public class CoverConveyor extends CoverBasicTransport implements IFilterable {
public static String ID = "conveyor";

private boolean extracting = true;
private final CoverItemFilter filter;

public static final Map<Tier, Integer> speeds = ImmutableMap.<Tier, Integer>builder().
put(Tier.LV, 400)
Expand All @@ -47,6 +51,8 @@ public class CoverConveyor extends CoverBasicTransport implements IFilterable {

public CoverConveyor(ICoverHandler<?> source, @Nullable Tier tier, Direction side, CoverFactory factory) {
super(source, tier, side, factory);
this.filter = new CoverItemFilter(source, null, side, GregTechData.COVER_ITEM_FILTER);
filter.onCreate();
Objects.requireNonNull(tier);
this.gui.getSlots().add(SlotTypes.FILTERABLE, 79, 53);
}
Expand All @@ -55,12 +61,7 @@ public CoverConveyor(ICoverHandler<?> source, @Nullable Tier tier, Direction sid
@Override
public boolean onTransfer(Object object, boolean inputSide, boolean simulate) {
if (object instanceof ItemStack stack){
ItemStack compare = getInventory(SlotTypes.FILTERABLE).getItem(0);
if (compare.hasTag()){
CompoundTag nbt = compare.getTag();
boolean blacklist = nbt.getBoolean("blacklist");

}
return filter.onTransfer(stack, inputSide, simulate);
}
return super.onTransfer(object, inputSide, simulate);
}
Expand Down Expand Up @@ -135,4 +136,38 @@ protected boolean canMove(Direction side){
public boolean accepts(ItemStack stack) {
return stack.getItem() == GregTechData.COVER_ITEM_FILTER.getItem().getItem();
}

@Override
public void onMachineEvent(IGuiHandler tile, IMachineEvent event, int... data) {
if (tile == this && event == SlotTypes.FILTERABLE){
ItemStack slotStack = getInventory(SlotTypes.FILTERABLE).getItem(data[0]);
if (slotStack.isEmpty()){
filter.clearFilter();
} else {
filter.addInfoFromStack(slotStack);
}
}
super.onMachineEvent(tile, event, data);
}

@Override
public void addInfoFromStack(ItemStack stack) {
super.addInfoFromStack(stack);
onMachineEvent(this, SlotTypes.FILTERABLE, 0);
}

@Override
public void deserialize(CompoundTag nbt) {
super.deserialize(nbt);
if (nbt.contains("filter")) {
filter.deserialize(nbt.getCompound("filter"));
}
}

@Override
public CompoundTag serialize() {
CompoundTag nbt = super.serialize();
nbt.put("filter", filter.serialize());
return nbt;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,20 @@ public CoverFluidFilter(@NotNull ICoverHandler<?> source, @Nullable Tier tier, D
super(source, tier, side, factory);
getGui().getSlots().add(SlotType.DISPLAY_SETTABLE, 80, 25);
}
@Override
public void clearFilter(){
super.clearFilter();
getInventory(SlotType.DISPLAY_SETTABLE).clearContent();
}

@Override
public <T> boolean blocksCapability(Class<T> cap, @Nullable Direction side) {
return false;
}

@Override
public boolean onTransfer(Object object, boolean inputSide, boolean execute) {
super.onTransfer(object, inputSide, execute);
public boolean onTransfer(Object object, boolean inputSide, boolean simulate) {
super.onTransfer(object, inputSide, simulate);
if (object instanceof FluidHolder fluidHolder) {
ItemStack filter = getInventory(SlotType.DISPLAY_SETTABLE).getItem(0);
boolean empty = filter.isEmpty() || FluidHooks.safeGetItemFluidManager(filter).map(f -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,20 @@ public CoverItemFilter(@NotNull ICoverHandler<?> source, @Nullable Tier tier, Di
getGui().getSlots().add(SlotType.DISPLAY_SETTABLE, 80, 25);
}

@Override
public void clearFilter(){
super.clearFilter();
getInventory(SlotType.DISPLAY_SETTABLE).clearContent();
}

@Override
public <T> boolean blocksCapability(Class<T> cap, @Nullable Direction side) {
return false;
}

@Override
public boolean onTransfer(Object object, boolean inputSide, boolean execute) {
super.onTransfer(object, inputSide, execute);
public boolean onTransfer(Object object, boolean inputSide, boolean simulate) {
super.onTransfer(object, inputSide, simulate);
if (object instanceof ItemStack item) {
ItemStack filter = getInventory(SlotType.DISPLAY_SETTABLE).getItem(0);
boolean empty = filter.isEmpty();
Expand Down
Loading

0 comments on commit ef4baf8

Please sign in to comment.