Skip to content

Commit

Permalink
1.0.5
Browse files Browse the repository at this point in the history
  • Loading branch information
MarbleGateKeeper committed Oct 22, 2024
1 parent be632cf commit 5a22205
Show file tree
Hide file tree
Showing 12 changed files with 179 additions and 117 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ permissions:
env:
MINECRAFT_VERSION: 1.20.1
JAVA_VERSION: 17
VERSION: 1.0.4.b
VERSION: 1.0.5

jobs:
release:
Expand Down
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ providing full fabric-3.0.2 version features in 1.19.2+ forge version and built-
Reasons are simple:
* New ways to interact (e.g. Place Beer in Bartending Table and see it)
* (Partial) Automation support by implementing Capability (e.g. Hopper supports Bartending Table)
* Extension and Compat With Other Mods (e.g. Keg support Alcocraft Recipe) `This is now suspended since alcocraft 1.19.2 crash problem, See issue Alcocraft#10`

## Credit
Thank following people for their amazing ground works!
Expand Down
12 changes: 12 additions & 0 deletions changelog/1.0.5.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
## Drink Beer Refill 1.0.5

### Bugfix
- Fix TradeBox Exploit issue
- Fix Bartering Box Re-roll fail issue
- Remove Redundant Catalan File

### Update
- Add Spanish Localization by ramonaflower
- Add Traditional Chinese Localization by dirtTW


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 version info
mod_version = 1.0.4.b
mod_version = 1.0.5
artifact_minecraft_version = 1.20.1
minecraft_version = 1.20.1
forge_version = 47.0.1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import lekavar.lma.drinkbeer.utils.tradebox.Locations;
import lekavar.lma.drinkbeer.utils.tradebox.Residents;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.core.NonNullList;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.chat.Component;
Expand All @@ -18,6 +19,9 @@
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.entity.BaseContainerBlockEntity;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.common.util.LazyOptional;
import org.jetbrains.annotations.NotNull;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;
Expand Down Expand Up @@ -89,6 +93,7 @@ public void set(int index, int value) {
process = value;
break;
}
setChanged();
}

@Override
Expand All @@ -98,29 +103,34 @@ public int getCount() {
};

