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

Commit

Permalink
made filter coers change texture based off whether it's set to blackl…
Browse files Browse the repository at this point in the history
…ist or whitelist
  • Loading branch information
Trinsdar committed Aug 1, 2024
1 parent 01e9dec commit 32d14d2
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import earth.terrarium.botarium.common.fluid.base.FluidHolder;
import earth.terrarium.botarium.common.fluid.utils.FluidHooks;
import muramasa.antimatter.blockentity.BlockEntityBase;
import muramasa.antimatter.blockentity.BlockEntityMachine;
import muramasa.antimatter.blockentity.pipe.BlockEntityPipe;
import muramasa.antimatter.capability.ICoverHandler;
Expand Down Expand Up @@ -47,7 +48,9 @@ public void onGuiEvent(IGuiEvent event, Player playerEntity) {
GuiEvents.GuiEvent ev = (GuiEvents.GuiEvent) event;
if (ev.data[1] == 0){
blacklist = !blacklist;
this.handler.getTile().setChanged();
if (this.handler.getTile() instanceof BlockEntityBase<?> base){
base.sidedSync(true);
}
} else if (ev.data[1] == 1){
if (filterMode == 0){
filterMode = 1;
Expand All @@ -56,7 +59,9 @@ public void onGuiEvent(IGuiEvent event, Player playerEntity) {
} else {
filterMode = 0;
}
this.handler.getTile().setChanged();
if (this.handler.getTile() instanceof BlockEntityBase<?> base){
base.sidedSync(true);
}
}
}
}
Expand Down
13 changes: 10 additions & 3 deletions common/src/main/java/muramasa/gregtech/cover/CoverItemFilter.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package muramasa.gregtech.cover;

import muramasa.antimatter.blockentity.BlockEntityBase;
import muramasa.antimatter.blockentity.BlockEntityMachine;
import muramasa.antimatter.blockentity.pipe.BlockEntityItemPipe;
import muramasa.antimatter.blockentity.pipe.BlockEntityPipe;
Expand Down Expand Up @@ -86,10 +87,14 @@ public void onGuiEvent(IGuiEvent event, Player playerEntity) {
GuiEvents.GuiEvent ev = (GuiEvents.GuiEvent) event;
if (ev.data[1] == 0){
blacklist = !blacklist;
this.handler.getTile().setChanged();
if (this.handler.getTile() instanceof BlockEntityBase<?> base){
base.sidedSync(true);
}
} else if (ev.data[1] == 1){
ignoreNBT = !ignoreNBT;
this.handler.getTile().setChanged();
if (this.handler.getTile() instanceof BlockEntityBase<?> base){
base.sidedSync(true);
}
} else if (ev.data[1] == 2){
if (filterMode == 0){
filterMode = 1;
Expand All @@ -98,7 +103,9 @@ public void onGuiEvent(IGuiEvent event, Player playerEntity) {
} else {
filterMode = 0;
}
this.handler.getTile().setChanged();
if (this.handler.getTile() instanceof BlockEntityBase<?> base){
base.sidedSync(true);
}
}
}
}
Expand Down
18 changes: 18 additions & 0 deletions common/src/main/java/muramasa/gregtech/cover/base/CoverFilter.java
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
package muramasa.gregtech.cover.base;

import muramasa.antimatter.capability.CoverHandler;
import muramasa.antimatter.capability.ICoverHandler;
import muramasa.antimatter.cover.BaseCover;
import muramasa.antimatter.cover.CoverFactory;
import muramasa.antimatter.machine.Tier;
import muramasa.antimatter.texture.Texture;
import net.minecraft.core.Direction;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.world.item.ItemStack;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.function.BiConsumer;

public class CoverFilter extends BaseCover {
protected boolean blacklist = false;
protected boolean ignoreNBT = false;
Expand Down Expand Up @@ -57,10 +61,24 @@ public void deserialize(CompoundTag nbt) {
this.blacklist = nbt.getBoolean("blacklist");
this.ignoreNBT = nbt.getBoolean("ignoreNBT");
this.filterMode = nbt.getByte("filterMode");
if (this.handler.getTile().getLevel() != null && this.handler.getTile().getLevel().isClientSide()) {
if (this.handler instanceof CoverHandler<?> coverHandler && coverHandler.coverTexturer != null && coverHandler.coverTexturer.get(this.side) != null){
coverHandler.coverTexturer.get(this.side).invalidate();
}
}
}

@Override
public void onUpdate() {
super.onUpdate();
}

@Override
public void setTextures(BiConsumer<String, Texture> texer) {
if (factory.getTextures().size() == 2){
texer.accept("overlay", factory.getTextures().get(blacklist ? 1 : 0));
} else {
super.setTextures(texer);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public class GregTechCovers {
}
}
}
}).tip("Can be placed as cover")).addTextures(new Texture(GTIRef.ID, "block/cover/item_filter")).gui().build(GTIRef.ID, "item_filter");
}).tip("Can be placed as cover")).addTextures(new Texture(GTIRef.ID, "block/cover/item_filter"), new Texture(GTIRef.ID, "block/cover/item_filter_inverted")).gui().build(GTIRef.ID, "item_filter");
public static final CoverFactory COVER_FLUID_FILTER = CoverFactory.builder(CoverFluidFilter::new).item((a, b) ->
new ItemCoverCustomTooltip(GTIRef.ID, "fluid_filter", (stack, world, tooltip, flag) -> {
CompoundTag nbt = stack.getTag();
Expand All @@ -76,7 +76,7 @@ public class GregTechCovers {
}
}
}
}).tip("Can be placed as cover")).addTextures(new Texture(GTIRef.ID, "block/cover/fluid_filter")).gui().build(GTIRef.ID, "fluid_filter");
}).tip("Can be placed as cover")).addTextures(new Texture(GTIRef.ID, "block/cover/fluid_filter"),new Texture(GTIRef.ID, "block/cover/fluid_filter_inverted")).gui().build(GTIRef.ID, "fluid_filter");
public static final CoverFactory COVER_REDSTONE_MACHINE_CONTROLLER = CoverFactory.builder(CoverRedstoneMachineController::new).item((a, b) -> {
return new ItemCover(GTIRef.ID, "redstone_machine_controller");
}).addTextures(new Texture(GTIRef.ID, "block/cover/redstone_machine_controller")).build(GTIRef.ID, "redstone_machine_controller");
Expand Down

0 comments on commit 32d14d2

Please sign in to comment.