Skip to content

Commit

Permalink
Merge branch 'master' into feat/slab
Browse files Browse the repository at this point in the history
  • Loading branch information
smartcmd authored Jan 13, 2025
2 parents 2e5006a + a4a96a1 commit f45f9a8
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 23 deletions.
11 changes: 9 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ Unless otherwise specified, any version comparison below is the comparison of se
`Registries#POTION_MIX_RECIPES`, `PotionMixRecipe` are added to api module. See commit history for more details.
- (API) Implemented slab, and several related interfaces are added to api module.
- (API) Introduced `BlockBaseComponent#combine` method which is used by slab. For the details of this method, see the javadoc.
- (API) Implemented brewing stand, and several related interfaces & objects including `BlockEntityBrewingStand`,
`BrewingStandContainer`, `Registries#POTION_MIX_RECIPES`, `PotionMixRecipe` are added to api module. See commit
history for more details.
- (API) Introduced a number of overloads of `Dimension#addSound`.
- Implemented trapdoor except redstone feature (Redstone feature requires the implementation of redstone system).
- Implemented sponge and wet sponge.
Expand All @@ -55,12 +58,14 @@ Unless otherwise specified, any version comparison below is the comparison of se
- (API) `EntityBaseComponent#getBlockStateStandingOn` now return `BlockStateWithPos` instead of `BlockState`.
- (API) Removed `BlockFace#horizontalIndex` which is useless.
- (API) Removed `ScoreboardService#ServerEventListener` as it is not supposed to be touched by plugin.
- (API) Methods `BlockEntityFurnaceBaseComponent#getStoredXP` and `BlockEntityFurnaceBaseComponent#setStoredXP` now accept
`int` instead of `float`.
- (API) Methods `BlockEntityFurnaceBaseComponent#getStoredXP` and `BlockEntityFurnaceBaseComponent#setStoredXP` now
accept `int` instead of `float`.
- Removed useless class `PackageClassLoaderUtils`, dependency `org.reflections.reflections` is also removed.
- Added `-dev` suffix to api version in development build.
- Changed `ContainerActionProcessorHolder` to a final class instead of an interface, because this abstraction is
meaningless.
- Changed `enableGui` to `enable-gui` in `server-settings.yml`
- Disabled packet limit only in dev build.

### Fixed

Expand All @@ -69,6 +74,8 @@ 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.
- Fixed translation for potion mix loading.

## [0.1.2](https://github.com/AllayMC/Allay/releases/tag/0.1.2) (API 0.3.0) - 2024-12-31

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ public static class GenericSettings extends OkaeriConfig {
private boolean isWhitelisted = false;

@Comment("Whether to display the GUI")
@CustomKey("enable-gui")
private boolean enableGui = true;

@CustomKey("max-compute-thread-count")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
Expand All @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import io.netty.channel.socket.DatagramChannel;
import io.netty.channel.socket.nio.NioDatagramChannel;
import lombok.extern.slf4j.Slf4j;
import org.allaymc.api.AllayAPI;
import org.allaymc.api.entity.type.EntityTypes;
import org.allaymc.api.eventbus.event.network.ClientConnectEvent;
import org.allaymc.api.i18n.I18n;
Expand Down Expand Up @@ -75,7 +76,7 @@ public void start() {
this.channel = new ServerBootstrap()
.channelFactory(RakChannelFactory.server(datagramChannelClass))
.option(RakChannelOption.RAK_ADVERTISEMENT, pong.toByteBuf())
.option(RakChannelOption.RAK_PACKET_LIMIT, 1000) // This option fixed localhost blocking address
.option(RakChannelOption.RAK_PACKET_LIMIT, AllayAPI.getInstance().isDevBuild() ? Integer.MAX_VALUE : 120) // This option fixed localhost blocking address
.group(eventLoopGroup)
.childHandler(new BedrockServerInitializer() {
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
public class PotionMixRecipeRegistryLoader implements RegistryLoader<Void, Map<Identifier, PotionMixRecipe>> {
@Override
public Map<Identifier, PotionMixRecipe> load(Void $) {
log.info(TrKeys.A_RECIPE_POTIONMIX_LOADING);
log.info(I18n.get().tr(TrKeys.A_RECIPE_POTIONMIX_LOADING));
var stream = Objects.requireNonNull(Utils.getResource("recipes.json"));

var obj = JsonParser.parseReader(new InputStreamReader(stream)).getAsJsonObject();
Expand Down

0 comments on commit f45f9a8

Please sign in to comment.