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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
|
--- a/net/minecraft/world/level/block/CampfireBlock.java
+++ b/net/minecraft/world/level/block/CampfireBlock.java
@@ -3,7 +3,6 @@
import com.mojang.serialization.Codec;
import com.mojang.serialization.MapCodec;
import com.mojang.serialization.codecs.RecordCodecBuilder;
-import com.mojang.serialization.codecs.RecordCodecBuilder.Instance;
import java.util.Optional;
import javax.annotation.Nullable;
import net.minecraft.core.BlockPos;
@@ -16,7 +15,7 @@
import net.minecraft.tags.BlockTags;
import net.minecraft.util.RandomSource;
import net.minecraft.world.Containers;
-import net.minecraft.world.InteractionHand;
+import net.minecraft.world.EnumHand;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.LivingEntity;
@@ -35,69 +34,67 @@
import net.minecraft.world.level.block.entity.BlockEntityType;
import net.minecraft.world.level.block.entity.CampfireBlockEntity;
import net.minecraft.world.level.block.state.BlockBehaviour;
-import net.minecraft.world.level.block.state.BlockState;
+import net.minecraft.world.level.block.state.IBlockData;
import net.minecraft.world.level.block.state.StateDefinition;
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
import net.minecraft.world.level.block.state.properties.BooleanProperty;
import net.minecraft.world.level.block.state.properties.DirectionProperty;
import net.minecraft.world.level.gameevent.GameEvent;
+import net.minecraft.world.level.material.Fluid;
import net.minecraft.world.level.material.FluidState;
import net.minecraft.world.level.material.Fluids;
-import net.minecraft.world.level.pathfinder.PathComputationType;
+import net.minecraft.world.level.pathfinder.PathMode;
import net.minecraft.world.phys.BlockHitResult;
import net.minecraft.world.phys.shapes.BooleanOp;
import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.Shapes;
import net.minecraft.world.phys.shapes.VoxelShape;
+// CraftBukkit start
+import org.bukkit.craftbukkit.block.CraftBlock;
+// CraftBukkit end
public class CampfireBlock extends BaseEntityBlock implements SimpleWaterloggedBlock {
- public static final MapCodec<CampfireBlock> CODEC = RecordCodecBuilder.mapCodec(
- instance -> instance.group(
- Codec.BOOL.fieldOf("spawn_particles").forGetter(campfireBlock -> campfireBlock.spawnParticles),
- Codec.intRange(0, 1000).fieldOf("fire_damage").forGetter(campfireBlock -> campfireBlock.fireDamage),
- propertiesCodec()
- )
- .apply(instance, CampfireBlock::new)
- );
- protected static final VoxelShape SHAPE = Block.box(0.0, 0.0, 0.0, 16.0, 7.0, 16.0);
+
+ public static final MapCodec<CampfireBlock> CODEC = RecordCodecBuilder.mapCodec((instance) -> {
+ return instance.group(Codec.BOOL.fieldOf("spawn_particles").forGetter((blockcampfire) -> {
+ return blockcampfire.spawnParticles;
+ }), Codec.intRange(0, 1000).fieldOf("fire_damage").forGetter((blockcampfire) -> {
+ return blockcampfire.fireDamage;
+ }), propertiesCodec()).apply(instance, CampfireBlock::new);
+ });
+ protected static final VoxelShape SHAPE = Block.box(0.0D, 0.0D, 0.0D, 16.0D, 7.0D, 16.0D);
public static final BooleanProperty LIT = BlockStateProperties.LIT;
public static final BooleanProperty SIGNAL_FIRE = BlockStateProperties.SIGNAL_FIRE;
public static final BooleanProperty WATERLOGGED = BlockStateProperties.WATERLOGGED;
public static final DirectionProperty FACING = BlockStateProperties.HORIZONTAL_FACING;
- private static final VoxelShape VIRTUAL_FENCE_POST = Block.box(6.0, 0.0, 6.0, 10.0, 16.0, 10.0);
+ private static final VoxelShape VIRTUAL_FENCE_POST = Block.box(6.0D, 0.0D, 6.0D, 10.0D, 16.0D, 10.0D);
private static final int SMOKE_DISTANCE = 5;
private final boolean spawnParticles;
private final int fireDamage;
@Override
public MapCodec<CampfireBlock> codec() {
- return CODEC;
+ return CampfireBlock.CODEC;
}
public CampfireBlock(boolean spawnParticles, int fireDamage, BlockBehaviour.Properties properties) {
super(properties);
this.spawnParticles = spawnParticles;
this.fireDamage = fireDamage;
- this.registerDefaultState(
- this.stateDefinition
- .any()
- .setValue(LIT, Boolean.valueOf(true))
- .setValue(SIGNAL_FIRE, Boolean.valueOf(false))
- .setValue(WATERLOGGED, Boolean.valueOf(false))
- .setValue(FACING, Direction.NORTH)
- );
+ this.registerDefaultState((IBlockData) ((IBlockData) ((IBlockData) ((IBlockData) ((IBlockData) this.stateDefinition.any()).setValue(CampfireBlock.LIT, true)).setValue(CampfireBlock.SIGNAL_FIRE, false)).setValue(CampfireBlock.WATERLOGGED, false)).setValue(CampfireBlock.FACING, Direction.NORTH));
}
@Override
- public InteractionResult use(BlockState state, Level level, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) {
- if (level.getBlockEntity(pos) instanceof CampfireBlockEntity campfireBlockEntity) {
- ItemStack itemInHand = player.getItemInHand(hand);
- Optional<RecipeHolder<CampfireCookingRecipe>> cookableRecipe = campfireBlockEntity.getCookableRecipe(itemInHand);
- if (cookableRecipe.isPresent()) {
- if (!level.isClientSide
- && campfireBlockEntity.placeFood(
- player, player.getAbilities().instabuild ? itemInHand.copy() : itemInHand, cookableRecipe.get().value().getCookingTime()
- )) {
+ public InteractionResult use(IBlockData state, Level level, BlockPos pos, Player player, EnumHand hand, BlockHitResult hit) {
+ BlockEntity tileentity = level.getBlockEntity(pos);
+
+ if (tileentity instanceof CampfireBlockEntity) {
+ CampfireBlockEntity tileentitycampfire = (CampfireBlockEntity) tileentity;
+ ItemStack itemstack = player.getItemInHand(hand);
+ Optional<RecipeHolder<CampfireCookingRecipe>> optional = tileentitycampfire.getCookableRecipe(itemstack);
+
+ if (optional.isPresent()) {
+ if (!level.isClientSide && tileentitycampfire.placeFood(player, player.getAbilities().instabuild ? itemstack.copy() : itemstack, ((CampfireCookingRecipe) ((RecipeHolder) optional.get()).value()).getCookingTime())) {
player.awardStat(Stats.INTERACT_WITH_CAMPFIRE);
return InteractionResult.SUCCESS;
}
@@ -110,20 +107,23 @@
}
@Override
- public void entityInside(BlockState state, Level level, BlockPos pos, Entity entity) {
- if (state.getValue(LIT) && entity instanceof LivingEntity && !EnchantmentHelper.hasFrostWalker((LivingEntity)entity)) {
- entity.hurt(level.damageSources().inFire(), (float)this.fireDamage);
+ public void entityInside(IBlockData state, Level level, BlockPos pos, Entity entity) {
+ if ((Boolean) state.getValue(CampfireBlock.LIT) && entity instanceof LivingEntity && !EnchantmentHelper.hasFrostWalker((LivingEntity) entity)) {
+ org.bukkit.craftbukkit.event.CraftEventFactory.blockDamage = CraftBlock.at(level, pos); // CraftBukkit
+ entity.hurt(level.damageSources().inFire(), (float) this.fireDamage);
+ org.bukkit.craftbukkit.event.CraftEventFactory.blockDamage = null; // CraftBukkit
}
super.entityInside(state, level, pos, entity);
}
@Override
- public void onRemove(BlockState state, Level level, BlockPos pos, BlockState newState, boolean isMoving) {
+ public void onRemove(IBlockData state, Level level, BlockPos pos, IBlockData newState, boolean isMoving) {
if (!state.is(newState.getBlock())) {
- BlockEntity blockEntity = level.getBlockEntity(pos);
- if (blockEntity instanceof CampfireBlockEntity) {
- Containers.dropContents(level, pos, ((CampfireBlockEntity)blockEntity).getItems());
+ BlockEntity tileentity = level.getBlockEntity(pos);
+
+ if (tileentity instanceof CampfireBlockEntity) {
+ Containers.dropContents(level, pos, ((CampfireBlockEntity) tileentity).getItems());
}
super.onRemove(state, level, pos, newState, isMoving);
@@ -132,102 +132,83 @@
@Nullable
@Override
- public BlockState getStateForPlacement(BlockPlaceContext context) {
- LevelAccessor level = context.getLevel();
- BlockPos clickedPos = context.getClickedPos();
- boolean flag = level.getFluidState(clickedPos).getType() == Fluids.WATER;
- return this.defaultBlockState()
- .setValue(WATERLOGGED, Boolean.valueOf(flag))
- .setValue(SIGNAL_FIRE, Boolean.valueOf(this.isSmokeSource(level.getBlockState(clickedPos.below()))))
- .setValue(LIT, Boolean.valueOf(!flag))
- .setValue(FACING, context.getHorizontalDirection());
+ public IBlockData getStateForPlacement(BlockPlaceContext context) {
+ Level world = context.getLevel();
+ BlockPos blockposition = context.getClickedPos();
+ boolean flag = world.getFluidState(blockposition).getType() == Fluids.WATER;
+
+ return (IBlockData) ((IBlockData) ((IBlockData) ((IBlockData) this.defaultBlockState().setValue(CampfireBlock.WATERLOGGED, flag)).setValue(CampfireBlock.SIGNAL_FIRE, this.isSmokeSource(world.getBlockState(blockposition.below())))).setValue(CampfireBlock.LIT, !flag)).setValue(CampfireBlock.FACING, context.getHorizontalDirection());
}
@Override
- public BlockState updateShape(BlockState state, Direction facing, BlockState facingState, LevelAccessor level, BlockPos currentPos, BlockPos facingPos) {
- if (state.getValue(WATERLOGGED)) {
- level.scheduleTick(currentPos, Fluids.WATER, Fluids.WATER.getTickDelay(level));
+ public IBlockData updateShape(IBlockData state, Direction facing, IBlockData facingState, LevelAccessor level, BlockPos currentPos, BlockPos facingPos) {
+ if ((Boolean) state.getValue(CampfireBlock.WATERLOGGED)) {
+ level.scheduleTick(currentPos, (Fluid) Fluids.WATER, Fluids.WATER.getTickDelay(level));
}
- return facing == Direction.DOWN
- ? state.setValue(SIGNAL_FIRE, Boolean.valueOf(this.isSmokeSource(facingState)))
- : super.updateShape(state, facing, facingState, level, currentPos, facingPos);
+ return facing == Direction.DOWN ? (IBlockData) state.setValue(CampfireBlock.SIGNAL_FIRE, this.isSmokeSource(facingState)) : super.updateShape(state, facing, facingState, level, currentPos, facingPos);
}
- private boolean isSmokeSource(BlockState state) {
+ private boolean isSmokeSource(IBlockData state) {
return state.is(Blocks.HAY_BLOCK);
}
@Override
- public VoxelShape getShape(BlockState state, BlockGetter level, BlockPos pos, CollisionContext context) {
- return SHAPE;
+ public VoxelShape getShape(IBlockData state, BlockGetter level, BlockPos pos, CollisionContext context) {
+ return CampfireBlock.SHAPE;
}
@Override
- public RenderShape getRenderShape(BlockState state) {
- return RenderShape.MODEL;
+ public EnumRenderType getRenderShape(IBlockData state) {
+ return EnumRenderType.MODEL;
}
@Override
- public void animateTick(BlockState state, Level level, BlockPos pos, RandomSource random) {
- if (state.getValue(LIT)) {
+ public void animateTick(IBlockData state, Level level, BlockPos pos, RandomSource random) {
+ if ((Boolean) state.getValue(CampfireBlock.LIT)) {
if (random.nextInt(10) == 0) {
- level.playLocalSound(
- (double)pos.getX() + 0.5,
- (double)pos.getY() + 0.5,
- (double)pos.getZ() + 0.5,
- SoundEvents.CAMPFIRE_CRACKLE,
- SoundSource.BLOCKS,
- 0.5F + random.nextFloat(),
- random.nextFloat() * 0.7F + 0.6F,
- false
- );
+ level.playLocalSound((double) pos.getX() + 0.5D, (double) pos.getY() + 0.5D, (double) pos.getZ() + 0.5D, SoundEvents.CAMPFIRE_CRACKLE, SoundSource.BLOCKS, 0.5F + random.nextFloat(), random.nextFloat() * 0.7F + 0.6F, false);
}
if (this.spawnParticles && random.nextInt(5) == 0) {
- for (int i = 0; i < random.nextInt(1) + 1; i++) {
- level.addParticle(
- ParticleTypes.LAVA,
- (double)pos.getX() + 0.5,
- (double)pos.getY() + 0.5,
- (double)pos.getZ() + 0.5,
- (double)(random.nextFloat() / 2.0F),
- 5.0E-5,
- (double)(random.nextFloat() / 2.0F)
- );
+ for (int i = 0; i < random.nextInt(1) + 1; ++i) {
+ level.addParticle(ParticleTypes.LAVA, (double) pos.getX() + 0.5D, (double) pos.getY() + 0.5D, (double) pos.getZ() + 0.5D, (double) (random.nextFloat() / 2.0F), 5.0E-5D, (double) (random.nextFloat() / 2.0F));
}
}
+
}
}
- public static void dowse(@Nullable Entity entity, LevelAccessor level, BlockPos pos, BlockState state) {
+ public static void dowse(@Nullable Entity entity, LevelAccessor level, BlockPos pos, IBlockData state) {
if (level.isClientSide()) {
- for (int i = 0; i < 20; i++) {
- makeParticles((Level)level, pos, state.getValue(SIGNAL_FIRE), true);
+ for (int i = 0; i < 20; ++i) {
+ makeParticles((Level) level, pos, (Boolean) state.getValue(CampfireBlock.SIGNAL_FIRE), true);
}
}
- BlockEntity blockEntity = level.getBlockEntity(pos);
- if (blockEntity instanceof CampfireBlockEntity) {
- ((CampfireBlockEntity)blockEntity).dowse();
+ BlockEntity tileentity = level.getBlockEntity(pos);
+
+ if (tileentity instanceof CampfireBlockEntity) {
+ ((CampfireBlockEntity) tileentity).dowse();
}
level.gameEvent(entity, GameEvent.BLOCK_CHANGE, pos);
}
@Override
- public boolean placeLiquid(LevelAccessor level, BlockPos pos, BlockState state, FluidState fluidState) {
- if (!state.getValue(BlockStateProperties.WATERLOGGED) && fluidState.getType() == Fluids.WATER) {
- boolean flag = state.getValue(LIT);
+ public boolean placeLiquid(LevelAccessor level, BlockPos pos, IBlockData state, FluidState fluidState) {
+ if (!(Boolean) state.getValue(BlockStateProperties.WATERLOGGED) && fluidState.getType() == Fluids.WATER) {
+ boolean flag = (Boolean) state.getValue(CampfireBlock.LIT);
+
if (flag) {
if (!level.isClientSide()) {
- level.playSound(null, pos, SoundEvents.GENERIC_EXTINGUISH_FIRE, SoundSource.BLOCKS, 1.0F, 1.0F);
+ level.playSound((Player) null, pos, SoundEvents.GENERIC_EXTINGUISH_FIRE, SoundSource.BLOCKS, 1.0F, 1.0F);
}
- dowse(null, level, pos, state);
+ dowse((Entity) null, level, pos, state);
}
- level.setBlock(pos, state.setValue(WATERLOGGED, Boolean.valueOf(true)).setValue(LIT, Boolean.valueOf(false)), 3);
+ level.setBlock(pos, (IBlockData) ((IBlockData) state.setValue(CampfireBlock.WATERLOGGED, true)).setValue(CampfireBlock.LIT, false), 3);
level.scheduleTick(pos, fluidState.getType(), fluidState.getType().getTickDelay(level));
return true;
} else {
@@ -236,106 +217,95 @@
}
@Override
- public void onProjectileHit(Level level, BlockState state, BlockHitResult hit, Projectile projectile) {
- BlockPos blockPos = hit.getBlockPos();
- if (!level.isClientSide && projectile.isOnFire() && projectile.mayInteract(level, blockPos) && !state.getValue(LIT) && !state.getValue(WATERLOGGED)) {
- level.setBlock(blockPos, state.setValue(BlockStateProperties.LIT, Boolean.valueOf(true)), 11);
+ public void onProjectileHit(Level level, IBlockData state, BlockHitResult hit, Projectile projectile) {
+ BlockPos blockposition = hit.getBlockPos();
+
+ if (!level.isClientSide && projectile.isOnFire() && projectile.mayInteract(level, blockposition) && !(Boolean) state.getValue(CampfireBlock.LIT) && !(Boolean) state.getValue(CampfireBlock.WATERLOGGED)) {
+ // CraftBukkit start
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockIgniteEvent(level, blockposition, projectile).isCancelled()) {
+ return;
+ }
+ // CraftBukkit end
+ level.setBlock(blockposition, (IBlockData) state.setValue(BlockStateProperties.LIT, true), 11);
}
+
}
public static void makeParticles(Level level, BlockPos pos, boolean isSignalFire, boolean spawnExtraSmoke) {
- RandomSource random = level.getRandom();
- SimpleParticleType simpleParticleType = isSignalFire ? ParticleTypes.CAMPFIRE_SIGNAL_SMOKE : ParticleTypes.CAMPFIRE_COSY_SMOKE;
- level.addAlwaysVisibleParticle(
- simpleParticleType,
- true,
- (double)pos.getX() + 0.5 + random.nextDouble() / 3.0 * (double)(random.nextBoolean() ? 1 : -1),
- (double)pos.getY() + random.nextDouble() + random.nextDouble(),
- (double)pos.getZ() + 0.5 + random.nextDouble() / 3.0 * (double)(random.nextBoolean() ? 1 : -1),
- 0.0,
- 0.07,
- 0.0
- );
+ RandomSource randomsource = level.getRandom();
+ SimpleParticleType particletype = isSignalFire ? ParticleTypes.CAMPFIRE_SIGNAL_SMOKE : ParticleTypes.CAMPFIRE_COSY_SMOKE;
+
+ level.addAlwaysVisibleParticle(particletype, true, (double) pos.getX() + 0.5D + randomsource.nextDouble() / 3.0D * (double) (randomsource.nextBoolean() ? 1 : -1), (double) pos.getY() + randomsource.nextDouble() + randomsource.nextDouble(), (double) pos.getZ() + 0.5D + randomsource.nextDouble() / 3.0D * (double) (randomsource.nextBoolean() ? 1 : -1), 0.0D, 0.07D, 0.0D);
if (spawnExtraSmoke) {
- level.addParticle(
- ParticleTypes.SMOKE,
- (double)pos.getX() + 0.5 + random.nextDouble() / 4.0 * (double)(random.nextBoolean() ? 1 : -1),
- (double)pos.getY() + 0.4,
- (double)pos.getZ() + 0.5 + random.nextDouble() / 4.0 * (double)(random.nextBoolean() ? 1 : -1),
- 0.0,
- 0.005,
- 0.0
- );
+ level.addParticle(ParticleTypes.SMOKE, (double) pos.getX() + 0.5D + randomsource.nextDouble() / 4.0D * (double) (randomsource.nextBoolean() ? 1 : -1), (double) pos.getY() + 0.4D, (double) pos.getZ() + 0.5D + randomsource.nextDouble() / 4.0D * (double) (randomsource.nextBoolean() ? 1 : -1), 0.0D, 0.005D, 0.0D);
}
+
}
public static boolean isSmokeyPos(Level level, BlockPos pos) {
- for (int i = 1; i <= 5; i++) {
- BlockPos blockPos = pos.below(i);
- BlockState blockState = level.getBlockState(blockPos);
- if (isLitCampfire(blockState)) {
+ for (int i = 1; i <= 5; ++i) {
+ BlockPos blockposition1 = pos.below(i);
+ IBlockData iblockdata = level.getBlockState(blockposition1);
+
+ if (isLitCampfire(iblockdata)) {
return true;
}
- boolean flag = Shapes.joinIsNotEmpty(VIRTUAL_FENCE_POST, blockState.getCollisionShape(level, pos, CollisionContext.empty()), BooleanOp.AND);
+ boolean flag = Shapes.joinIsNotEmpty(CampfireBlock.VIRTUAL_FENCE_POST, iblockdata.getCollisionShape(level, pos, CollisionContext.empty()), BooleanOp.AND);
+
if (flag) {
- BlockState blockState1 = level.getBlockState(blockPos.below());
- return isLitCampfire(blockState1);
+ IBlockData iblockdata1 = level.getBlockState(blockposition1.below());
+
+ return isLitCampfire(iblockdata1);
}
}
return false;
}
- public static boolean isLitCampfire(BlockState state) {
- return state.hasProperty(LIT) && state.is(BlockTags.CAMPFIRES) && state.getValue(LIT);
+ public static boolean isLitCampfire(IBlockData state) {
+ return state.hasProperty(CampfireBlock.LIT) && state.is(BlockTags.CAMPFIRES) && (Boolean) state.getValue(CampfireBlock.LIT);
}
@Override
- public FluidState getFluidState(BlockState state) {
- return state.getValue(WATERLOGGED) ? Fluids.WATER.getSource(false) : super.getFluidState(state);
+ public FluidState getFluidState(IBlockData state) {
+ return (Boolean) state.getValue(CampfireBlock.WATERLOGGED) ? Fluids.WATER.getSource(false) : super.getFluidState(state);
}
@Override
- public BlockState rotate(BlockState state, Rotation rot) {
- return state.setValue(FACING, rot.rotate(state.getValue(FACING)));
+ public IBlockData rotate(IBlockData state, Rotation rot) {
+ return (IBlockData) state.setValue(CampfireBlock.FACING, rot.rotate((Direction) state.getValue(CampfireBlock.FACING)));
}
@Override
- public BlockState mirror(BlockState state, Mirror mirror) {
- return state.rotate(mirror.getRotation(state.getValue(FACING)));
+ public IBlockData mirror(IBlockData state, Mirror mirror) {
+ return state.rotate(mirror.getRotation((Direction) state.getValue(CampfireBlock.FACING)));
}
@Override
- protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder) {
- builder.add(LIT, SIGNAL_FIRE, WATERLOGGED, FACING);
+ protected void createBlockStateDefinition(StateDefinition.Builder<Block, IBlockData> builder) {
+ builder.add(CampfireBlock.LIT, CampfireBlock.SIGNAL_FIRE, CampfireBlock.WATERLOGGED, CampfireBlock.FACING);
}
@Override
- public BlockEntity newBlockEntity(BlockPos pos, BlockState state) {
+ public BlockEntity newBlockEntity(BlockPos pos, IBlockData state) {
return new CampfireBlockEntity(pos, state);
}
@Nullable
@Override
- public <T extends BlockEntity> BlockEntityTicker<T> getTicker(Level level, BlockState state, BlockEntityType<T> blockEntityType) {
- if (level.isClientSide) {
- return state.getValue(LIT) ? createTickerHelper(blockEntityType, BlockEntityType.CAMPFIRE, CampfireBlockEntity::particleTick) : null;
- } else {
- return state.getValue(LIT)
- ? createTickerHelper(blockEntityType, BlockEntityType.CAMPFIRE, CampfireBlockEntity::cookTick)
- : createTickerHelper(blockEntityType, BlockEntityType.CAMPFIRE, CampfireBlockEntity::cooldownTick);
- }
+ public <T extends BlockEntity> BlockEntityTicker<T> getTicker(Level level, IBlockData state, BlockEntityType<T> blockEntityType) {
+ return level.isClientSide ? ((Boolean) state.getValue(CampfireBlock.LIT) ? createTickerHelper(blockEntityType, BlockEntityType.CAMPFIRE, CampfireBlockEntity::particleTick) : null) : ((Boolean) state.getValue(CampfireBlock.LIT) ? createTickerHelper(blockEntityType, BlockEntityType.CAMPFIRE, CampfireBlockEntity::cookTick) : createTickerHelper(blockEntityType, BlockEntityType.CAMPFIRE, CampfireBlockEntity::cooldownTick));
}
@Override
- public boolean isPathfindable(BlockState state, BlockGetter level, BlockPos pos, PathComputationType type) {
+ public boolean isPathfindable(IBlockData state, BlockGetter level, BlockPos pos, PathMode type) {
return false;
}
- public static boolean canLight(BlockState state) {
- return state.is(BlockTags.CAMPFIRES, blockStateBase -> blockStateBase.hasProperty(WATERLOGGED) && blockStateBase.hasProperty(LIT))
- && !state.getValue(WATERLOGGED)
- && !state.getValue(LIT);
+ public static boolean canLight(IBlockData state) {
+ return state.is(BlockTags.CAMPFIRES, (blockbase_blockdata) -> {
+ return blockbase_blockdata.hasProperty(CampfireBlock.WATERLOGGED) && blockbase_blockdata.hasProperty(CampfireBlock.LIT);
+ }) && !(Boolean) state.getValue(CampfireBlock.WATERLOGGED) && !(Boolean) state.getValue(CampfireBlock.LIT);
}
}
|