From f6ecfac78b963a694a13891df06413df104b19fb Mon Sep 17 00:00:00 2001 From: Kyle Gunger Date: Fri, 17 Nov 2023 01:20:36 -0500 Subject: Update for 1.20 --- .../java/net/corechg/sparkt/BlockRegister.java | 31 ------- src/main/java/net/corechg/sparkt/SparktInit.java | 19 ---- .../net/corechg/sparkt/block/DriverMechanical.java | 9 -- .../net/corechg/sparkt/block/MachineBlock.java | 12 --- .../net/corechg/sparkt/block/MachineFurnace.java | 9 -- .../net/corechg/sparkt/block/MachineGrinder.java | 9 -- src/main/java/net/corechg/sparkt/block/Wire.java | 11 --- .../sparkt/block/entity/MachineFurnaceEntity.java | 102 --------------------- src/main/java/net/cshift/sparkt/SparktInit.java | 22 +++++ src/main/java/net/cshift/sparkt/block/Blocks.java | 32 +++++++ .../net/cshift/sparkt/block/DriverMechanical.java | 9 ++ .../java/net/cshift/sparkt/block/MachineBlock.java | 28 ++++++ .../net/cshift/sparkt/block/MachineFurnace.java | 9 ++ .../net/cshift/sparkt/block/MachineGrinder.java | 9 ++ src/main/java/net/cshift/sparkt/block/Wire.java | 11 +++ .../sparkt/block/entity/BlockEntityTypes.java | 22 +++++ .../sparkt/block/entity/MachineFurnaceEntity.java | 61 ++++++++++++ .../cshift/sparkt/block/entity/MachineNode.java | 59 ++++++++++++ src/main/resources/fabric.mod.json | 14 +-- 19 files changed, 269 insertions(+), 209 deletions(-) delete mode 100644 src/main/java/net/corechg/sparkt/BlockRegister.java delete mode 100644 src/main/java/net/corechg/sparkt/SparktInit.java delete mode 100644 src/main/java/net/corechg/sparkt/block/DriverMechanical.java delete mode 100644 src/main/java/net/corechg/sparkt/block/MachineBlock.java delete mode 100644 src/main/java/net/corechg/sparkt/block/MachineFurnace.java delete mode 100644 src/main/java/net/corechg/sparkt/block/MachineGrinder.java delete mode 100644 src/main/java/net/corechg/sparkt/block/Wire.java delete mode 100644 src/main/java/net/corechg/sparkt/block/entity/MachineFurnaceEntity.java create mode 100644 src/main/java/net/cshift/sparkt/SparktInit.java create mode 100644 src/main/java/net/cshift/sparkt/block/Blocks.java create mode 100644 src/main/java/net/cshift/sparkt/block/DriverMechanical.java create mode 100644 src/main/java/net/cshift/sparkt/block/MachineBlock.java create mode 100644 src/main/java/net/cshift/sparkt/block/MachineFurnace.java create mode 100644 src/main/java/net/cshift/sparkt/block/MachineGrinder.java create mode 100644 src/main/java/net/cshift/sparkt/block/Wire.java create mode 100644 src/main/java/net/cshift/sparkt/block/entity/BlockEntityTypes.java create mode 100644 src/main/java/net/cshift/sparkt/block/entity/MachineFurnaceEntity.java create mode 100644 src/main/java/net/cshift/sparkt/block/entity/MachineNode.java (limited to 'src') diff --git a/src/main/java/net/corechg/sparkt/BlockRegister.java b/src/main/java/net/corechg/sparkt/BlockRegister.java deleted file mode 100644 index 5833055..0000000 --- a/src/main/java/net/corechg/sparkt/BlockRegister.java +++ /dev/null @@ -1,31 +0,0 @@ -package net.corechg.sparkt; - -import net.minecraft.block.Block; -import net.minecraft.item.BlockItem; -import net.minecraft.item.Item; -import net.minecraft.util.Identifier; -import net.minecraft.util.registry.Registry; -import net.corechg.sparkt.block.*; - -public class BlockRegister { - - public static final Block MACHINE_BLOCK = new MachineBlock(); - public static final Block MACHINE_FURNACE = new MachineFurnace(); - public static final Block DRIVER_MECHANICAL = new DriverMechanical(); - public static final Block MACHINE_GRINDER = new MachineGrinder(); - //public static final Block - - public static void register(String modid) { - Registry.register(Registry.BLOCK, new Identifier(modid, "machine_block"), MACHINE_BLOCK); - Registry.register(Registry.ITEM, new Identifier(modid, "machine_block"), new BlockItem(MACHINE_BLOCK, new Item.Settings())); - - Registry.register(Registry.BLOCK, new Identifier(modid, "machine_furnace"), MACHINE_FURNACE); - Registry.register(Registry.ITEM, new Identifier(modid, "machine_furnace"), new BlockItem(MACHINE_FURNACE, new Item.Settings())); - - Registry.register(Registry.BLOCK, new Identifier(modid, "driver_mechanical"), DRIVER_MECHANICAL); - Registry.register(Registry.ITEM, new Identifier(modid, "driver_mechanical"), new BlockItem(DRIVER_MECHANICAL, new Item.Settings())); - - Registry.register(Registry.BLOCK, new Identifier(modid, "machine_grinder"), MACHINE_GRINDER); - Registry.register(Registry.ITEM, new Identifier(modid, "machine_grinder"), new BlockItem(MACHINE_GRINDER, new Item.Settings())); - } -} \ No newline at end of file diff --git a/src/main/java/net/corechg/sparkt/SparktInit.java b/src/main/java/net/corechg/sparkt/SparktInit.java deleted file mode 100644 index 2d2d557..0000000 --- a/src/main/java/net/corechg/sparkt/SparktInit.java +++ /dev/null @@ -1,19 +0,0 @@ -package net.corechg.sparkt; - -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; - -import net.fabricmc.api.ModInitializer; - -public class SparktInit implements ModInitializer { - - public static final Logger LOG = LogManager.getFormatterLogger("Sparkt|Init"); - public static final String MODID = "sparkt"; - - @Override - public void onInitialize() { - LOG.info("Preparing to spark a reaction!"); - BlockRegister.register(MODID); - } - -} \ No newline at end of file diff --git a/src/main/java/net/corechg/sparkt/block/DriverMechanical.java b/src/main/java/net/corechg/sparkt/block/DriverMechanical.java deleted file mode 100644 index 3198120..0000000 --- a/src/main/java/net/corechg/sparkt/block/DriverMechanical.java +++ /dev/null @@ -1,9 +0,0 @@ -package net.corechg.sparkt.block; - -public class DriverMechanical extends MachineBlock{ - - public DriverMechanical() { - super(); - } - -} \ No newline at end of file diff --git a/src/main/java/net/corechg/sparkt/block/MachineBlock.java b/src/main/java/net/corechg/sparkt/block/MachineBlock.java deleted file mode 100644 index 7e0c7bb..0000000 --- a/src/main/java/net/corechg/sparkt/block/MachineBlock.java +++ /dev/null @@ -1,12 +0,0 @@ -package net.corechg.sparkt.block; - -import net.minecraft.block.Block; -import net.minecraft.block.Material; - -public class MachineBlock extends Block{ - - public MachineBlock() { - super(Settings.of(Material.METAL)); - } - -} \ No newline at end of file diff --git a/src/main/java/net/corechg/sparkt/block/MachineFurnace.java b/src/main/java/net/corechg/sparkt/block/MachineFurnace.java deleted file mode 100644 index f7556ca..0000000 --- a/src/main/java/net/corechg/sparkt/block/MachineFurnace.java +++ /dev/null @@ -1,9 +0,0 @@ -package net.corechg.sparkt.block; - -public class MachineFurnace extends MachineBlock{ - - public MachineFurnace() { - super(); - } - -} \ No newline at end of file diff --git a/src/main/java/net/corechg/sparkt/block/MachineGrinder.java b/src/main/java/net/corechg/sparkt/block/MachineGrinder.java deleted file mode 100644 index 49c877d..0000000 --- a/src/main/java/net/corechg/sparkt/block/MachineGrinder.java +++ /dev/null @@ -1,9 +0,0 @@ -package net.corechg.sparkt.block; - -public class MachineGrinder extends MachineBlock{ - - public MachineGrinder() { - super(); - } - -} \ No newline at end of file diff --git a/src/main/java/net/corechg/sparkt/block/Wire.java b/src/main/java/net/corechg/sparkt/block/Wire.java deleted file mode 100644 index 51f9178..0000000 --- a/src/main/java/net/corechg/sparkt/block/Wire.java +++ /dev/null @@ -1,11 +0,0 @@ -package net.corechg.sparkt.block; - -import net.minecraft.block.Block; - -public class Wire extends Block{ - - public Wire(Settings settings) { - super(settings); - } - -} \ No newline at end of file diff --git a/src/main/java/net/corechg/sparkt/block/entity/MachineFurnaceEntity.java b/src/main/java/net/corechg/sparkt/block/entity/MachineFurnaceEntity.java deleted file mode 100644 index edde32b..0000000 --- a/src/main/java/net/corechg/sparkt/block/entity/MachineFurnaceEntity.java +++ /dev/null @@ -1,102 +0,0 @@ -package net.corechg.sparkt.block.entity; - -import net.minecraft.block.entity.BlockEntity; -import net.minecraft.block.entity.BlockEntityType; -import net.minecraft.util.Tickable; - -import java.util.ArrayList; - -import net.corechg.transit.network.packet.IStaticPacket; -import net.corechg.transit.network.system.INode; -import net.corechg.transit.network.system.ISystem; -import net.corechg.transit.network.system.swap.IAcceptorNode; - -public class MachineFurnaceEntity extends BlockEntity implements IAcceptorNode, Tickable { - - private static final String[] GROUPS = { "ENERGY" }; - private int energyCap = 20000; - private int energyStored = 0; - private ArrayList connected = new ArrayList(0); - - public MachineFurnaceEntity(BlockEntityType type) { - super(type); - } - - @Override - public String[] groupsProvided() { - return GROUPS; - } - - @Override - public ISystem getSystem() { - return null; - } - - @Override - public Object getData(String groupID) { - if (groupID == "ENERGY") { - return energyStored; - } - return null; - } - - @Override - public void setData(Object dat, String groupID) { - if (groupID == "ENERGY") { - int tmp = (int) dat; - - energyStored = tmp > energyCap ? energyCap : tmp; - } - - } - - @Override - public INode[] getConnections() { - return (INode[]) connected.toArray(); - } - - @Override - public void tick() { - - } - - @Override - public boolean linkProvider(INode requester, String group) { - if (group == "ENERGY") { - connected.add(requester); - } - return false; - } - - @Override - public boolean unlinkProvider(INode toUnlink) { - for(int i = 0; i < connected.size(); i++) { - if(toUnlink.equals(connected.get(i))) { - connected.remove(i); - return true; - } - } - return false; - } - - @Override - public INode[] getProviders() { - return getConnections(); - } - - @Override - public boolean accept(IStaticPacket packet, String group) { - if (group == "ENERGY") { - int add = (int) packet.getType().toBase(packet, group); - if(add + energyStored > energyCap) { - return false; - } - else { - energyStored += add; - return true; - } - } - return false; - } - -} \ No newline at end of file diff --git a/src/main/java/net/cshift/sparkt/SparktInit.java b/src/main/java/net/cshift/sparkt/SparktInit.java new file mode 100644 index 0000000..0b85404 --- /dev/null +++ b/src/main/java/net/cshift/sparkt/SparktInit.java @@ -0,0 +1,22 @@ +package net.cshift.sparkt; + +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +import net.cshift.sparkt.block.Blocks; +import net.cshift.sparkt.block.entity.BlockEntityTypes; +import net.fabricmc.api.ModInitializer; + +public class SparktInit implements ModInitializer { + + public static final Logger LOG = LogManager.getFormatterLogger("Sparkt|Init"); + public static final String MODID = "sparkt"; + + @Override + public void onInitialize() { + LOG.info("Preparing to spark a reaction!"); + Blocks.register(); + BlockEntityTypes.register(); + } + +} \ No newline at end of file diff --git a/src/main/java/net/cshift/sparkt/block/Blocks.java b/src/main/java/net/cshift/sparkt/block/Blocks.java new file mode 100644 index 0000000..3aab1e2 --- /dev/null +++ b/src/main/java/net/cshift/sparkt/block/Blocks.java @@ -0,0 +1,32 @@ +package net.cshift.sparkt.block; + +import net.cshift.sparkt.SparktInit; +import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings; +import net.minecraft.block.Block; +import net.minecraft.item.BlockItem; +import net.minecraft.item.Item; +import net.minecraft.util.Identifier; +import net.minecraft.registry.*; + +public class Blocks { + + public static final Block MACHINE_BLOCK = new MachineBlock(FabricBlockSettings.create().strength(1, 1)); + public static final Block MACHINE_FURNACE = new MachineFurnace(FabricBlockSettings.create().strength(1, 1)); + public static final Block DRIVER_MECHANICAL = new DriverMechanical(FabricBlockSettings.create().strength(1, 1)); + public static final Block MACHINE_GRINDER = new MachineGrinder(FabricBlockSettings.create().strength(1, 1)); + //public static final Block + + public static void register() { + Registry.register(Registries.BLOCK, new Identifier(SparktInit.MODID, "machine_block"), MACHINE_BLOCK); + Registry.register(Registries.ITEM, new Identifier(SparktInit.MODID, "machine_block"), new BlockItem(MACHINE_BLOCK, new Item.Settings())); + + Registry.register(Registries.BLOCK, new Identifier(SparktInit.MODID, "machine_furnace"), MACHINE_FURNACE); + Registry.register(Registries.ITEM, new Identifier(SparktInit.MODID, "machine_furnace"), new BlockItem(MACHINE_FURNACE, new Item.Settings())); + + Registry.register(Registries.BLOCK, new Identifier(SparktInit.MODID, "driver_mechanical"), DRIVER_MECHANICAL); + Registry.register(Registries.ITEM, new Identifier(SparktInit.MODID, "driver_mechanical"), new BlockItem(DRIVER_MECHANICAL, new Item.Settings())); + + Registry.register(Registries.BLOCK, new Identifier(SparktInit.MODID, "machine_grinder"), MACHINE_GRINDER); + Registry.register(Registries.ITEM, new Identifier(SparktInit.MODID, "machine_grinder"), new BlockItem(MACHINE_GRINDER, new Item.Settings())); + } +} \ No newline at end of file diff --git a/src/main/java/net/cshift/sparkt/block/DriverMechanical.java b/src/main/java/net/cshift/sparkt/block/DriverMechanical.java new file mode 100644 index 0000000..a0f690e --- /dev/null +++ b/src/main/java/net/cshift/sparkt/block/DriverMechanical.java @@ -0,0 +1,9 @@ +package net.cshift.sparkt.block; + +public class DriverMechanical extends MachineBlock{ + + public DriverMechanical(Settings settings) { + super(settings); + } + +} \ No newline at end of file diff --git a/src/main/java/net/cshift/sparkt/block/MachineBlock.java b/src/main/java/net/cshift/sparkt/block/MachineBlock.java new file mode 100644 index 0000000..875f295 --- /dev/null +++ b/src/main/java/net/cshift/sparkt/block/MachineBlock.java @@ -0,0 +1,28 @@ +package net.cshift.sparkt.block; + +import net.cshift.sparkt.block.entity.MachineNode; +import net.minecraft.block.BlockState; +import net.minecraft.block.BlockWithEntity; +import net.minecraft.block.entity.BlockEntity; +import net.minecraft.entity.LivingEntity; +import net.minecraft.item.ItemStack; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.World; + +public class MachineBlock extends BlockWithEntity { + + public MachineBlock(Settings settings) { + super(settings); + } + + @Override + public BlockEntity createBlockEntity(BlockPos var1, BlockState var2) { + return new MachineNode(var1, var2); + } + + @Override + public void onPlaced(World world, BlockPos pos, BlockState state, LivingEntity placer, ItemStack itemStack) { + super.onPlaced(world, pos, state, placer, itemStack); + } + +} \ No newline at end of file diff --git a/src/main/java/net/cshift/sparkt/block/MachineFurnace.java b/src/main/java/net/cshift/sparkt/block/MachineFurnace.java new file mode 100644 index 0000000..2c815ce --- /dev/null +++ b/src/main/java/net/cshift/sparkt/block/MachineFurnace.java @@ -0,0 +1,9 @@ +package net.cshift.sparkt.block; + +public class MachineFurnace extends MachineBlock{ + + public MachineFurnace(Settings settings) { + super(settings); + } + +} \ No newline at end of file diff --git a/src/main/java/net/cshift/sparkt/block/MachineGrinder.java b/src/main/java/net/cshift/sparkt/block/MachineGrinder.java new file mode 100644 index 0000000..890fa7e --- /dev/null +++ b/src/main/java/net/cshift/sparkt/block/MachineGrinder.java @@ -0,0 +1,9 @@ +package net.cshift.sparkt.block; + +public class MachineGrinder extends MachineBlock{ + + public MachineGrinder(Settings settings) { + super(settings); + } + +} \ No newline at end of file diff --git a/src/main/java/net/cshift/sparkt/block/Wire.java b/src/main/java/net/cshift/sparkt/block/Wire.java new file mode 100644 index 0000000..fa0da3d --- /dev/null +++ b/src/main/java/net/cshift/sparkt/block/Wire.java @@ -0,0 +1,11 @@ +package net.cshift.sparkt.block; + +import net.minecraft.block.Block; + +public class Wire extends Block{ + + public Wire(Settings settings) { + super(settings); + } + +} \ No newline at end of file diff --git a/src/main/java/net/cshift/sparkt/block/entity/BlockEntityTypes.java b/src/main/java/net/cshift/sparkt/block/entity/BlockEntityTypes.java new file mode 100644 index 0000000..f4b1379 --- /dev/null +++ b/src/main/java/net/cshift/sparkt/block/entity/BlockEntityTypes.java @@ -0,0 +1,22 @@ +package net.cshift.sparkt.block.entity; + +import net.cshift.sparkt.SparktInit; +import net.cshift.sparkt.block.Blocks; +import net.fabricmc.fabric.api.object.builder.v1.block.entity.FabricBlockEntityTypeBuilder; +import net.minecraft.block.entity.BlockEntityType; +import net.minecraft.registry.Registries; +import net.minecraft.registry.Registry; +import net.minecraft.util.Identifier; + +public class BlockEntityTypes { + + public static BlockEntityType MACHINE_NODE; + + public static void register() { + MACHINE_NODE = Registry.register( + Registries.BLOCK_ENTITY_TYPE, + new Identifier(SparktInit.MODID, "machine_block_entity"), + FabricBlockEntityTypeBuilder.create(MachineNode::new, Blocks.MACHINE_BLOCK).build() + ); + } +} diff --git a/src/main/java/net/cshift/sparkt/block/entity/MachineFurnaceEntity.java b/src/main/java/net/cshift/sparkt/block/entity/MachineFurnaceEntity.java new file mode 100644 index 0000000..d45938c --- /dev/null +++ b/src/main/java/net/cshift/sparkt/block/entity/MachineFurnaceEntity.java @@ -0,0 +1,61 @@ +package net.cshift.sparkt.block.entity; + +import net.minecraft.block.BlockState; +import net.minecraft.block.entity.BlockEntity; +import net.minecraft.block.entity.BlockEntityType; +import net.minecraft.util.math.BlockPos; + +import net.cshift.api.transit.network.*; +import net.cshift.api.transit.network.packet.*; + +public class MachineFurnaceEntity extends BlockEntity implements INode { + + public MachineFurnaceEntity(BlockEntityType type, BlockPos pos, BlockState state) { + super(type, pos, state); + //TODO Auto-generated constructor stub + } + + @Override + public IStaticPacket accept(IStaticPacket arg0, Channel arg1) { + // TODO Auto-generated method stub + throw new UnsupportedOperationException("Unimplemented method 'accept'"); + } + + @Override + public Channel connect(int arg0, String arg1, INode arg2) { + // TODO Auto-generated method stub + throw new UnsupportedOperationException("Unimplemented method 'connect'"); + } + + @Override + public Channel connectDefault(String arg0, INode arg1) { + // TODO Auto-generated method stub + throw new UnsupportedOperationException("Unimplemented method 'connectDefault'"); + } + + @Override + public PoolManifest getManifest() { + // TODO Auto-generated method stub + throw new UnsupportedOperationException("Unimplemented method 'getManifest'"); + } + + @Override + public Number getPressure(Channel arg0) { + // TODO Auto-generated method stub + throw new UnsupportedOperationException("Unimplemented method 'getPressure'"); + } + + @Override + public Number getRate(Channel arg0) { + // TODO Auto-generated method stub + throw new UnsupportedOperationException("Unimplemented method 'getRate'"); + } + + @Override + public void onTerminate(Channel arg0) { + // TODO Auto-generated method stub + throw new UnsupportedOperationException("Unimplemented method 'onTerminate'"); + } + + +} \ No newline at end of file diff --git a/src/main/java/net/cshift/sparkt/block/entity/MachineNode.java b/src/main/java/net/cshift/sparkt/block/entity/MachineNode.java new file mode 100644 index 0000000..111d8cc --- /dev/null +++ b/src/main/java/net/cshift/sparkt/block/entity/MachineNode.java @@ -0,0 +1,59 @@ +package net.cshift.sparkt.block.entity; + +import net.cshift.api.transit.network.*; +import net.cshift.api.transit.network.packet.IStaticPacket; +import net.minecraft.block.BlockState; +import net.minecraft.block.entity.BlockEntity; +import net.minecraft.util.math.BlockPos; + +public class MachineNode extends BlockEntity implements INode { + + public MachineNode(BlockPos pos, BlockState state) { + super(BlockEntityTypes.MACHINE_NODE, pos, state); + } + + @Override + public IStaticPacket accept(IStaticPacket arg0, Channel arg1) { + // TODO Auto-generated method stub + throw new UnsupportedOperationException("Unimplemented method 'accept'"); + } + + @Override + public Channel connect(int arg0, String arg1, INode arg2) { + // TODO Auto-generated method stub + throw new UnsupportedOperationException("Unimplemented method 'connect'"); + } + + @Override + public Channel connectDefault(String arg0, INode arg1) { + // TODO Auto-generated method stub + throw new UnsupportedOperationException("Unimplemented method 'connectDefault'"); + } + + @Override + public PoolManifest getManifest() { + // TODO Auto-generated method stub + throw new UnsupportedOperationException("Unimplemented method 'getManifest'"); + } + + @Override + public Number getPressure(Channel arg0) { + // TODO Auto-generated method stub + throw new UnsupportedOperationException("Unimplemented method 'getPressure'"); + } + + @Override + public Number getRate(Channel arg0) { + // TODO Auto-generated method stub + throw new UnsupportedOperationException("Unimplemented method 'getRate'"); + } + + @Override + public void onTerminate(Channel arg0) { + // TODO Auto-generated method stub + throw new UnsupportedOperationException("Unimplemented method 'onTerminate'"); + } + + + +} diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 898a95f..69935ee 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -1,15 +1,15 @@ { "schemaVersion": 1, "id": "sparkt", - "version": "0.0.1", + "version": "0.0.2", "name": "Sparkt", "description": "Wires and whatnot!", "authors": [ - "CCGKyle" + "CSKyle" ], "contact": { - "sources": "https://github.com/CoreChg/Sparkt" + "sources": "https://git.cshift.net/CircleShift/Sparkt" }, "license": "MIT", @@ -18,15 +18,15 @@ "environment": "*", "entrypoints": { "main": [ - "net.corechg.sparkt.SparktInit" + "net.cshift.sparkt.SparktInit" ] }, "depends": { - "fabricloader": ">=0.7.4", + "fabricloader": ">=0.8.0", "fabric": "*", - "minecraft": "1.15.x", + "minecraft": "1.20.x", - "transit-api": ">=0.10.2" + "transit-api": "=3.0.0-alpha-2" } } -- cgit v1.2.3