mirror of
https://github.com/nimsolated/Nims-Random-BS.git
synced 2026-04-02 10:20:42 -07:00
feature: add mailbox naming for shipping labels
This commit is contained in:
@@ -21,9 +21,11 @@ import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.BlockGetter;
|
||||
import net.minecraft.world.item.context.BlockPlaceContext;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.inventory.AbstractContainerMenu;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.entity.player.Inventory;
|
||||
import net.minecraft.world.entity.LivingEntity;
|
||||
import net.minecraft.world.MenuProvider;
|
||||
import net.minecraft.world.InteractionResult;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
@@ -35,6 +37,7 @@ import net.minecraft.core.Direction;
|
||||
import net.minecraft.core.BlockPos;
|
||||
|
||||
import net.mcreator.nimsrandombullshit.world.inventory.MailboxGUIMenu;
|
||||
import net.mcreator.nimsrandombullshit.procedures.MailboxBlockIsPlacedByProcedure;
|
||||
import net.mcreator.nimsrandombullshit.block.entity.MailboxBlockEntity;
|
||||
|
||||
import io.netty.buffer.Unpooled;
|
||||
@@ -81,6 +84,12 @@ public class MailboxBlock extends Block implements EntityBlock {
|
||||
return state.rotate(mirrorIn.getRotation(state.getValue(FACING)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPlacedBy(Level world, BlockPos pos, BlockState blockstate, LivingEntity entity, ItemStack itemstack) {
|
||||
super.setPlacedBy(world, pos, blockstate, entity, itemstack);
|
||||
MailboxBlockIsPlacedByProcedure.execute(world, pos.getX(), pos.getY(), pos.getZ(), entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public InteractionResult use(BlockState blockstate, Level world, BlockPos pos, Player entity, InteractionHand hand, BlockHitResult hit) {
|
||||
super.use(blockstate, world, pos, entity, hand, hit);
|
||||
|
||||
@@ -0,0 +1,101 @@
|
||||
package net.mcreator.nimsrandombullshit.client.gui;
|
||||
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.entity.player.Inventory;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen;
|
||||
import net.minecraft.client.gui.components.EditBox;
|
||||
import net.minecraft.client.gui.components.Button;
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import net.minecraft.client.Minecraft;
|
||||
|
||||
import net.mcreator.nimsrandombullshit.world.inventory.MailboxNameEntryGUIMenu;
|
||||
import net.mcreator.nimsrandombullshit.network.MailboxNameEntryGUIButtonMessage;
|
||||
import net.mcreator.nimsrandombullshit.NimsRandomBullshitMod;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
|
||||
public class MailboxNameEntryGUIScreen extends AbstractContainerScreen<MailboxNameEntryGUIMenu> {
|
||||
private final static HashMap<String, Object> guistate = MailboxNameEntryGUIMenu.guistate;
|
||||
private final Level world;
|
||||
private final int x, y, z;
|
||||
private final Player entity;
|
||||
EditBox mailbox_name_field;
|
||||
Button button_done;
|
||||
|
||||
public MailboxNameEntryGUIScreen(MailboxNameEntryGUIMenu container, Inventory inventory, Component text) {
|
||||
super(container, inventory, text);
|
||||
this.world = container.world;
|
||||
this.x = container.x;
|
||||
this.y = container.y;
|
||||
this.z = container.z;
|
||||
this.entity = container.entity;
|
||||
this.imageWidth = 176;
|
||||
this.imageHeight = 166;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTicks) {
|
||||
this.renderBackground(guiGraphics);
|
||||
super.render(guiGraphics, mouseX, mouseY, partialTicks);
|
||||
mailbox_name_field.render(guiGraphics, mouseX, mouseY, partialTicks);
|
||||
this.renderTooltip(guiGraphics, mouseX, mouseY);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void renderBg(GuiGraphics guiGraphics, float partialTicks, int gx, int gy) {
|
||||
RenderSystem.setShaderColor(1, 1, 1, 1);
|
||||
RenderSystem.enableBlend();
|
||||
RenderSystem.defaultBlendFunc();
|
||||
RenderSystem.disableBlend();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean keyPressed(int key, int b, int c) {
|
||||
if (key == 256) {
|
||||
this.minecraft.player.closeContainer();
|
||||
return true;
|
||||
}
|
||||
if (mailbox_name_field.isFocused())
|
||||
return mailbox_name_field.keyPressed(key, b, c);
|
||||
return super.keyPressed(key, b, c);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void containerTick() {
|
||||
super.containerTick();
|
||||
mailbox_name_field.tick();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resize(Minecraft minecraft, int width, int height) {
|
||||
String mailbox_name_fieldValue = mailbox_name_field.getValue();
|
||||
super.resize(minecraft, width, height);
|
||||
mailbox_name_field.setValue(mailbox_name_fieldValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void renderLabels(GuiGraphics guiGraphics, int mouseX, int mouseY) {
|
||||
guiGraphics.drawString(this.font, Component.translatable("gui.nims_random_bullshit.mailbox_name_entry_gui.label_mailbox_name"), 51, 48, -16724839, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
super.init();
|
||||
mailbox_name_field = new EditBox(this.font, this.leftPos + 30, this.topPos + 62, 118, 18, Component.translatable("gui.nims_random_bullshit.mailbox_name_entry_gui.mailbox_name_field"));
|
||||
mailbox_name_field.setMaxLength(32767);
|
||||
guistate.put("text:mailbox_name_field", mailbox_name_field);
|
||||
this.addWidget(this.mailbox_name_field);
|
||||
button_done = Button.builder(Component.translatable("gui.nims_random_bullshit.mailbox_name_entry_gui.button_done"), e -> {
|
||||
if (true) {
|
||||
NimsRandomBullshitMod.PACKET_HANDLER.sendToServer(new MailboxNameEntryGUIButtonMessage(0, x, y, z));
|
||||
MailboxNameEntryGUIButtonMessage.handleButtonAction(entity, 0, x, y, z);
|
||||
}
|
||||
}).bounds(this.leftPos + 65, this.topPos + 93, 46, 20).build();
|
||||
guistate.put("button:button_done", button_done);
|
||||
this.addRenderableWidget(button_done);
|
||||
}
|
||||
}
|
||||
@@ -13,6 +13,7 @@ import net.minecraft.world.inventory.MenuType;
|
||||
|
||||
import net.mcreator.nimsrandombullshit.world.inventory.ShitGUIMenu;
|
||||
import net.mcreator.nimsrandombullshit.world.inventory.OreMinerGUIMenu;
|
||||
import net.mcreator.nimsrandombullshit.world.inventory.MailboxNameEntryGUIMenu;
|
||||
import net.mcreator.nimsrandombullshit.world.inventory.MailboxGUIMenu;
|
||||
import net.mcreator.nimsrandombullshit.NimsRandomBullshitMod;
|
||||
|
||||
@@ -21,4 +22,5 @@ public class NimsRandomBullshitModMenus {
|
||||
public static final RegistryObject<MenuType<ShitGUIMenu>> SHIT_GUI = REGISTRY.register("shit_gui", () -> IForgeMenuType.create(ShitGUIMenu::new));
|
||||
public static final RegistryObject<MenuType<OreMinerGUIMenu>> ORE_MINER_GUI = REGISTRY.register("ore_miner_gui", () -> IForgeMenuType.create(OreMinerGUIMenu::new));
|
||||
public static final RegistryObject<MenuType<MailboxGUIMenu>> MAILBOX_GUI = REGISTRY.register("mailbox_gui", () -> IForgeMenuType.create(MailboxGUIMenu::new));
|
||||
public static final RegistryObject<MenuType<MailboxNameEntryGUIMenu>> MAILBOX_NAME_ENTRY_GUI = REGISTRY.register("mailbox_name_entry_gui", () -> IForgeMenuType.create(MailboxNameEntryGUIMenu::new));
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ import net.minecraft.client.gui.screens.MenuScreens;
|
||||
|
||||
import net.mcreator.nimsrandombullshit.client.gui.ShitGUIScreen;
|
||||
import net.mcreator.nimsrandombullshit.client.gui.OreMinerGUIScreen;
|
||||
import net.mcreator.nimsrandombullshit.client.gui.MailboxNameEntryGUIScreen;
|
||||
import net.mcreator.nimsrandombullshit.client.gui.MailboxGUIScreen;
|
||||
|
||||
@Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.MOD, value = Dist.CLIENT)
|
||||
@@ -23,6 +24,7 @@ public class NimsRandomBullshitModScreens {
|
||||
MenuScreens.register(NimsRandomBullshitModMenus.SHIT_GUI.get(), ShitGUIScreen::new);
|
||||
MenuScreens.register(NimsRandomBullshitModMenus.ORE_MINER_GUI.get(), OreMinerGUIScreen::new);
|
||||
MenuScreens.register(NimsRandomBullshitModMenus.MAILBOX_GUI.get(), MailboxGUIScreen::new);
|
||||
MenuScreens.register(NimsRandomBullshitModMenus.MAILBOX_NAME_ENTRY_GUI.get(), MailboxNameEntryGUIScreen::new);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,75 @@
|
||||
|
||||
package net.mcreator.nimsrandombullshit.network;
|
||||
|
||||
import net.minecraftforge.network.NetworkEvent;
|
||||
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import net.minecraft.core.BlockPos;
|
||||
|
||||
import net.mcreator.nimsrandombullshit.world.inventory.MailboxNameEntryGUIMenu;
|
||||
import net.mcreator.nimsrandombullshit.procedures.MailboxNameEntryButtonPressedProcedure;
|
||||
import net.mcreator.nimsrandombullshit.NimsRandomBullshitMod;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
import java.util.HashMap;
|
||||
|
||||
@Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.MOD)
|
||||
public class MailboxNameEntryGUIButtonMessage {
|
||||
private final int buttonID, x, y, z;
|
||||
|
||||
public MailboxNameEntryGUIButtonMessage(FriendlyByteBuf buffer) {
|
||||
this.buttonID = buffer.readInt();
|
||||
this.x = buffer.readInt();
|
||||
this.y = buffer.readInt();
|
||||
this.z = buffer.readInt();
|
||||
}
|
||||
|
||||
public MailboxNameEntryGUIButtonMessage(int buttonID, int x, int y, int z) {
|
||||
this.buttonID = buttonID;
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
}
|
||||
|
||||
public static void buffer(MailboxNameEntryGUIButtonMessage message, FriendlyByteBuf buffer) {
|
||||
buffer.writeInt(message.buttonID);
|
||||
buffer.writeInt(message.x);
|
||||
buffer.writeInt(message.y);
|
||||
buffer.writeInt(message.z);
|
||||
}
|
||||
|
||||
public static void handler(MailboxNameEntryGUIButtonMessage message, Supplier<NetworkEvent.Context> contextSupplier) {
|
||||
NetworkEvent.Context context = contextSupplier.get();
|
||||
context.enqueueWork(() -> {
|
||||
Player entity = context.getSender();
|
||||
int buttonID = message.buttonID;
|
||||
int x = message.x;
|
||||
int y = message.y;
|
||||
int z = message.z;
|
||||
handleButtonAction(entity, buttonID, x, y, z);
|
||||
});
|
||||
context.setPacketHandled(true);
|
||||
}
|
||||
|
||||
public static void handleButtonAction(Player entity, int buttonID, int x, int y, int z) {
|
||||
Level world = entity.level();
|
||||
HashMap guistate = MailboxNameEntryGUIMenu.guistate;
|
||||
// security measure to prevent arbitrary chunk generation
|
||||
if (!world.hasChunkAt(new BlockPos(x, y, z)))
|
||||
return;
|
||||
if (buttonID == 0) {
|
||||
|
||||
MailboxNameEntryButtonPressedProcedure.execute(world, x, y, z, entity, guistate);
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public static void registerMessage(FMLCommonSetupEvent event) {
|
||||
NimsRandomBullshitMod.addNetworkMessage(MailboxNameEntryGUIButtonMessage.class, MailboxNameEntryGUIButtonMessage::buffer, MailboxNameEntryGUIButtonMessage::new, MailboxNameEntryGUIButtonMessage::handler);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package net.mcreator.nimsrandombullshit.procedures;
|
||||
|
||||
import net.minecraftforge.network.NetworkHooks;
|
||||
|
||||
import net.minecraft.world.level.LevelAccessor;
|
||||
import net.minecraft.world.inventory.AbstractContainerMenu;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.entity.player.Inventory;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.MenuProvider;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import net.minecraft.core.BlockPos;
|
||||
|
||||
import net.mcreator.nimsrandombullshit.world.inventory.MailboxNameEntryGUIMenu;
|
||||
|
||||
import io.netty.buffer.Unpooled;
|
||||
|
||||
public class MailboxBlockIsPlacedByProcedure {
|
||||
public static void execute(LevelAccessor world, double x, double y, double z, Entity entity) {
|
||||
if (entity == null)
|
||||
return;
|
||||
if (!world.isClientSide()) {
|
||||
if (entity instanceof ServerPlayer _ent) {
|
||||
BlockPos _bpos = BlockPos.containing(x, y, z);
|
||||
NetworkHooks.openScreen((ServerPlayer) _ent, new MenuProvider() {
|
||||
@Override
|
||||
public Component getDisplayName() {
|
||||
return Component.literal("MailboxNameEntryGUI");
|
||||
}
|
||||
|
||||
@Override
|
||||
public AbstractContainerMenu createMenu(int id, Inventory inventory, Player player) {
|
||||
return new MailboxNameEntryGUIMenu(id, inventory, new FriendlyByteBuf(Unpooled.buffer()).writeBlockPos(_bpos));
|
||||
}
|
||||
}, _bpos);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package net.mcreator.nimsrandombullshit.procedures;
|
||||
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.LevelAccessor;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.client.gui.components.EditBox;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
public class MailboxNameEntryButtonPressedProcedure {
|
||||
public static void execute(LevelAccessor world, double x, double y, double z, Entity entity, HashMap guistate) {
|
||||
if (entity == null || guistate == null)
|
||||
return;
|
||||
if (!world.isClientSide()) {
|
||||
if (!world.isClientSide()) {
|
||||
BlockPos _bp = BlockPos.containing(x, y, z);
|
||||
BlockEntity _blockEntity = world.getBlockEntity(_bp);
|
||||
BlockState _bs = world.getBlockState(_bp);
|
||||
if (_blockEntity != null)
|
||||
_blockEntity.getPersistentData().putString("mailbox_name", (guistate.containsKey("text:mailbox_name_field") ? ((EditBox) guistate.get("text:mailbox_name_field")).getValue() : ""));
|
||||
if (world instanceof Level _level)
|
||||
_level.sendBlockUpdated(_bp, _bs, _bs, 3);
|
||||
}
|
||||
if (entity instanceof Player _player)
|
||||
_player.closeContainer();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package net.mcreator.nimsrandombullshit.procedures;
|
||||
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.LevelAccessor;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.client.gui.components.EditBox;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
public class MailboxNameEntryGUIThisGUIIsClosedProcedure {
|
||||
public static void execute(LevelAccessor world, double x, double y, double z, HashMap guistate) {
|
||||
if (guistate == null)
|
||||
return;
|
||||
if (!world.isClientSide()) {
|
||||
if ((guistate.containsKey("text:mailbox_name_field") ? ((EditBox) guistate.get("text:mailbox_name_field")).getValue() : "").equals("")) {
|
||||
if (!world.isClientSide()) {
|
||||
BlockPos _bp = BlockPos.containing(x, y, z);
|
||||
BlockEntity _blockEntity = world.getBlockEntity(_bp);
|
||||
BlockState _bs = world.getBlockState(_bp);
|
||||
if (_blockEntity != null)
|
||||
_blockEntity.getPersistentData().putString("mailbox_name", "Unnamed");
|
||||
if (world instanceof Level _level)
|
||||
_level.sendBlockUpdated(_bp, _bs, _bs, 3);
|
||||
}
|
||||
} else {
|
||||
if (!world.isClientSide()) {
|
||||
BlockPos _bp = BlockPos.containing(x, y, z);
|
||||
BlockEntity _blockEntity = world.getBlockEntity(_bp);
|
||||
BlockState _bs = world.getBlockState(_bp);
|
||||
if (_blockEntity != null)
|
||||
_blockEntity.getPersistentData().putString("mailbox_name", (guistate.containsKey("text:mailbox_name_field") ? ((EditBox) guistate.get("text:mailbox_name_field")).getValue() : ""));
|
||||
if (world instanceof Level _level)
|
||||
_level.sendBlockUpdated(_bp, _bs, _bs, 3);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@ package net.mcreator.nimsrandombullshit.procedures;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.LevelAccessor;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
@@ -11,6 +12,7 @@ import net.minecraft.util.RandomSource;
|
||||
import net.minecraft.util.Mth;
|
||||
import net.minecraft.sounds.SoundSource;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.core.BlockPos;
|
||||
|
||||
import net.mcreator.nimsrandombullshit.init.NimsRandomBullshitModBlocks;
|
||||
@@ -25,6 +27,14 @@ public class ShippingLabelRightclickedOnBlockProcedure {
|
||||
itemstack.getOrCreateTag().putDouble("connected_mailbox_y", y);
|
||||
itemstack.getOrCreateTag().putDouble("connected_mailbox_z", z);
|
||||
itemstack.getOrCreateTag().putBoolean("connected", true);
|
||||
itemstack.setHoverName(Component.literal(((new Object() {
|
||||
public String getValue(LevelAccessor world, BlockPos pos, String tag) {
|
||||
BlockEntity blockEntity = world.getBlockEntity(pos);
|
||||
if (blockEntity != null)
|
||||
return blockEntity.getPersistentData().getString(tag);
|
||||
return "";
|
||||
}
|
||||
}.getValue(world, BlockPos.containing(x, y, z), "mailbox_name")) + "'s Mailbox")));
|
||||
if (world instanceof Level _level) {
|
||||
if (!_level.isClientSide()) {
|
||||
_level.playSound(null, BlockPos.containing(x, y, z), ForgeRegistries.SOUND_EVENTS.getValue(new ResourceLocation("entity.player.levelup")), SoundSource.PLAYERS, (float) 0.75,
|
||||
|
||||
@@ -0,0 +1,81 @@
|
||||
|
||||
package net.mcreator.nimsrandombullshit.world.inventory;
|
||||
|
||||
import net.minecraftforge.items.ItemStackHandler;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.inventory.Slot;
|
||||
import net.minecraft.world.inventory.ContainerLevelAccess;
|
||||
import net.minecraft.world.inventory.AbstractContainerMenu;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.entity.player.Inventory;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import net.minecraft.core.BlockPos;
|
||||
|
||||
import net.mcreator.nimsrandombullshit.procedures.MailboxNameEntryGUIThisGUIIsClosedProcedure;
|
||||
import net.mcreator.nimsrandombullshit.init.NimsRandomBullshitModMenus;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
|
||||
public class MailboxNameEntryGUIMenu extends AbstractContainerMenu implements Supplier<Map<Integer, Slot>> {
|
||||
public final static HashMap<String, Object> guistate = new HashMap<>();
|
||||
public final Level world;
|
||||
public final Player entity;
|
||||
public int x, y, z;
|
||||
private ContainerLevelAccess access = ContainerLevelAccess.NULL;
|
||||
private IItemHandler internal;
|
||||
private final Map<Integer, Slot> customSlots = new HashMap<>();
|
||||
private boolean bound = false;
|
||||
private Supplier<Boolean> boundItemMatcher = null;
|
||||
private Entity boundEntity = null;
|
||||
private BlockEntity boundBlockEntity = null;
|
||||
|
||||
public MailboxNameEntryGUIMenu(int id, Inventory inv, FriendlyByteBuf extraData) {
|
||||
super(NimsRandomBullshitModMenus.MAILBOX_NAME_ENTRY_GUI.get(), id);
|
||||
this.entity = inv.player;
|
||||
this.world = inv.player.level();
|
||||
this.internal = new ItemStackHandler(0);
|
||||
BlockPos pos = null;
|
||||
if (extraData != null) {
|
||||
pos = extraData.readBlockPos();
|
||||
this.x = pos.getX();
|
||||
this.y = pos.getY();
|
||||
this.z = pos.getZ();
|
||||
access = ContainerLevelAccess.create(world, pos);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean stillValid(Player player) {
|
||||
if (this.bound) {
|
||||
if (this.boundItemMatcher != null)
|
||||
return this.boundItemMatcher.get();
|
||||
else if (this.boundBlockEntity != null)
|
||||
return AbstractContainerMenu.stillValid(this.access, player, this.boundBlockEntity.getBlockState().getBlock());
|
||||
else if (this.boundEntity != null)
|
||||
return this.boundEntity.isAlive();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack quickMoveStack(Player playerIn, int index) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removed(Player playerIn) {
|
||||
super.removed(playerIn);
|
||||
MailboxNameEntryGUIThisGUIIsClosedProcedure.execute(world, x, y, z, guistate);
|
||||
}
|
||||
|
||||
public Map<Integer, Slot> get() {
|
||||
return customSlots;
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@
|
||||
"item.nims_random_bullshit.gravedigger": "Gravedigger",
|
||||
"fluid.nims_random_bullshit.netherrack_juice": "Netherrack Juice",
|
||||
"item.nims_random_bullshit.star_wand": "Star Wand",
|
||||
"gui.nims_random_bullshit.mailbox_name_entry_gui.button_done": "Done",
|
||||
"block.nims_random_bullshit.quadra_condensed_netherrack": "Quadra-condensed Netherrack",
|
||||
"gui.nims_random_bullshit.ore_miner_gui.button_mine": "Mine",
|
||||
"gui.nims_random_bullshit.mailbox_gui.outbox_z_coord": "0",
|
||||
@@ -20,6 +21,7 @@
|
||||
"block.nims_random_bullshit.netherrack_juice": "Netherrack Juice",
|
||||
"effect.nims_random_bullshit.summoned_entity_effect": "Summoned Entity",
|
||||
"item.nims_random_bullshit.sand_dust": "Sand Dust",
|
||||
"gui.nims_random_bullshit.mailbox_name_entry_gui.mailbox_name_field": "",
|
||||
"item.nims_random_bullshit.magic_flesh": "Magic Flesh",
|
||||
"item.nims_random_bullshit.ghoul_spawn_egg": "Ghoul Spawn Egg",
|
||||
"item.nims_random_bullshit.shipping_label": "Shipping Label",
|
||||
@@ -41,6 +43,7 @@
|
||||
"block.nims_random_bullshit.mailbox": "Mailbox",
|
||||
"gui.nims_random_bullshit.mailbox_gui.button_send": "Send",
|
||||
"gui.nims_random_bullshit.mailbox_gui.outbox_y_coord": "0",
|
||||
"gui.nims_random_bullshit.mailbox_name_entry_gui.label_mailbox_name": "Mailbox Name:",
|
||||
"gui.nims_random_bullshit.mailbox_gui.label_inbox": "Inbox",
|
||||
"item.nims_random_bullshit.netherrackite": "Netherrackite Ingot"
|
||||
}
|
||||
Reference in New Issue
Block a user