-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
94 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
79 changes: 79 additions & 0 deletions
79
src/main/java/supersymmetry/common/covers/CoverRestrictive.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
src/main/resources/assets/gregtech/models/item/metaitems/restrictive_filter.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"parent" : "item/generated", | ||
"textures" : { | ||
"layer0" : "gregtech:items/metaitems/restrictive_filter" | ||
} | ||
} |
Binary file added
BIN
+1.9 KB
.../resources/assets/gregtech/textures/blocks/cover/overlay_restrictive_filter.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+1.9 KB
src/main/resources/assets/gregtech/textures/items/metaitems/restrictive_filter.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters