This repository has been archived by the owner on Nov 5, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 32
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
10 changed files
with
160 additions
and
58 deletions.
There are no files selected for viewing
79 changes: 79 additions & 0 deletions
79
common/src/main/java/muramasa/gregtech/cover/base/CoverBasicRedstoneInput.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 muramasa.gregtech.cover.base; | ||
|
||
import muramasa.antimatter.blockentity.BlockEntityMachine; | ||
import muramasa.antimatter.capability.ICoverHandler; | ||
import muramasa.antimatter.cover.BaseCover; | ||
import muramasa.antimatter.cover.CoverFactory; | ||
import muramasa.antimatter.data.AntimatterDefaultTools; | ||
import muramasa.antimatter.machine.MachineState; | ||
import muramasa.antimatter.machine.Tier; | ||
import muramasa.antimatter.tool.AntimatterToolType; | ||
import muramasa.antimatter.util.Utils; | ||
import net.minecraft.core.Direction; | ||
import net.minecraft.nbt.CompoundTag; | ||
import net.minecraft.resources.ResourceLocation; | ||
import net.minecraft.world.InteractionHand; | ||
import net.minecraft.world.InteractionResult; | ||
import net.minecraft.world.entity.player.Player; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
|
||
public class CoverBasicRedstoneInput extends BaseCover { | ||
protected int redstonePower; | ||
boolean inverted = false; | ||
|
||
public CoverBasicRedstoneInput(ICoverHandler<?> source, @Nullable Tier tier, Direction side, CoverFactory factory) { | ||
super(source, tier, side, factory); | ||
} | ||
|
||
public boolean isPowered(){ | ||
return inverted ? redstonePower == 0 : redstonePower > 0; | ||
} | ||
|
||
public int getRedstonePower() { | ||
return redstonePower; | ||
} | ||
|
||
@Override | ||
public void onBlockUpdate() { | ||
redstonePower = handler.getTile().getLevel().getSignal(handler.getTile().getBlockPos().relative(side), side); | ||
} | ||
|
||
@Override | ||
public void onFirstTick() { | ||
onBlockUpdate(); | ||
} | ||
|
||
@Override | ||
public ResourceLocation getModel(String type, Direction dir) { | ||
if (type.equals("pipe")) return PIPE_COVER_MODEL; | ||
return getBasicModel(); | ||
} | ||
|
||
@Override | ||
public InteractionResult onInteract(Player player, InteractionHand hand, Direction side, @Nullable AntimatterToolType type) { | ||
if (type != null && type.getTag() == AntimatterDefaultTools.SCREWDRIVER.getTag()){ | ||
inverted = !inverted; | ||
player.sendMessage(Utils.translatable("message.gti.redstone_mode." + (inverted ? "inverted" : "normal")), player.getUUID()); | ||
for (Direction dir : Direction.values()) { | ||
if (dir == this.side) continue; | ||
source().get(dir).onBlockUpdate(); | ||
} | ||
return InteractionResult.SUCCESS; | ||
} | ||
return super.onInteract(player, hand, side, type); | ||
} | ||
|
||
@Override | ||
public CompoundTag serialize() { | ||
CompoundTag nbt = super.serialize(); | ||
nbt.putBoolean("inverted", inverted); | ||
return nbt; | ||
} | ||
|
||
@Override | ||
public void deserialize(CompoundTag nbt) { | ||
super.deserialize(nbt); | ||
inverted = nbt.getBoolean("inverted"); | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
common/src/main/java/muramasa/gregtech/cover/redstone/CoverRedstoneConductorAccept.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,30 @@ | ||
package muramasa.gregtech.cover.redstone; | ||
|
||
import muramasa.antimatter.capability.ICoverHandler; | ||
import muramasa.antimatter.cover.BaseCover; | ||
import muramasa.antimatter.cover.CoverFactory; | ||
import muramasa.antimatter.machine.Tier; | ||
import muramasa.antimatter.tool.AntimatterToolType; | ||
import muramasa.gregtech.cover.base.CoverBasicRedstoneInput; | ||
import net.minecraft.core.Direction; | ||
import net.minecraft.world.InteractionHand; | ||
import net.minecraft.world.InteractionResult; | ||
import net.minecraft.world.entity.player.Player; | ||
import org.jetbrains.annotations.NotNull; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
public class CoverRedstoneConductorAccept extends CoverBasicRedstoneInput { | ||
public CoverRedstoneConductorAccept(@NotNull ICoverHandler<?> source, @Nullable Tier tier, Direction side, CoverFactory factory) { | ||
super(source, tier, side, factory); | ||
} | ||
|
||
@Override | ||
public boolean isPowered() { | ||
return redstonePower > 0; | ||
} | ||
|
||
@Override | ||
public InteractionResult onInteract(Player player, InteractionHand hand, Direction side, @Nullable AntimatterToolType type) { | ||
return InteractionResult.PASS; | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
common/src/main/java/muramasa/gregtech/cover/redstone/CoverRedstoneConductorEmit.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,39 @@ | ||
package muramasa.gregtech.cover.redstone; | ||
|
||
import muramasa.antimatter.capability.ICoverHandler; | ||
import muramasa.antimatter.cover.CoverFactory; | ||
import muramasa.antimatter.cover.ICover; | ||
import muramasa.antimatter.machine.Tier; | ||
import muramasa.antimatter.tool.AntimatterToolType; | ||
import muramasa.gregtech.cover.base.CoverBasicRedstoneOutput; | ||
import net.minecraft.core.Direction; | ||
import net.minecraft.world.InteractionHand; | ||
import net.minecraft.world.InteractionResult; | ||
import net.minecraft.world.entity.player.Player; | ||
import org.jetbrains.annotations.NotNull; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
public class CoverRedstoneConductorEmit extends CoverBasicRedstoneOutput { | ||
public CoverRedstoneConductorEmit(@NotNull ICoverHandler<?> source, @Nullable Tier tier, Direction side, CoverFactory factory) { | ||
super(source, tier, side, factory); | ||
} | ||
|
||
@Override | ||
public void onUpdate() { | ||
int newPower = 0; | ||
for (Direction direction : Direction.values()) { | ||
if (direction == this.side) continue; | ||
ICover cover = source().get(direction); | ||
if (!(cover instanceof CoverRedstoneConductorAccept accept)) continue; | ||
if (newPower < accept.getRedstonePower()){ | ||
newPower = accept.getRedstonePower(); | ||
} | ||
} | ||
setOutputRedstone(newPower); | ||
} | ||
|
||
@Override | ||
public InteractionResult onInteract(Player player, InteractionHand hand, Direction side, @Nullable AntimatterToolType type) { | ||
return InteractionResult.PASS; | ||
} | ||
} |
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
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
Binary file added
BIN
+344 Bytes
...rc/main/resources/assets/gti/textures/block/cover/redstone_conductor_accept.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
+344 Bytes
.../src/main/resources/assets/gti/textures/block/cover/redstone_conductor_emit.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
+4.37 KB
...src/main/resources/assets/gti/textures/item/basic/redstone_conductor_accept.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
+4.37 KB
...n/src/main/resources/assets/gti/textures/item/basic/redstone_conductor_emit.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.