This repository has been archived by the owner on Oct 4, 2024. It is now read-only.
generated from GregTech-Intergalactical/ExampleMod
-
Notifications
You must be signed in to change notification settings - Fork 2
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
4 changed files
with
135 additions
and
1 deletion.
There are no files selected for viewing
49 changes: 49 additions & 0 deletions
49
...main/java/io/github/gregtechintergalactical/gtcore/behaviour/BlockEntityRedstoneWire.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,49 @@ | ||
package io.github.gregtechintergalactical.gtcore.behaviour; | ||
|
||
import muramasa.antimatter.AntimatterAPI; | ||
import muramasa.antimatter.blockentity.pipe.BlockEntityPipe; | ||
import muramasa.antimatter.capability.ICoverHandler; | ||
import muramasa.antimatter.cover.CoverFactory; | ||
import muramasa.antimatter.cover.CoverPlate; | ||
import muramasa.antimatter.pipe.types.PipeType; | ||
import net.minecraft.core.BlockPos; | ||
import net.minecraft.core.Direction; | ||
import net.minecraft.world.level.block.state.BlockState; | ||
import net.minecraft.world.level.redstone.Redstone; | ||
|
||
public class BlockEntityRedstoneWire<T extends PipeType<T>> extends BlockEntityPipe<T> { | ||
int state = 0; | ||
public BlockEntityRedstoneWire(T type, BlockPos pos, BlockState state) { | ||
super(type, pos, state); | ||
} | ||
|
||
@Override | ||
public CoverFactory[] getValidCovers() { | ||
return AntimatterAPI.all(CoverFactory.class).stream().filter(t -> { | ||
try { | ||
return !t.get().get(ICoverHandler.empty(this), t.getValidTier(), Direction.SOUTH, t).isNode(); | ||
} catch (Exception ex) { | ||
return false; | ||
} | ||
}).toArray(CoverFactory[]::new); | ||
} | ||
|
||
@Override | ||
public Class<?> getCapClass() { | ||
return Redstone.class; | ||
} | ||
|
||
@Override | ||
protected void register() { | ||
|
||
} | ||
|
||
@Override | ||
protected boolean deregister() { | ||
return false; | ||
} | ||
|
||
public int getState() { | ||
return state; | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
common/src/main/java/io/github/gregtechintergalactical/gtcore/block/BlockRedstoneWire.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,40 @@ | ||
package io.github.gregtechintergalactical.gtcore.block; | ||
|
||
import io.github.gregtechintergalactical.gtcore.behaviour.BlockEntityRedstoneWire; | ||
import muramasa.antimatter.Ref; | ||
import muramasa.antimatter.pipe.BlockCable; | ||
import muramasa.antimatter.pipe.BlockPipe; | ||
import muramasa.antimatter.pipe.PipeSize; | ||
import muramasa.antimatter.texture.Texture; | ||
import net.minecraft.core.BlockPos; | ||
import net.minecraft.world.level.BlockGetter; | ||
import net.minecraft.world.level.block.state.BlockState; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
public class BlockRedstoneWire<T extends RedstoneWire<T>> extends BlockPipe<T> { | ||
public BlockRedstoneWire(T type, PipeSize size) { | ||
super(type.getId(), type, size, 2); | ||
String prefix = "wire"; | ||
this.side = new Texture(Ref.ID, "block/pipe/" + prefix + "_side"); | ||
this.faces = new Texture[]{ | ||
new Texture(Ref.ID, "block/pipe/" + prefix + "_vtiny"), | ||
new Texture(Ref.ID, "block/pipe/" + prefix + "_tiny"), | ||
new Texture(Ref.ID, "block/pipe/" + prefix + "_small"), | ||
new Texture(Ref.ID, "block/pipe/" + prefix + "_normal"), | ||
new Texture(Ref.ID, "block/pipe/" + prefix + "_large"), | ||
new Texture(Ref.ID, "block/pipe/" + prefix + "_huge") | ||
}; | ||
} | ||
|
||
@Override | ||
public int getBlockColor(BlockState state, @Nullable BlockGetter world, @Nullable BlockPos pos, int i) { | ||
if (world != null && pos != null){ | ||
if (world.getBlockEntity(pos) instanceof BlockEntityRedstoneWire<?> redstoneWire){ | ||
if (redstoneWire.getState() > 0){ | ||
return getType().getOnColor(); | ||
} | ||
} | ||
} | ||
return super.getBlockColor(state, world, pos, i); | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
common/src/main/java/io/github/gregtechintergalactical/gtcore/block/RedstoneWire.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,44 @@ | ||
package io.github.gregtechintergalactical.gtcore.block; | ||
|
||
import io.github.gregtechintergalactical.gtcore.behaviour.BlockEntityRedstoneWire; | ||
import muramasa.antimatter.blockentity.BlockEntityBase; | ||
import muramasa.antimatter.blockentity.pipe.BlockEntityPipe; | ||
import muramasa.antimatter.material.Material; | ||
import muramasa.antimatter.pipe.BlockCable; | ||
import muramasa.antimatter.pipe.PipeSize; | ||
import muramasa.antimatter.pipe.types.Cable; | ||
import muramasa.antimatter.pipe.types.PipeType; | ||
import muramasa.antimatter.pipe.types.Wire; | ||
import net.minecraft.world.level.block.Block; | ||
|
||
import java.util.Set; | ||
import java.util.stream.Collectors; | ||
|
||
public class RedstoneWire<T extends RedstoneWire<T>> extends PipeType<T> { | ||
int onColor; | ||
|
||
public RedstoneWire(String domain, Material material, int onColor) { | ||
super(domain, material, BlockEntityRedstoneWire::new); | ||
this.onColor = onColor; | ||
sizes(PipeSize.VTINY); | ||
} | ||
|
||
@Override | ||
public String getType() { | ||
return "wire"; | ||
} | ||
|
||
@Override | ||
public Set<Block> getBlocks() { | ||
return sizes.stream().map(s -> new BlockRedstoneWire(this, s)).collect(Collectors.toSet()); | ||
} | ||
|
||
@Override | ||
public String getTypeName() { | ||
return "redstone"; | ||
} | ||
|
||
public int getOnColor() { | ||
return onColor; | ||
} | ||
} |
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