Skip to content

Commit

Permalink
fixed: wooden shovel was used as burnable instead of extinguishing th…
Browse files Browse the repository at this point in the history
…e campfire #27

- fixed: resetting the burn and rain timer was incorrect when campfire was extinguished by shovel, water bucket or water splash potion
  • Loading branch information
cech12 committed Aug 22, 2023
1 parent 9059a48 commit 4b8c18c
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 3 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Forge Recommended Versioning](https://mcforge.readthedocs.io/en/latest/conventions/versioning/).

## [1.19.4-1.7.2.1] - 2023-08-22
### Fixed
- wooden shovel was used as burnable instead of extinguishing the campfire (thanks to brass_mccrafty for the report) #27
- resetting the burn and rain timer was incorrect when campfire was extinguished by shovel, water bucket or water splash potion

## [1.19.4-1.7.2.0] - 2023-08-19
### Changed
- updated mod to Forge 1.19.4-45.1.0
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ org.gradle.jvmargs=-Xmx3G
org.gradle.daemon=false

mod_id=unlitcampfire
mod_version=1.7.2.0
mod_version=1.7.2.1
minecraft_version=1.19.4
forge_version=45.1.0

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ public abstract class CampfireBlockEntityMixin extends BlockEntity implements IC

@Shadow protected abstract void markUpdated();

@Shadow public abstract void dowse();

private Boolean isSoulCampfire;

private int litTime = 0;
Expand Down Expand Up @@ -108,9 +110,10 @@ private void unlitCampfire() {
this.playUnlitSound();
if (this.dropsItemsWhenUnlitByTimeOrRain()) {
this.dropAllContainingItems();
} else {
this.dowse();
}
this.level.setBlockAndUpdate(this.getBlockPos(), this.getBlockState().setValue(CampfireBlock.LIT, false));
this.litTime = 0;
}
}

Expand Down Expand Up @@ -175,7 +178,6 @@ private static void cookTickProxy(Level level, BlockPos pos, BlockState state, C
if (rainUnlitTime >= 0 && level.isRainingAt(pos.above())) {
mixinEntity.rainTime++;
if (mixinEntity.rainTime >= rainUnlitTime) {
mixinEntity.rainTime = 0;
mixinEntity.unlitCampfire();
}
} else {
Expand Down Expand Up @@ -223,4 +225,12 @@ protected void getUpdateTagProxy(CallbackInfoReturnable<CompoundTag> info) {
}
}

@Inject(at = @At("RETURN"), method = "dowse")
protected void dowseProxy(CallbackInfo info) {
//is called by multiple sources such as shovel, water potion, water bucket extinguishing
this.litTime = 0;
this.rainTime = 0;
this.markUpdated();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import net.minecraft.world.InteractionResult;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.ShovelItem;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockBehaviour;
Expand Down Expand Up @@ -91,6 +92,10 @@ protected void useProxy(BlockState state, Level level, BlockPos pos, Player play
if (!this.canAddBurnables(state)) {
return;
}
//when shovel item is used, do nothing, to avoid using (wooden) shovel as burning material (issue #27)
if (stack.getItem() instanceof ShovelItem) {
return;
}
//when interaction item has no burn time, do nothing
int burnTime = ForgeHooks.getBurnTime(stack, null);
if (burnTime < 1) {
Expand Down

0 comments on commit 4b8c18c

Please sign in to comment.