@Override
public Component getDisplayName() {
public @NotNull Component getDisplayName() {
return Component.translatable("block.drinkbeer.trade_box_normal");
}

@Override
protected Component getDefaultName() {
protected @NotNull Component getDefaultName() {
return Component.translatable("block.drinkbeer.trade_box_normal");
}

@Nullable
@Override
public AbstractContainerMenu createMenu(int id, Inventory inventory, Player player) {
public AbstractContainerMenu createMenu(int id, @NotNull Inventory inventory, @NotNull Player player) {
this.screenHandler = new TradeBoxMenu(id, this, syncData, inventory, this);
return this.screenHandler;
}

@Override
protected AbstractContainerMenu createMenu(int id, Inventory inventory) {
protected @NotNull AbstractContainerMenu createMenu(int id, @NotNull Inventory inventory) {
return null;
}

@Override
public void saveAdditional(CompoundTag tag) {
public <T> @NotNull LazyOptional<T> getCapability(@NotNull Capability<T> cap, @Nullable Direction side) {
return LazyOptional.empty();
}

@Override
public void saveAdditional(@NotNull CompoundTag tag) {
super.saveAdditional(tag);

ContainerHelper.saveAllItems(tag, this.goodInventory);
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/lekavar/lma/drinkbeer/gui/TradeBoxMenu.java
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ public void removed(Player player) {
// Return Item to Player;
clearContainer(player, this.tradeboxInventory);
} else {
player.level().playSound((Player) null, player.blockPosition(), SoundEventRegistry.TRADEBOX_CLOSE.get(), SoundSource.BLOCKS, 0.6f, 1f);
player.level().playSound(null, player.blockPosition(), SoundEventRegistry.TRADEBOX_CLOSE.get(), SoundSource.BLOCKS, 0.6f, 1f);
}
}

Expand Down Expand Up @@ -314,7 +314,7 @@ public void setTradeboxTrading() {
TradeMission tradeMission = new TradeMission();
try {
Block block = player.level().getBlockState(pos).getBlock();
if (block.asItem().equals(BlockRegistry.TRADE_BOX.get().asItem())) {
if (block.equals(BlockRegistry.TRADE_BOX.get())) {
tradeMission = TradeMission.genRandomTradeMission();
}
/*else if(block.asItem().equals(DrinkBeer.TRADE_BOX_NORTHON.asItem()){
Expand Down
36 changes: 20 additions & 16 deletions src/main/java/lekavar/lma/drinkbeer/networking/NetWorking.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import lekavar.lma.drinkbeer.gui.TradeBoxMenu;
import lekavar.lma.drinkbeer.networking.messages.RefreshTradeBoxMessage;
import lekavar.lma.drinkbeer.registries.NetworkingRegistry;
import lekavar.lma.drinkbeer.utils.ChannelHelper;
import net.minecraft.core.BlockPos;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.inventory.AbstractContainerMenu;
Expand All @@ -16,28 +15,33 @@
public class NetWorking {

public static void init(FMLCommonSetupEvent event) {
ChannelHelper.RegisterMessage(
NetworkingRegistry.MAIN.registerMessage(
NetworkingRegistry.SEND_REFRESH_TRADEBOX,
RefreshTradeBoxMessage.class,
RefreshTradeBoxMessage::toBytes,
RefreshTradeBoxMessage::fromBytes,
(RefreshTradeBoxMessage msg, Supplier<NetworkEvent.Context> ctx) -> {
NetworkEvent.Context context = ctx.get();
ServerPlayer player = context.getSender();
if (player == null) {
return;
}
AbstractContainerMenu screenContainer = player.containerMenu;
if (screenContainer instanceof TradeBoxMenu) {
BlockPos pos = msg.getPos();
context.enqueueWork(() -> {
TradeBoxBlockEntity tradeboxEntity = (TradeBoxBlockEntity) player.level().getBlockEntity(pos);
tradeboxEntity.screenHandler.setTradeboxCooling();
});
}
ctx.get().enqueueWork(()->{
ServerPlayer player = ctx.get().getSender();
if (player == null) {
return;
}
AbstractContainerMenu screenContainer = player.containerMenu;
if (screenContainer instanceof TradeBoxMenu) {
BlockPos pos = msg.getPos();
if(player.level().hasChunkAt(pos)){
TradeBoxBlockEntity tradeboxEntity = (TradeBoxBlockEntity) player.level().getBlockEntity(pos);
tradeboxEntity.screenHandler.setTradeboxCooling();
tradeboxEntity.setChanged();
}
}
});
ctx.get().setPacketHandled(true);
});
}

public static void sendRefreshTradebox(BlockPos pos) {
ChannelHelper.DEFAULT_CHANNEL.sendToServer(
NetworkingRegistry.MAIN.sendToServer(
new RefreshTradeBoxMessage(pos)
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import net.minecraft.core.BlockPos;
import net.minecraft.network.FriendlyByteBuf;

public class RefreshTradeBoxMessage extends Message {
public class RefreshTradeBoxMessage {
private BlockPos pos;

public RefreshTradeBoxMessage(BlockPos pos) {
Expand All @@ -15,13 +15,11 @@ public BlockPos getPos() {
return pos;
}

@Override
public void fromBytes(FriendlyByteBuf packetBuffer) {
pos = packetBuffer.readBlockPos();
public static RefreshTradeBoxMessage fromBytes(FriendlyByteBuf packetBuffer) {
return new RefreshTradeBoxMessage(packetBuffer.readBlockPos());
}

@Override
public void toBytes(FriendlyByteBuf packetBuffer) {
packetBuffer.writeBlockPos(pos);
public static void toBytes(RefreshTradeBoxMessage message,FriendlyByteBuf packetBuffer) {
packetBuffer.writeBlockPos(message.pos);
}
}
42 changes: 0 additions & 42 deletions src/main/java/lekavar/lma/drinkbeer/utils/ChannelHelper.java

This file was deleted.

2 changes: 1 addition & 1 deletion src/main/java/lekavar/lma/drinkbeer/utils/Message.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import net.minecraft.network.FriendlyByteBuf;

public abstract class Message {
public abstract void fromBytes(FriendlyByteBuf packetBuffer);
public abstract Message fromBytes(FriendlyByteBuf packetBuffer);

public abstract void toBytes(FriendlyByteBuf packetBuffer);
}
41 changes: 0 additions & 41 deletions src/main/resources/assets/drinkbeer/lang/es_ca.json

This file was deleted.

Loading

0 comments on commit 5a22205

Please sign in to comment.