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

Commit

Permalink
started work on redstone wires
Browse files Browse the repository at this point in the history
  • Loading branch information
Trinsdar committed Mar 18, 2024
1 parent 659fb81 commit e71fbf7
Show file tree
Hide file tree
Showing 4 changed files with 135 additions and 1 deletion.
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;
}
}
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);
}
}
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;
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package io.github.gregtechintergalactical.gtcore.data;

import io.github.gregtechintergalactical.gtcore.GTCore;
import io.github.gregtechintergalactical.gtcore.block.RedstoneWire;
import muramasa.antimatter.AntimatterAPI;
import muramasa.antimatter.data.AntimatterMaterials;
import muramasa.antimatter.machine.Tier;
Expand All @@ -17,7 +18,7 @@ public class GTCoreCables {
public static final SubTag TIN_WIRE = new SubTag("tin_wire");

public static final SubTag TIN_CABLE = new SubTag("tin_cable");
public static final Wire<?> WIRE_RED_ALLOY = AntimatterAPI.register(Wire.class, new Wire<>(GTCore.ID, RedAlloy, 1, Tier.ULV).amps(1));
public static final RedstoneWire<?> WIRE_RED_ALLOY = AntimatterAPI.register(RedstoneWire.class, new RedstoneWire<>(GTCore.ID, RedAlloy, 0xd00000));

public static void init(){
WIRE.subTag(TIN_WIRE, Tin);
Expand Down

0 comments on commit e71fbf7

Please sign in to comment.