blob: 3ad78ede9df98260400d2da519914a3669153bcf (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
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);
}
}
|