Skip to content

Commit

Permalink
feat: restrictive filter
Browse files Browse the repository at this point in the history
  • Loading branch information
MCTian-mi committed Dec 22, 2024
1 parent 6dcc0fe commit 6ab7973
Show file tree
Hide file tree
Showing 8 changed files with 94 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
import gregtech.client.renderer.texture.cube.SimpleCubeRenderer;
import gregtech.client.renderer.texture.cube.SimpleOverlayRenderer;
import gregtech.client.renderer.texture.cube.SimpleSidedCubeRenderer;
import supersymmetry.client.renderer.textures.custom.ExtenderRender;
import gregtech.client.renderer.texture.custom.DrumRenderer;
import supersymmetry.client.renderer.textures.custom.ExtenderRender;

public class SusyTextures {

Expand Down Expand Up @@ -84,6 +84,7 @@ public SusyTextures(){
public static final SimpleOverlayRenderer SILICON_CARBIDE_CASING = new SimpleOverlayRenderer("multiblock_casing/silicon_carbide_casing");
public static final SimpleOverlayRenderer ULV_STRUCTURAL_CASING = new SimpleOverlayRenderer("multiblock_casing/ulv_structural_casing");
public static final SimpleOverlayRenderer SLAG_HOT = new SimpleOverlayRenderer("resource/slag_hot");
public static final SimpleOverlayRenderer RESTRICTIVE_FILTER_FILTER_OVERLAY = new SimpleOverlayRenderer("cover/overlay_restrictive_filter");

public static final SimpleCubeRenderer MASONRY_BRICK = new SimpleCubeRenderer("gregtech:blocks/multiblock_casing/masonry_brick");

Expand Down
79 changes: 79 additions & 0 deletions src/main/java/supersymmetry/common/covers/CoverRestrictive.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
package supersymmetry.common.covers;

import codechicken.lib.render.CCRenderState;
import codechicken.lib.render.pipeline.IVertexOperation;
import codechicken.lib.vec.Cuboid6;
import codechicken.lib.vec.Matrix4;
import gregtech.api.capability.impl.ItemHandlerDelegate;
import gregtech.api.cover.CoverBase;
import gregtech.api.cover.CoverDefinition;
import gregtech.api.cover.CoverableView;
import net.minecraft.item.ItemStack;
import net.minecraft.util.BlockRenderLayer;
import net.minecraft.util.EnumFacing;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.items.CapabilityItemHandler;
import net.minecraftforge.items.IItemHandler;
import org.jetbrains.annotations.NotNull;
import supersymmetry.client.renderer.textures.SusyTextures;

public class CoverRestrictive extends CoverBase {

protected ItemHandlerRestrictive itemHandler;

public CoverRestrictive(@NotNull CoverDefinition definition, @NotNull CoverableView coverableView,
@NotNull EnumFacing attachedSide) {
super(definition, coverableView, attachedSide);
}

@Override
public boolean canAttach(@NotNull CoverableView coverable, @NotNull EnumFacing enumFacing) {
return coverable.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, getAttachedSide()) != null;
}

@Override
public <T> T getCapability(@NotNull Capability<T> capability, T defaultValue) {
if (capability == CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) {
if (defaultValue == null) {
return null;
}
IItemHandler delegate = (IItemHandler) defaultValue;
if (itemHandler == null || itemHandler.delegate != delegate) {
this.itemHandler = new ItemHandlerRestrictive(delegate);
}
return CapabilityItemHandler.ITEM_HANDLER_CAPABILITY.cast(itemHandler);
}
return defaultValue;
}

@Override
public boolean canPipePassThrough() {
return true;
}

@Override
public void renderCover(@NotNull CCRenderState renderState, @NotNull Matrix4 translation, @NotNull IVertexOperation[] pipeline,
@NotNull Cuboid6 plateBox, @NotNull BlockRenderLayer renderLayer) {
SusyTextures.RESTRICTIVE_FILTER_FILTER_OVERLAY.renderSided(getAttachedSide(), plateBox, renderState, pipeline, translation);
}

protected static class ItemHandlerRestrictive extends ItemHandlerDelegate {

public ItemHandlerRestrictive(IItemHandler delegate) {
super(delegate);
}

@NotNull
@Override
public ItemStack insertItem(int slot, @NotNull ItemStack stack, boolean simulate) {
if (!stack.isEmpty() && !stack.isItemEqual(delegate.getStackInSlot(slot))) {
for (int i = 0; i < getSlots(); i++) {
if (i != slot && stack.isItemEqual(getStackInSlot(i))) {
return super.insertItem(i, stack, simulate);
}
}
}
return super.insertItem(slot, stack, simulate);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ public static void init() {

registerBehavior(SuSyUtility.susyId("air_vent"), SuSyMetaItems.AIR_VENT,
(definition, coverableView, attachedSide) -> new CoverAirVent(definition, coverableView, attachedSide, 100));

registerBehavior(SuSyUtility.susyId("restrictive_filter"), SuSyMetaItems.RESTRICTIVE_FILTER, CoverRestrictive::new);
}

}
3 changes: 3 additions & 0 deletions src/main/java/supersymmetry/common/item/SuSyMetaItems.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public class SuSyMetaItems {
public static MetaValueItem CONVEYOR_STEAM;
public static MetaValueItem PUMP_STEAM;
public static MetaValueItem AIR_VENT;
public static MetaValueItem RESTRICTIVE_FILTER;
public static MetaValueItem TRACK_SEGMENT;
public static ArmorMetaItem<?>.ArmorMetaValueItem JET_WINGPACK;

Expand Down Expand Up @@ -58,6 +59,8 @@ private static void initMetaItem() {
TRACK_SEGMENT = metaItem.addItem(5, "track_segment").addComponents(new TooltipBehavior((lines) -> {
lines.add(I18n.format("metaitem.track_segment.length_info"));
}));

RESTRICTIVE_FILTER = metaItem.addItem(6, "restrictive_filter");
}

private static void addTieredOredictItem (OreDictValueItem[] items, int id, int RGB, OrePrefix prefix) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"parent" : "item/generated",
"textures" : {
"layer0" : "gregtech:items/metaitems/restrictive_filter"
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions src/main/resources/assets/susy/lang/en_us.lang
Original file line number Diff line number Diff line change
Expand Up @@ -797,6 +797,8 @@ cover.conveyor.steam.title=Steam Conveyor Module
metaitem.pump.steam.name=Steam Pump
cover.pump.steam.title=Steam Pump
metaitem.air_vent.name=Air Vent
metaitem.restrictive_filter.name=Restrictive Filter
metaitem.restrictive_filter.tooltip=§oHere you may come, but no further.§r §7Job 38:11
metaitem.air_vent.tooltip=Passively collects a Dimension's Air for your Machines when facing Air
metaitem.track_segment.name=Monorail Track Segment
metaitem.track_segment.tooltip=For use in the §8tunnelbore.
Expand Down

0 comments on commit 6ab7973

Please sign in to comment.