summaryrefslogtreecommitdiff
path: root/src/main/java/net/cshift/mc/sparkt/block/Wire.java
diff options
context:
space:
mode:
authorKyle Gunger <kgunger12@gmail.com>2024-11-03 02:40:23 -0500
committerKyle Gunger <kgunger12@gmail.com>2024-11-03 02:40:23 -0500
commit8a6be0ce81d935551ab2ebc9c4e7d41b88297957 (patch)
treeed194dd70239f4a022d8ee824876cdbcd5c950c7 /src/main/java/net/cshift/mc/sparkt/block/Wire.java
parentf6ecfac78b963a694a13891df06413df104b19fb (diff)
Update to currentHEADmain
Diffstat (limited to 'src/main/java/net/cshift/mc/sparkt/block/Wire.java')
-rw-r--r--src/main/java/net/cshift/mc/sparkt/block/Wire.java44
1 files changed, 44 insertions, 0 deletions
diff --git a/src/main/java/net/cshift/mc/sparkt/block/Wire.java b/src/main/java/net/cshift/mc/sparkt/block/Wire.java
new file mode 100644
index 0000000..3ad78ed
--- /dev/null
+++ b/src/main/java/net/cshift/mc/sparkt/block/Wire.java
@@ -0,0 +1,44 @@
+package net.cshift.mc.sparkt.block;
+
+import org.jetbrains.annotations.Nullable;
+
+import com.mojang.serialization.MapCodec;
+
+import net.cshift.mc.sparkt.block.entity.BlockEntityTypes;
+import net.cshift.mc.sparkt.block.entity.WireEntity;
+import net.minecraft.block.BlockState;
+import net.minecraft.block.BlockWithEntity;
+import net.minecraft.block.entity.BlockEntity;
+import net.minecraft.block.entity.BlockEntityTicker;
+import net.minecraft.block.entity.BlockEntityType;
+import net.minecraft.util.math.BlockPos;
+import net.minecraft.world.World;
+
+public class Wire extends BlockWithEntity {
+ public static final MapCodec<Wire> CODEC = createCodec(Wire::new);
+
+ public MapCodec<Wire> getCodec() {
+ return CODEC;
+ }
+
+ public Wire(Settings settings) {
+ super(settings);
+ }
+
+ @Override
+ public BlockEntity createBlockEntity(BlockPos var1, BlockState var2) {
+ return new WireEntity(var1, var2);
+ }
+
+ @Override
+ public <T extends BlockEntity> BlockEntityTicker<T> getTicker(World world, BlockState state,
+ BlockEntityType<T> type) {
+ // TODO Auto-generated method stub
+ return validateTicker(world, type, BlockEntityTypes.WIRE_ENTITY);
+ }
+
+ @Nullable
+ protected static <T extends BlockEntity> BlockEntityTicker<T> validateTicker(World world, BlockEntityType<T> givenType, BlockEntityType<? extends WireEntity> expectedType) {
+ return world.isClient ? null : validateTicker(givenType, expectedType, WireEntity::tick);
+ }
+}