Skip to content

Commit

Permalink
Fix custom campfires cooking function breaking when re-entering a world.
Browse files Browse the repository at this point in the history
  • Loading branch information
Crystal-Spider committed Jun 15, 2024
1 parent 75b654b commit 5b9a9ef
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ public CustomCampfireBlock(ResourceLocation fireType, boolean spawnParticles, Pr
this.fireType = fireType;
}

protected BlockEntityType<? extends CustomCampfireBlockEntity> getBlockEntityType() {
return FireManager.CUSTOM_CAMPFIRE_ENTITY_TYPE.get();
}

protected BlockEntityTicker<? super CampfireBlockEntity> particleTick() {
return CustomCampfireBlockEntity::particleTick;
}
Expand All @@ -69,13 +73,13 @@ public MapCodec<CampfireBlock> codec() {

@Override
public BlockEntity newBlockEntity(@NotNull BlockPos pos, @NotNull BlockState state) {
return new CustomCampfireBlockEntity(getFireType(), pos, state);
return new CustomCampfireBlockEntity(pos, state);
}

@Nullable
@Override
public <T extends BlockEntity> BlockEntityTicker<T> getTicker(Level level, @NotNull BlockState state, @NotNull BlockEntityType<T> blockEntityType) {
BlockEntityType<CampfireBlockEntity> customBlockEntityType = FireManager.CUSTOM_CAMPFIRE_ENTITY_TYPE.get();
BlockEntityType<? extends CustomCampfireBlockEntity> customBlockEntityType = getBlockEntityType();
if (level.isClientSide) {
return state.getValue(LIT) ? createTickerHelper(blockEntityType, customBlockEntityType, particleTick()) : null;
} else {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,30 +1,20 @@
package it.crystalnest.soul_fire_d.api.block.entity;

import it.crystalnest.soul_fire_d.api.FireManager;
import it.crystalnest.soul_fire_d.api.type.FireTyped;
import net.minecraft.core.BlockPos;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.level.block.entity.BlockEntityType;
import net.minecraft.world.level.block.entity.CampfireBlockEntity;
import net.minecraft.world.level.block.state.BlockState;
import org.jetbrains.annotations.NotNull;

public class CustomCampfireBlockEntity extends CampfireBlockEntity implements FireTyped {
private final ResourceLocation fireType;

public CustomCampfireBlockEntity(ResourceLocation fireType, BlockPos pos, BlockState state) {
public class CustomCampfireBlockEntity extends CampfireBlockEntity {
public CustomCampfireBlockEntity(BlockPos pos, BlockState state) {
super(pos, state);
this.fireType = fireType;
}

@NotNull
@Override
public BlockEntityType<?> getType() {
return FireManager.CUSTOM_CAMPFIRE_ENTITY_TYPE.get();
}

@Override
public ResourceLocation getFireType() {
return fireType;
}
}

0 comments on commit 5b9a9ef

Please sign in to comment.