From 2242c3551f066af2395c2c1b43c454b0812930e1 Mon Sep 17 00:00:00 2001 From: 17146 <1714673995@qq.com> Date: Sun, 15 Dec 2024 16:00:54 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=9E=E7=8E=B0=E4=BA=86=E5=BF=AB=E8=89=87?= =?UTF-8?q?=E7=9A=84=E7=89=A9=E5=93=81=E5=AD=98=E5=82=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../block/ReforgingTableBlock.java | 2 +- .../entity/ChargingStationBlockEntity.java | 2 +- .../client/screens/ChargingStationScreen.java | 2 +- .../client/screens/ReforgingTableScreen.java | 6 +- .../client/screens/SpeedboatScreen.java | 46 +++++ .../superbwarfare/entity/SpeedboatEntity.java | 162 +++++++++++++++++- .../superbwarfare/init/ModMenuTypes.java | 8 +- .../superbwarfare/init/ModScreens.java | 2 + .../{block => }/menu/ChargingStationMenu.java | 2 +- .../{block => }/menu/ReforgingTableMenu.java | 2 +- .../superbwarfare/menu/SpeedboatMenu.java | 80 +++++++++ .../network/ClientPacketHandler.java | 2 +- .../network/message/GunReforgeMessage.java | 2 +- .../network/message/SetPerkLevelMessage.java | 2 +- .../superbwarfare/textures/gui/speedboat.png | Bin 0 -> 1553 bytes 15 files changed, 301 insertions(+), 19 deletions(-) create mode 100644 src/main/java/com/atsuishio/superbwarfare/client/screens/SpeedboatScreen.java rename src/main/java/com/atsuishio/superbwarfare/{block => }/menu/ChargingStationMenu.java (99%) rename src/main/java/com/atsuishio/superbwarfare/{block => }/menu/ReforgingTableMenu.java (99%) create mode 100644 src/main/java/com/atsuishio/superbwarfare/menu/SpeedboatMenu.java create mode 100644 src/main/resources/assets/superbwarfare/textures/gui/speedboat.png diff --git a/src/main/java/com/atsuishio/superbwarfare/block/ReforgingTableBlock.java b/src/main/java/com/atsuishio/superbwarfare/block/ReforgingTableBlock.java index 7d0549ed8..67e729eb2 100644 --- a/src/main/java/com/atsuishio/superbwarfare/block/ReforgingTableBlock.java +++ b/src/main/java/com/atsuishio/superbwarfare/block/ReforgingTableBlock.java @@ -1,6 +1,6 @@ package com.atsuishio.superbwarfare.block; -import com.atsuishio.superbwarfare.block.menu.ReforgingTableMenu; +import com.atsuishio.superbwarfare.menu.ReforgingTableMenu; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.network.chat.Component; diff --git a/src/main/java/com/atsuishio/superbwarfare/block/entity/ChargingStationBlockEntity.java b/src/main/java/com/atsuishio/superbwarfare/block/entity/ChargingStationBlockEntity.java index c78045b15..7f56f6dd2 100644 --- a/src/main/java/com/atsuishio/superbwarfare/block/entity/ChargingStationBlockEntity.java +++ b/src/main/java/com/atsuishio/superbwarfare/block/entity/ChargingStationBlockEntity.java @@ -1,8 +1,8 @@ package com.atsuishio.superbwarfare.block.entity; -import com.atsuishio.superbwarfare.block.menu.ChargingStationMenu; import com.atsuishio.superbwarfare.entity.IChargeEntity; import com.atsuishio.superbwarfare.init.ModBlockEntities; +import com.atsuishio.superbwarfare.menu.ChargingStationMenu; import com.atsuishio.superbwarfare.network.dataslot.ContainerEnergyData; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; diff --git a/src/main/java/com/atsuishio/superbwarfare/client/screens/ChargingStationScreen.java b/src/main/java/com/atsuishio/superbwarfare/client/screens/ChargingStationScreen.java index 3173b219c..d87e20ae6 100644 --- a/src/main/java/com/atsuishio/superbwarfare/client/screens/ChargingStationScreen.java +++ b/src/main/java/com/atsuishio/superbwarfare/client/screens/ChargingStationScreen.java @@ -2,7 +2,7 @@ package com.atsuishio.superbwarfare.client.screens; import com.atsuishio.superbwarfare.ModUtils; import com.atsuishio.superbwarfare.block.entity.ChargingStationBlockEntity; -import com.atsuishio.superbwarfare.block.menu.ChargingStationMenu; +import com.atsuishio.superbwarfare.menu.ChargingStationMenu; import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen; import net.minecraft.network.chat.Component; diff --git a/src/main/java/com/atsuishio/superbwarfare/client/screens/ReforgingTableScreen.java b/src/main/java/com/atsuishio/superbwarfare/client/screens/ReforgingTableScreen.java index a6b87d64c..6882434bc 100644 --- a/src/main/java/com/atsuishio/superbwarfare/client/screens/ReforgingTableScreen.java +++ b/src/main/java/com/atsuishio/superbwarfare/client/screens/ReforgingTableScreen.java @@ -1,11 +1,11 @@ package com.atsuishio.superbwarfare.client.screens; +import com.atsuishio.superbwarfare.ModUtils; +import com.atsuishio.superbwarfare.menu.ReforgingTableMenu; import com.atsuishio.superbwarfare.network.message.GunReforgeMessage; import com.atsuishio.superbwarfare.network.message.SetPerkLevelMessage; -import com.mojang.blaze3d.systems.RenderSystem; -import com.atsuishio.superbwarfare.ModUtils; -import com.atsuishio.superbwarfare.block.menu.ReforgingTableMenu; import com.atsuishio.superbwarfare.perk.Perk; +import com.mojang.blaze3d.systems.RenderSystem; import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.gui.components.AbstractButton; import net.minecraft.client.gui.narration.NarrationElementOutput; diff --git a/src/main/java/com/atsuishio/superbwarfare/client/screens/SpeedboatScreen.java b/src/main/java/com/atsuishio/superbwarfare/client/screens/SpeedboatScreen.java new file mode 100644 index 000000000..f31c1ef71 --- /dev/null +++ b/src/main/java/com/atsuishio/superbwarfare/client/screens/SpeedboatScreen.java @@ -0,0 +1,46 @@ +package com.atsuishio.superbwarfare.client.screens; + +import com.atsuishio.superbwarfare.ModUtils; +import com.atsuishio.superbwarfare.menu.SpeedboatMenu; +import net.minecraft.client.gui.GuiGraphics; +import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen; +import net.minecraft.network.chat.Component; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.entity.player.Inventory; +import net.minecraftforge.api.distmarker.Dist; +import net.minecraftforge.api.distmarker.OnlyIn; + +@OnlyIn(Dist.CLIENT) +public class SpeedboatScreen extends AbstractContainerScreen { + + private static final ResourceLocation TEXTURE = ModUtils.loc("textures/gui/speedboat.png"); + + public SpeedboatScreen(SpeedboatMenu pMenu, Inventory pPlayerInventory, Component pTitle) { + super(pMenu, pPlayerInventory, pTitle); + imageWidth = 320; + imageHeight = 222; + } + + @Override + protected void renderBg(GuiGraphics pGuiGraphics, float pPartialTick, int pMouseX, int pMouseY) { + int i = (this.width - this.imageWidth) / 2; + int j = (this.height - this.imageHeight) / 2; + pGuiGraphics.blit(TEXTURE, i, j, 0, 0, this.imageWidth, this.imageHeight, 328, 328); + } + + @Override + public void render(GuiGraphics pGuiGraphics, int pMouseX, int pMouseY, float pPartialTick) { + this.renderBackground(pGuiGraphics); + super.render(pGuiGraphics, pMouseX, pMouseY, pPartialTick); + this.renderTooltip(pGuiGraphics, pMouseX, pMouseY); + } + + @Override + protected void init() { + super.init(); + this.titleLabelX = 8; + this.titleLabelY = 5; + this.inventoryLabelX = 80; + this.inventoryLabelY = 128; + } +} diff --git a/src/main/java/com/atsuishio/superbwarfare/entity/SpeedboatEntity.java b/src/main/java/com/atsuishio/superbwarfare/entity/SpeedboatEntity.java index 8b1e9ad50..07bac8b9f 100644 --- a/src/main/java/com/atsuishio/superbwarfare/entity/SpeedboatEntity.java +++ b/src/main/java/com/atsuishio/superbwarfare/entity/SpeedboatEntity.java @@ -6,6 +6,7 @@ import com.atsuishio.superbwarfare.config.server.ExplosionDestroyConfig; import com.atsuishio.superbwarfare.entity.projectile.ProjectileEntity; import com.atsuishio.superbwarfare.init.*; import com.atsuishio.superbwarfare.item.ContainerBlockItem; +import com.atsuishio.superbwarfare.menu.SpeedboatMenu; import com.atsuishio.superbwarfare.network.ModVariables; import com.atsuishio.superbwarfare.network.message.ShakeClientMessage; import com.atsuishio.superbwarfare.tools.CustomExplosion; @@ -13,42 +14,53 @@ import com.atsuishio.superbwarfare.tools.EntityFindUtil; import com.atsuishio.superbwarfare.tools.ParticleTool; import com.atsuishio.superbwarfare.tools.SoundTool; import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.core.NonNullList; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.protocol.Packet; import net.minecraft.network.protocol.game.ClientGamePacketListener; import net.minecraft.network.syncher.EntityDataAccessor; import net.minecraft.network.syncher.EntityDataSerializers; import net.minecraft.network.syncher.SynchedEntityData; +import net.minecraft.resources.ResourceLocation; import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; import net.minecraft.sounds.SoundEvent; import net.minecraft.sounds.SoundSource; import net.minecraft.util.Mth; +import net.minecraft.world.ContainerHelper; +import net.minecraft.world.Containers; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; import net.minecraft.world.damagesource.DamageSource; import net.minecraft.world.damagesource.DamageTypes; -import net.minecraft.world.entity.AreaEffectCloud; -import net.minecraft.world.entity.Entity; -import net.minecraft.world.entity.EntityType; -import net.minecraft.world.entity.MoverType; +import net.minecraft.world.entity.*; import net.minecraft.world.entity.item.ItemEntity; +import net.minecraft.world.entity.player.Inventory; import net.minecraft.world.entity.player.Player; import net.minecraft.world.entity.projectile.Projectile; import net.minecraft.world.entity.projectile.ThrownPotion; +import net.minecraft.world.entity.vehicle.ContainerEntity; +import net.minecraft.world.inventory.AbstractContainerMenu; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.Explosion; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.entity.EntityTypeTest; +import net.minecraft.world.level.gameevent.GameEvent; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; +import net.minecraftforge.common.capabilities.Capability; +import net.minecraftforge.common.capabilities.ForgeCapabilities; +import net.minecraftforge.common.util.LazyOptional; import net.minecraftforge.fluids.FluidType; +import net.minecraftforge.items.wrapper.InvWrapper; import net.minecraftforge.network.NetworkHooks; import net.minecraftforge.network.PacketDistributor; import net.minecraftforge.network.PlayMessages; import net.minecraftforge.registries.ForgeRegistries; +import org.jetbrains.annotations.Nullable; import org.joml.Math; import software.bernie.geckolib.animatable.GeoEntity; import software.bernie.geckolib.core.animatable.instance.AnimatableInstanceCache; @@ -61,7 +73,8 @@ import software.bernie.geckolib.util.GeckoLibUtil; import java.util.Comparator; -public class SpeedboatEntity extends Entity implements GeoEntity, IChargeEntity, IVehicleEntity { +public class SpeedboatEntity extends Entity implements GeoEntity, IChargeEntity, IVehicleEntity, HasCustomInventoryScreen, ContainerEntity { + public static final EntityDataAccessor HEALTH = SynchedEntityData.defineId(SpeedboatEntity.class, EntityDataSerializers.FLOAT); public static final EntityDataAccessor ENERGY = SynchedEntityData.defineId(SpeedboatEntity.class, EntityDataSerializers.FLOAT); public static final EntityDataAccessor ROT_Y = SynchedEntityData.defineId(SpeedboatEntity.class, EntityDataSerializers.FLOAT); @@ -73,6 +86,10 @@ public class SpeedboatEntity extends Entity implements GeoEntity, IChargeEntity, public static final float MAX_HEALTH = CannonConfig.SPEEDBOAT_HP.get(); public static final float MAX_ENERGY = CannonConfig.SPEEDBOAT_MAX_ENERGY.get().floatValue(); + public static final int CONTAINER_SIZE = 102; + + private NonNullList items = NonNullList.withSize(CONTAINER_SIZE, ItemStack.EMPTY); + private LazyOptional itemHandler = LazyOptional.of(() -> new InvWrapper(this)); private final AnimatableInstanceCache cache = GeckoLibUtil.createInstanceCache(this); private int lerpSteps; @@ -115,6 +132,7 @@ public class SpeedboatEntity extends Entity implements GeoEntity, IChargeEntity, compound.putFloat("Health", this.entityData.get(HEALTH)); compound.putFloat("Energy", this.entityData.get(ENERGY)); compound.putString("LastAttacker", this.entityData.get(LAST_ATTACKER_UUID)); + ContainerHelper.saveAllItems(compound, this.getItemStacks()); } @Override @@ -128,6 +146,7 @@ public class SpeedboatEntity extends Entity implements GeoEntity, IChargeEntity, if (compound.contains("LastAttacker")) { this.entityData.set(LAST_ATTACKER_UUID, compound.getString("LastAttacker")); } + ContainerHelper.loadAllItems(compound, this.getItemStacks()); } @Override @@ -163,6 +182,15 @@ public class SpeedboatEntity extends Entity implements GeoEntity, IChargeEntity, return super.getPassengersRidingOffset() - 1.3; } + @Override + public void remove(Entity.RemovalReason pReason) { + if (!this.level().isClientSide && pReason.shouldDestroy()) { + Containers.dropContents(this.level(), this, this); + } + + super.remove(pReason); + } + @Override public boolean hurt(DamageSource source, float amount) { if (this.level() instanceof ServerLevel serverLevel) { @@ -222,8 +250,10 @@ public class SpeedboatEntity extends Entity implements GeoEntity, IChargeEntity, } this.discard(); return InteractionResult.sidedSuccess(this.level().isClientSide()); + } else { + player.openMenu(this); + return !player.level().isClientSide ? InteractionResult.CONSUME : InteractionResult.SUCCESS; } - return InteractionResult.PASS; } else { player.startRiding(this); return InteractionResult.sidedSuccess(this.level().isClientSide()); @@ -603,4 +633,124 @@ public class SpeedboatEntity extends Entity implements GeoEntity, IChargeEntity, public void charge(int amount) { this.entityData.set(ENERGY, Math.min(this.entityData.get(ENERGY) + amount, MAX_ENERGY)); } + + @Override + public void openCustomInventoryScreen(Player pPlayer) { + pPlayer.openMenu(this); + if (!pPlayer.level().isClientSide) { + this.gameEvent(GameEvent.CONTAINER_OPEN, pPlayer); + } + } + + @Nullable + @Override + public ResourceLocation getLootTable() { + return null; + } + + @Override + public void setLootTable(@Nullable ResourceLocation pLootTable) { + } + + @Override + public long getLootTableSeed() { + return 0; + } + + @Override + public void setLootTableSeed(long pLootTableSeed) { + } + + @Override + public NonNullList getItemStacks() { + return this.items; + } + + @Override + public void clearItemStacks() { + this.items.clear(); + } + + @Override + public int getContainerSize() { + return CONTAINER_SIZE; + } + + @Override + public ItemStack getItem(int pSlot) { + return this.items.get(pSlot); + } + + @Override + public ItemStack removeItem(int pSlot, int pAmount) { + return ContainerHelper.removeItem(this.items, pSlot, pAmount); + } + + @Override + public ItemStack removeItemNoUpdate(int pSlot) { + ItemStack itemstack = this.getItemStacks().get(pSlot); + if (itemstack.isEmpty()) { + return ItemStack.EMPTY; + } else { + this.getItemStacks().set(pSlot, ItemStack.EMPTY); + return itemstack; + } + } + + @Override + public void setItem(int pSlot, ItemStack pStack) { + this.getItemStacks().set(pSlot, pStack); + if (!pStack.isEmpty() && pStack.getCount() > this.getMaxStackSize()) { + pStack.setCount(this.getMaxStackSize()); + } + } + + @Override + public void setChanged() { + } + + @Override + public boolean stillValid(Player pPlayer) { + return !this.isRemoved() && this.position().closerThan(pPlayer.position(), 8.0D); + } + + @Override + public void clearContent() { + this.getItemStacks().clear(); + } + + @Nullable + @Override + public AbstractContainerMenu createMenu(int pContainerId, Inventory pPlayerInventory, Player pPlayer) { + if (pPlayer.isSpectator()) { + return null; + } else { + return new SpeedboatMenu(pContainerId, pPlayerInventory, this); + } + } + + @Override + public LazyOptional getCapability(Capability capability, @Nullable Direction facing) { + if (this.isAlive() && capability == ForgeCapabilities.ITEM_HANDLER) { + return itemHandler.cast(); + } + return super.getCapability(capability, facing); + } + + @Override + public void invalidateCaps() { + super.invalidateCaps(); + itemHandler.invalidate(); + } + + @Override + public void reviveCaps() { + super.reviveCaps(); + itemHandler = LazyOptional.of(() -> new InvWrapper(this)); + } + + @Override + public void stopOpen(Player pPlayer) { + this.level().gameEvent(GameEvent.CONTAINER_CLOSE, this.position(), GameEvent.Context.of(pPlayer)); + } } diff --git a/src/main/java/com/atsuishio/superbwarfare/init/ModMenuTypes.java b/src/main/java/com/atsuishio/superbwarfare/init/ModMenuTypes.java index bb132d55b..ff9cddb84 100644 --- a/src/main/java/com/atsuishio/superbwarfare/init/ModMenuTypes.java +++ b/src/main/java/com/atsuishio/superbwarfare/init/ModMenuTypes.java @@ -1,8 +1,9 @@ package com.atsuishio.superbwarfare.init; import com.atsuishio.superbwarfare.ModUtils; -import com.atsuishio.superbwarfare.block.menu.ChargingStationMenu; -import com.atsuishio.superbwarfare.block.menu.ReforgingTableMenu; +import com.atsuishio.superbwarfare.menu.ChargingStationMenu; +import com.atsuishio.superbwarfare.menu.ReforgingTableMenu; +import com.atsuishio.superbwarfare.menu.SpeedboatMenu; import net.minecraft.world.inventory.MenuType; import net.minecraftforge.common.extensions.IForgeMenuType; import net.minecraftforge.registries.DeferredRegister; @@ -19,4 +20,7 @@ public class ModMenuTypes { public static final RegistryObject> CHARGING_STATION_MENU = REGISTRY.register("charging_station_menu", () -> IForgeMenuType.create((windowId, inv, data) -> new ChargingStationMenu(windowId, inv))); + public static final RegistryObject> SPEEDBOAT_MENU = + REGISTRY.register("speedboat_menu", + () -> IForgeMenuType.create((windowId, inv, data) -> new SpeedboatMenu(windowId, inv))); } diff --git a/src/main/java/com/atsuishio/superbwarfare/init/ModScreens.java b/src/main/java/com/atsuishio/superbwarfare/init/ModScreens.java index bedcc910c..fa4f4cc6d 100644 --- a/src/main/java/com/atsuishio/superbwarfare/init/ModScreens.java +++ b/src/main/java/com/atsuishio/superbwarfare/init/ModScreens.java @@ -2,6 +2,7 @@ package com.atsuishio.superbwarfare.init; import com.atsuishio.superbwarfare.client.screens.ChargingStationScreen; import com.atsuishio.superbwarfare.client.screens.ReforgingTableScreen; +import com.atsuishio.superbwarfare.client.screens.SpeedboatScreen; import net.minecraft.client.gui.screens.MenuScreens; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.eventbus.api.SubscribeEvent; @@ -16,6 +17,7 @@ public class ModScreens { event.enqueueWork(() -> { MenuScreens.register(ModMenuTypes.REFORGING_TABLE_MENU.get(), ReforgingTableScreen::new); MenuScreens.register(ModMenuTypes.CHARGING_STATION_MENU.get(), ChargingStationScreen::new); + MenuScreens.register(ModMenuTypes.SPEEDBOAT_MENU.get(), SpeedboatScreen::new); }); } } diff --git a/src/main/java/com/atsuishio/superbwarfare/block/menu/ChargingStationMenu.java b/src/main/java/com/atsuishio/superbwarfare/menu/ChargingStationMenu.java similarity index 99% rename from src/main/java/com/atsuishio/superbwarfare/block/menu/ChargingStationMenu.java rename to src/main/java/com/atsuishio/superbwarfare/menu/ChargingStationMenu.java index 2aadaa7c6..7e2c3e8d5 100644 --- a/src/main/java/com/atsuishio/superbwarfare/block/menu/ChargingStationMenu.java +++ b/src/main/java/com/atsuishio/superbwarfare/menu/ChargingStationMenu.java @@ -1,4 +1,4 @@ -package com.atsuishio.superbwarfare.block.menu; +package com.atsuishio.superbwarfare.menu; import com.atsuishio.superbwarfare.ModUtils; import com.atsuishio.superbwarfare.block.entity.ChargingStationBlockEntity; diff --git a/src/main/java/com/atsuishio/superbwarfare/block/menu/ReforgingTableMenu.java b/src/main/java/com/atsuishio/superbwarfare/menu/ReforgingTableMenu.java similarity index 99% rename from src/main/java/com/atsuishio/superbwarfare/block/menu/ReforgingTableMenu.java rename to src/main/java/com/atsuishio/superbwarfare/menu/ReforgingTableMenu.java index bc9937b2b..40c360269 100644 --- a/src/main/java/com/atsuishio/superbwarfare/block/menu/ReforgingTableMenu.java +++ b/src/main/java/com/atsuishio/superbwarfare/menu/ReforgingTableMenu.java @@ -1,4 +1,4 @@ -package com.atsuishio.superbwarfare.block.menu; +package com.atsuishio.superbwarfare.menu; import com.atsuishio.superbwarfare.init.ModBlocks; import com.atsuishio.superbwarfare.init.ModMenuTypes; diff --git a/src/main/java/com/atsuishio/superbwarfare/menu/SpeedboatMenu.java b/src/main/java/com/atsuishio/superbwarfare/menu/SpeedboatMenu.java new file mode 100644 index 000000000..703956d93 --- /dev/null +++ b/src/main/java/com/atsuishio/superbwarfare/menu/SpeedboatMenu.java @@ -0,0 +1,80 @@ +package com.atsuishio.superbwarfare.menu; + +import com.atsuishio.superbwarfare.entity.SpeedboatEntity; +import com.atsuishio.superbwarfare.init.ModMenuTypes; +import net.minecraft.world.Container; +import net.minecraft.world.SimpleContainer; +import net.minecraft.world.entity.player.Inventory; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.inventory.AbstractContainerMenu; +import net.minecraft.world.inventory.Slot; +import net.minecraft.world.item.ItemStack; + +public class SpeedboatMenu extends AbstractContainerMenu { + + private final Container container; + private final int containerRows; + + public static final int X_OFFSET = 72; + public static final int Y_OFFSET = 20; + + public SpeedboatMenu(int pContainerId, Inventory pPlayerInventory) { + this(pContainerId, pPlayerInventory, new SimpleContainer(SpeedboatEntity.CONTAINER_SIZE)); + } + + public SpeedboatMenu(int pContainerId, Inventory pPlayerInventory, Container pContainer) { + super(ModMenuTypes.SPEEDBOAT_MENU.get(), pContainerId); + + checkContainerSize(pContainer, SpeedboatEntity.CONTAINER_SIZE); + this.container = pContainer; + this.containerRows = 6; + pContainer.startOpen(pPlayerInventory.player); + int i = (this.containerRows - 4) * 18; + + for (int j = 0; j < this.containerRows; ++j) { + for (int k = 0; k < 17; ++k) { + this.addSlot(new Slot(pContainer, k + j * 9, 8 + k * 18, 18 + j * 18)); + } + } + + for (int l = 0; l < 3; ++l) { + for (int j = 0; j < 9; ++j) { + this.addSlot(new Slot(pPlayerInventory, j + l * 9 + 9, 8 + j * 18 + X_OFFSET, 84 + l * 18 + Y_OFFSET + i)); + } + } + + for (int k = 0; k < 9; ++k) { + this.addSlot(new Slot(pPlayerInventory, k, 8 + k * 18 + X_OFFSET, 142 + Y_OFFSET + i)); + } + } + + @Override + public ItemStack quickMoveStack(Player pPlayer, int pIndex) { + ItemStack itemstack = ItemStack.EMPTY; + Slot slot = this.slots.get(pIndex); + if (slot.hasItem()) { + ItemStack itemstack1 = slot.getItem(); + itemstack = itemstack1.copy(); + if (pIndex < this.containerRows * 17) { + if (!this.moveItemStackTo(itemstack1, this.containerRows * 17, this.slots.size(), true)) { + return ItemStack.EMPTY; + } + } else if (!this.moveItemStackTo(itemstack1, 0, this.containerRows * 17, false)) { + return ItemStack.EMPTY; + } + + if (itemstack1.isEmpty()) { + slot.setByPlayer(ItemStack.EMPTY); + } else { + slot.setChanged(); + } + } + + return itemstack; + } + + @Override + public boolean stillValid(Player pPlayer) { + return this.container.stillValid(pPlayer); + } +} diff --git a/src/main/java/com/atsuishio/superbwarfare/network/ClientPacketHandler.java b/src/main/java/com/atsuishio/superbwarfare/network/ClientPacketHandler.java index abfb101be..5e80f74a8 100644 --- a/src/main/java/com/atsuishio/superbwarfare/network/ClientPacketHandler.java +++ b/src/main/java/com/atsuishio/superbwarfare/network/ClientPacketHandler.java @@ -1,10 +1,10 @@ package com.atsuishio.superbwarfare.network; -import com.atsuishio.superbwarfare.block.menu.ChargingStationMenu; import com.atsuishio.superbwarfare.client.screens.CrossHairOverlay; import com.atsuishio.superbwarfare.client.screens.DroneUIOverlay; import com.atsuishio.superbwarfare.config.client.KillMessageConfig; import com.atsuishio.superbwarfare.event.KillMessageHandler; +import com.atsuishio.superbwarfare.menu.ChargingStationMenu; import com.atsuishio.superbwarfare.network.message.ClientIndicatorMessage; import com.atsuishio.superbwarfare.network.message.ContainerDataMessage; import com.atsuishio.superbwarfare.network.message.GunsDataMessage; diff --git a/src/main/java/com/atsuishio/superbwarfare/network/message/GunReforgeMessage.java b/src/main/java/com/atsuishio/superbwarfare/network/message/GunReforgeMessage.java index a49eb939e..c6de13e4e 100644 --- a/src/main/java/com/atsuishio/superbwarfare/network/message/GunReforgeMessage.java +++ b/src/main/java/com/atsuishio/superbwarfare/network/message/GunReforgeMessage.java @@ -1,6 +1,6 @@ package com.atsuishio.superbwarfare.network.message; -import com.atsuishio.superbwarfare.block.menu.ReforgingTableMenu; +import com.atsuishio.superbwarfare.menu.ReforgingTableMenu; import net.minecraft.network.FriendlyByteBuf; import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.inventory.AbstractContainerMenu; diff --git a/src/main/java/com/atsuishio/superbwarfare/network/message/SetPerkLevelMessage.java b/src/main/java/com/atsuishio/superbwarfare/network/message/SetPerkLevelMessage.java index f23841feb..7f2813e4c 100644 --- a/src/main/java/com/atsuishio/superbwarfare/network/message/SetPerkLevelMessage.java +++ b/src/main/java/com/atsuishio/superbwarfare/network/message/SetPerkLevelMessage.java @@ -1,6 +1,6 @@ package com.atsuishio.superbwarfare.network.message; -import com.atsuishio.superbwarfare.block.menu.ReforgingTableMenu; +import com.atsuishio.superbwarfare.menu.ReforgingTableMenu; import com.atsuishio.superbwarfare.perk.Perk; import net.minecraft.network.FriendlyByteBuf; import net.minecraft.server.level.ServerPlayer; diff --git a/src/main/resources/assets/superbwarfare/textures/gui/speedboat.png b/src/main/resources/assets/superbwarfare/textures/gui/speedboat.png new file mode 100644 index 0000000000000000000000000000000000000000..5a4783f0bc3971e5562ec0f863251e7c7159fb08 GIT binary patch literal 1553 zcmeAS@N?(olHy`uVBq!ia0y~yVDtcC4mO~Okx05Rkm4-xh%9Dc;1&j9Muu5)Bp4W2 z4|}>ehE&XXdp9ue5t~Ts!`Byew76~?a62Z6S0>0emRg)HikC_~^d+I=ZPJJDo>QYt zEt^+8%jcNu9UT9QsiN-eTKOB__u4U?U!OT^mA3NF)kg#)Ca!zEYF*8-J69qV?CtEH zRfaHd7g)%wTJ@^JCXBa6{paiR`vu$^^!K;fvn0%A5mFHFXmC(qWNKvLz|Lv9KmFgc zyzSC|xwqs-FTZ@UPu9BZ-KNbqbL#&5ynk-)-1yHo-jh)xeRbJnA zJ9q!xyx*%{wLh|`FeqQ68Yi(W`S`i2vUB=f_lpd!yA}eK+I;Qne#Br*$U7(=)$5pE zKD|ux2FOo&PZ#X~Qg2#h#gD!PdO`io4h=p7W}M-IVi1J$psAv=Jac*@Nc;0Jy{_9E zlaKq|C=9#uui2APkO##;ZSSs%qDse}2FAdZ~H+rzoF~ z@A^K}fBrfr_VefCpZQ;Gzx_6c|HZ_;`}c=W72jCFbEx9x*1|Qbe*HZ@-~9OF!VjtW z4-EfEGyN+Im07)y{nIl47{UJ+A58o?OYUH|31*6V{(m;V`HV;9H=yZsuKfEPv)LD| z|Cl$*tjxU~IDh~B_peK=Zf^YiSa$#6Y`b|$%)}%~M9O_2_k<(&_O-hG+moNKvp#ct zb{GHa-}~0D`t{miW%r}9X&Z{`0{;|PgoIxGSh41lsa@B51^1{+shQTV?-T~s*wwKS zPX7qYKzXKmg0jxrOd$2EwF;efz8D8%dh(! z?lw6*Ygy*6b+7-NX4igfed4vr`t|F-*YOmX>R<3VY=7YPm+y591*-A4fhFo700)|X Yv3GTB6qS0oI}_v_Pgg&ebxsLQ03sC?+yDRo literal 0 HcmV?d00001