diff --git a/CHANGELOG.md b/CHANGELOG.md index db9623db4..e8128258b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -70,6 +70,7 @@ Unless otherwise specified, any version comparison below is the comparison of se - Fixed the bug that interacting with door doesn't have any sound. - Waxing copper-made block using honeycomb won't call `BlockFadeEvent` now. - Fixed the bug that player can still open enchant table even if he is sneaking. +- Fixed the bug that brewing stand fast brew and lagging brew animation. ## [0.1.2](https://github.com/AllayMC/Allay/releases/tag/0.1.2) (API 0.3.0) - 2024-12-31 diff --git a/server/src/main/java/org/allaymc/server/blockentity/component/BlockEntityBrewingStandBaseComponentImpl.java b/server/src/main/java/org/allaymc/server/blockentity/component/BlockEntityBrewingStandBaseComponentImpl.java index f9723ca37..095dc8f7e 100644 --- a/server/src/main/java/org/allaymc/server/blockentity/component/BlockEntityBrewingStandBaseComponentImpl.java +++ b/server/src/main/java/org/allaymc/server/blockentity/component/BlockEntityBrewingStandBaseComponentImpl.java @@ -67,33 +67,38 @@ public void onInitFinish(BlockEntityInitInfo initInfo) { container.addOnSlotChangeListener(BrewingStandContainer.REAGENT_SLOT, item -> { brewTime = item == ItemAirStack.AIR_STACK ? 0 : MAX_BREW_TIME; - sendBrewingStandContainerData(true); }); } @Override public void tick(long currentTick) { - tickBrewingStand(); - sendBrewingStandContainerData(brewTime % 40 == 0); + BrewingStandContainer container = containerHolderComponent.getContainer(); + tickBrewingStand(container); + container.sendContainerData(ContainerSetDataPacket.BREWING_STAND_FUEL_AMOUNT, fuelAmount); + container.sendContainerData(ContainerSetDataPacket.BREWING_STAND_FUEL_TOTAL, fuelTotal); } - protected void tickBrewingStand() { - if (!checkFuel()) { + protected void tickBrewingStand(BrewingStandContainer container) { + if (!checkFuel(container)) { return; } - BrewingStandContainer container = containerHolderComponent.getContainer(); var reagent = container.getReagent(); var a = findRecipe(container.getResult(0), reagent); var b = findRecipe(container.getResult(1), reagent); var c = findRecipe(container.getResult(2), reagent); if (a == null && b == null && c == null) { - brewTime = 0; + brewTime = MAX_BREW_TIME; + container.sendContainerData(ContainerSetDataPacket.BREWING_STAND_BREW_TIME, 0); // We should reset brew animation return; } if (brewTime > 0) { + if (brewTime % 40 == 0) { + container.sendContainerData(ContainerSetDataPacket.BREWING_STAND_BREW_TIME, brewTime); + } + brewTime--; return; } @@ -123,13 +128,11 @@ protected void tickBrewingStand() { getDimension().addSound(position, Sound.RANDOM_POTION_BREWED); } - protected boolean checkFuel() { + protected boolean checkFuel(BrewingStandContainer container) { if (fuelAmount > 0) { return true; } - BrewingStandContainer container = containerHolderComponent.getContainer(); - var fuel = container.getFuel(); if (fuel.getItemType() != ItemTypes.BLAZE_POWDER) { return false; @@ -151,15 +154,6 @@ protected PotionMixRecipe findRecipe(ItemStack ingredient, ItemStack reagent) { return Registries.POTION_MIX_RECIPES.get(PotionMixRecipe.buildIdentifier(ingredient, reagent)); } - protected void sendBrewingStandContainerData(boolean sendBrewTime) { - var container = containerHolderComponent.getContainer(); - if (sendBrewTime) { - container.sendContainerData(ContainerSetDataPacket.BREWING_STAND_BREW_TIME, brewTime); - } - container.sendContainerData(ContainerSetDataPacket.BREWING_STAND_FUEL_AMOUNT, fuelAmount); - container.sendContainerData(ContainerSetDataPacket.BREWING_STAND_FUEL_TOTAL, fuelTotal); - } - @Override public NbtMap saveNBT() { return super.saveNBT()