调整快艇gui
This commit is contained in:
parent
8536aac6f9
commit
eb6a3fff0e
7 changed files with 59 additions and 26 deletions
|
@ -23,7 +23,7 @@ public class SpeedboatModel extends GeoModel<SpeedboatEntity> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResourceLocation getTextureResource(SpeedboatEntity entity) {
|
public ResourceLocation getTextureResource(SpeedboatEntity entity) {
|
||||||
return ModUtils.loc("textures/entity/speedboat.png");
|
return ModUtils.loc("textures/entity/vehicle.png");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
package com.atsuishio.superbwarfare.client.screens;
|
package com.atsuishio.superbwarfare.client.screens;
|
||||||
|
|
||||||
import com.atsuishio.superbwarfare.ModUtils;
|
import com.atsuishio.superbwarfare.ModUtils;
|
||||||
import com.atsuishio.superbwarfare.menu.SpeedboatMenu;
|
import com.atsuishio.superbwarfare.menu.VehicleMenu;
|
||||||
import net.minecraft.client.gui.GuiGraphics;
|
import net.minecraft.client.gui.GuiGraphics;
|
||||||
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen;
|
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen;
|
||||||
import net.minecraft.network.chat.Component;
|
import net.minecraft.network.chat.Component;
|
||||||
|
@ -11,13 +11,13 @@ import net.minecraftforge.api.distmarker.Dist;
|
||||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||||
|
|
||||||
@OnlyIn(Dist.CLIENT)
|
@OnlyIn(Dist.CLIENT)
|
||||||
public class SpeedboatScreen extends AbstractContainerScreen<SpeedboatMenu> {
|
public class VehicleScreen extends AbstractContainerScreen<VehicleMenu> {
|
||||||
|
|
||||||
private static final ResourceLocation TEXTURE = ModUtils.loc("textures/gui/speedboat.png");
|
private static final ResourceLocation TEXTURE = ModUtils.loc("textures/gui/vehicle.png");
|
||||||
|
|
||||||
public SpeedboatScreen(SpeedboatMenu pMenu, Inventory pPlayerInventory, Component pTitle) {
|
public VehicleScreen(VehicleMenu pMenu, Inventory pPlayerInventory, Component pTitle) {
|
||||||
super(pMenu, pPlayerInventory, pTitle);
|
super(pMenu, pPlayerInventory, pTitle);
|
||||||
imageWidth = 320;
|
imageWidth = 345;
|
||||||
imageHeight = 222;
|
imageHeight = 222;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@ public class SpeedboatScreen extends AbstractContainerScreen<SpeedboatMenu> {
|
||||||
protected void renderBg(GuiGraphics pGuiGraphics, float pPartialTick, int pMouseX, int pMouseY) {
|
protected void renderBg(GuiGraphics pGuiGraphics, float pPartialTick, int pMouseX, int pMouseY) {
|
||||||
int i = (this.width - this.imageWidth) / 2;
|
int i = (this.width - this.imageWidth) / 2;
|
||||||
int j = (this.height - this.imageHeight) / 2;
|
int j = (this.height - this.imageHeight) / 2;
|
||||||
pGuiGraphics.blit(TEXTURE, i, j, 0, 0, this.imageWidth, this.imageHeight, 328, 328);
|
pGuiGraphics.blit(TEXTURE, i, j, 0, 0, this.imageWidth, this.imageHeight, 358, 328);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -38,9 +38,9 @@ public class SpeedboatScreen extends AbstractContainerScreen<SpeedboatMenu> {
|
||||||
@Override
|
@Override
|
||||||
protected void init() {
|
protected void init() {
|
||||||
super.init();
|
super.init();
|
||||||
this.titleLabelX = 8;
|
this.titleLabelX = 33;
|
||||||
this.titleLabelY = 5;
|
this.titleLabelY = 5;
|
||||||
this.inventoryLabelX = 80;
|
this.inventoryLabelX = 105;
|
||||||
this.inventoryLabelY = 128;
|
this.inventoryLabelY = 128;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -6,7 +6,7 @@ import com.atsuishio.superbwarfare.config.server.ExplosionDestroyConfig;
|
||||||
import com.atsuishio.superbwarfare.entity.projectile.ProjectileEntity;
|
import com.atsuishio.superbwarfare.entity.projectile.ProjectileEntity;
|
||||||
import com.atsuishio.superbwarfare.init.*;
|
import com.atsuishio.superbwarfare.init.*;
|
||||||
import com.atsuishio.superbwarfare.item.ContainerBlockItem;
|
import com.atsuishio.superbwarfare.item.ContainerBlockItem;
|
||||||
import com.atsuishio.superbwarfare.menu.SpeedboatMenu;
|
import com.atsuishio.superbwarfare.menu.VehicleMenu;
|
||||||
import com.atsuishio.superbwarfare.network.ModVariables;
|
import com.atsuishio.superbwarfare.network.ModVariables;
|
||||||
import com.atsuishio.superbwarfare.network.message.ShakeClientMessage;
|
import com.atsuishio.superbwarfare.network.message.ShakeClientMessage;
|
||||||
import com.atsuishio.superbwarfare.tools.CustomExplosion;
|
import com.atsuishio.superbwarfare.tools.CustomExplosion;
|
||||||
|
@ -89,7 +89,7 @@ public class SpeedboatEntity extends Entity implements GeoEntity, IChargeEntity,
|
||||||
|
|
||||||
public static final float MAX_HEALTH = CannonConfig.SPEEDBOAT_HP.get();
|
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 float MAX_ENERGY = CannonConfig.SPEEDBOAT_MAX_ENERGY.get().floatValue();
|
||||||
public static final int CONTAINER_SIZE = 102;
|
public static final int CONTAINER_SIZE = 105;
|
||||||
|
|
||||||
private NonNullList<ItemStack> items = NonNullList.withSize(CONTAINER_SIZE, ItemStack.EMPTY);
|
private NonNullList<ItemStack> items = NonNullList.withSize(CONTAINER_SIZE, ItemStack.EMPTY);
|
||||||
private LazyOptional<?> itemHandler = LazyOptional.of(() -> new InvWrapper(this));
|
private LazyOptional<?> itemHandler = LazyOptional.of(() -> new InvWrapper(this));
|
||||||
|
@ -815,7 +815,7 @@ public class SpeedboatEntity extends Entity implements GeoEntity, IChargeEntity,
|
||||||
if (pPlayer.isSpectator()) {
|
if (pPlayer.isSpectator()) {
|
||||||
return null;
|
return null;
|
||||||
} else {
|
} else {
|
||||||
return new SpeedboatMenu(pContainerId, pPlayerInventory, this);
|
return new VehicleMenu(pContainerId, pPlayerInventory, this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@ package com.atsuishio.superbwarfare.init;
|
||||||
import com.atsuishio.superbwarfare.ModUtils;
|
import com.atsuishio.superbwarfare.ModUtils;
|
||||||
import com.atsuishio.superbwarfare.menu.ChargingStationMenu;
|
import com.atsuishio.superbwarfare.menu.ChargingStationMenu;
|
||||||
import com.atsuishio.superbwarfare.menu.ReforgingTableMenu;
|
import com.atsuishio.superbwarfare.menu.ReforgingTableMenu;
|
||||||
import com.atsuishio.superbwarfare.menu.SpeedboatMenu;
|
import com.atsuishio.superbwarfare.menu.VehicleMenu;
|
||||||
import net.minecraft.world.inventory.MenuType;
|
import net.minecraft.world.inventory.MenuType;
|
||||||
import net.minecraftforge.common.extensions.IForgeMenuType;
|
import net.minecraftforge.common.extensions.IForgeMenuType;
|
||||||
import net.minecraftforge.registries.DeferredRegister;
|
import net.minecraftforge.registries.DeferredRegister;
|
||||||
|
@ -20,7 +20,7 @@ public class ModMenuTypes {
|
||||||
public static final RegistryObject<MenuType<ChargingStationMenu>> CHARGING_STATION_MENU =
|
public static final RegistryObject<MenuType<ChargingStationMenu>> CHARGING_STATION_MENU =
|
||||||
REGISTRY.register("charging_station_menu",
|
REGISTRY.register("charging_station_menu",
|
||||||
() -> IForgeMenuType.create((windowId, inv, data) -> new ChargingStationMenu(windowId, inv)));
|
() -> IForgeMenuType.create((windowId, inv, data) -> new ChargingStationMenu(windowId, inv)));
|
||||||
public static final RegistryObject<MenuType<SpeedboatMenu>> SPEEDBOAT_MENU =
|
public static final RegistryObject<MenuType<VehicleMenu>> VEHICLE_MENU =
|
||||||
REGISTRY.register("speedboat_menu",
|
REGISTRY.register("vehicle_menu",
|
||||||
() -> IForgeMenuType.create((windowId, inv, data) -> new SpeedboatMenu(windowId, inv)));
|
() -> IForgeMenuType.create((windowId, inv, data) -> new VehicleMenu(windowId, inv)));
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,7 @@ package com.atsuishio.superbwarfare.init;
|
||||||
|
|
||||||
import com.atsuishio.superbwarfare.client.screens.ChargingStationScreen;
|
import com.atsuishio.superbwarfare.client.screens.ChargingStationScreen;
|
||||||
import com.atsuishio.superbwarfare.client.screens.ReforgingTableScreen;
|
import com.atsuishio.superbwarfare.client.screens.ReforgingTableScreen;
|
||||||
import com.atsuishio.superbwarfare.client.screens.SpeedboatScreen;
|
import com.atsuishio.superbwarfare.client.screens.VehicleScreen;
|
||||||
import net.minecraft.client.gui.screens.MenuScreens;
|
import net.minecraft.client.gui.screens.MenuScreens;
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||||
|
@ -17,7 +17,7 @@ public class ModScreens {
|
||||||
event.enqueueWork(() -> {
|
event.enqueueWork(() -> {
|
||||||
MenuScreens.register(ModMenuTypes.REFORGING_TABLE_MENU.get(), ReforgingTableScreen::new);
|
MenuScreens.register(ModMenuTypes.REFORGING_TABLE_MENU.get(), ReforgingTableScreen::new);
|
||||||
MenuScreens.register(ModMenuTypes.CHARGING_STATION_MENU.get(), ChargingStationScreen::new);
|
MenuScreens.register(ModMenuTypes.CHARGING_STATION_MENU.get(), ChargingStationScreen::new);
|
||||||
MenuScreens.register(ModMenuTypes.SPEEDBOAT_MENU.get(), SpeedboatScreen::new);
|
MenuScreens.register(ModMenuTypes.VEHICLE_MENU.get(), VehicleScreen::new);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,8 @@ package com.atsuishio.superbwarfare.menu;
|
||||||
|
|
||||||
import com.atsuishio.superbwarfare.entity.SpeedboatEntity;
|
import com.atsuishio.superbwarfare.entity.SpeedboatEntity;
|
||||||
import com.atsuishio.superbwarfare.init.ModMenuTypes;
|
import com.atsuishio.superbwarfare.init.ModMenuTypes;
|
||||||
|
import com.atsuishio.superbwarfare.item.PerkItem;
|
||||||
|
import com.atsuishio.superbwarfare.perk.Perk;
|
||||||
import net.minecraft.world.Container;
|
import net.minecraft.world.Container;
|
||||||
import net.minecraft.world.SimpleContainer;
|
import net.minecraft.world.SimpleContainer;
|
||||||
import net.minecraft.world.entity.player.Inventory;
|
import net.minecraft.world.entity.player.Inventory;
|
||||||
|
@ -10,20 +12,20 @@ import net.minecraft.world.inventory.AbstractContainerMenu;
|
||||||
import net.minecraft.world.inventory.Slot;
|
import net.minecraft.world.inventory.Slot;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
|
|
||||||
public class SpeedboatMenu extends AbstractContainerMenu {
|
public class VehicleMenu extends AbstractContainerMenu {
|
||||||
|
|
||||||
private final Container container;
|
private final Container container;
|
||||||
private final int containerRows;
|
private final int containerRows;
|
||||||
|
|
||||||
public static final int X_OFFSET = 72;
|
public static final int X_OFFSET = 97;
|
||||||
public static final int Y_OFFSET = 20;
|
public static final int Y_OFFSET = 20;
|
||||||
|
|
||||||
public SpeedboatMenu(int pContainerId, Inventory pPlayerInventory) {
|
public VehicleMenu(int pContainerId, Inventory pPlayerInventory) {
|
||||||
this(pContainerId, pPlayerInventory, new SimpleContainer(SpeedboatEntity.CONTAINER_SIZE));
|
this(pContainerId, pPlayerInventory, new SimpleContainer(SpeedboatEntity.CONTAINER_SIZE));
|
||||||
}
|
}
|
||||||
|
|
||||||
public SpeedboatMenu(int pContainerId, Inventory pPlayerInventory, Container pContainer) {
|
public VehicleMenu(int pContainerId, Inventory pPlayerInventory, Container pContainer) {
|
||||||
super(ModMenuTypes.SPEEDBOAT_MENU.get(), pContainerId);
|
super(ModMenuTypes.VEHICLE_MENU.get(), pContainerId);
|
||||||
|
|
||||||
checkContainerSize(pContainer, SpeedboatEntity.CONTAINER_SIZE);
|
checkContainerSize(pContainer, SpeedboatEntity.CONTAINER_SIZE);
|
||||||
this.container = pContainer;
|
this.container = pContainer;
|
||||||
|
@ -33,10 +35,14 @@ public class SpeedboatMenu extends AbstractContainerMenu {
|
||||||
|
|
||||||
for (int j = 0; j < this.containerRows; ++j) {
|
for (int j = 0; j < this.containerRows; ++j) {
|
||||||
for (int k = 0; k < 17; ++k) {
|
for (int k = 0; k < 17; ++k) {
|
||||||
this.addSlot(new Slot(pContainer, k + j * 17, 8 + k * 18, 18 + j * 18));
|
this.addSlot(new Slot(pContainer, k + j * 17, 8 + k * 18 + 25, 18 + j * 18));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.addSlot(new PerkSlot(pContainer, this.containerRows * 17, Perk.Type.AMMO, 8, 36));
|
||||||
|
this.addSlot(new PerkSlot(pContainer, this.containerRows * 17 + 1, Perk.Type.FUNCTIONAL, 8, 54));
|
||||||
|
this.addSlot(new PerkSlot(pContainer, this.containerRows * 17 + 2, Perk.Type.DAMAGE, 8, 72));
|
||||||
|
|
||||||
for (int l = 0; l < 3; ++l) {
|
for (int l = 0; l < 3; ++l) {
|
||||||
for (int j = 0; j < 9; ++j) {
|
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));
|
this.addSlot(new Slot(pPlayerInventory, j + l * 9 + 9, 8 + j * 18 + X_OFFSET, 84 + l * 18 + Y_OFFSET + i));
|
||||||
|
@ -55,8 +61,15 @@ public class SpeedboatMenu extends AbstractContainerMenu {
|
||||||
if (slot.hasItem()) {
|
if (slot.hasItem()) {
|
||||||
ItemStack itemstack1 = slot.getItem();
|
ItemStack itemstack1 = slot.getItem();
|
||||||
itemstack = itemstack1.copy();
|
itemstack = itemstack1.copy();
|
||||||
if (pIndex < this.containerRows * 17) {
|
if (pIndex < this.containerRows * 17 + 2) {
|
||||||
if (!this.moveItemStackTo(itemstack1, this.containerRows * 17, this.slots.size(), true)) {
|
if (!this.moveItemStackTo(itemstack1, this.containerRows * 17 + 2, this.slots.size(), true)) {
|
||||||
|
return ItemStack.EMPTY;
|
||||||
|
}
|
||||||
|
} else if (itemstack1.getItem() instanceof PerkItem) {
|
||||||
|
if (!this.moveItemStackTo(itemstack1, this.containerRows * 17, this.containerRows * 17 + 2, false)) {
|
||||||
|
if (!this.moveItemStackTo(itemstack1, 0, this.containerRows * 17, false)) {
|
||||||
|
return ItemStack.EMPTY;
|
||||||
|
}
|
||||||
return ItemStack.EMPTY;
|
return ItemStack.EMPTY;
|
||||||
}
|
}
|
||||||
} else if (!this.moveItemStackTo(itemstack1, 0, this.containerRows * 17, false)) {
|
} else if (!this.moveItemStackTo(itemstack1, 0, this.containerRows * 17, false)) {
|
||||||
|
@ -77,4 +90,24 @@ public class SpeedboatMenu extends AbstractContainerMenu {
|
||||||
public boolean stillValid(Player pPlayer) {
|
public boolean stillValid(Player pPlayer) {
|
||||||
return this.container.stillValid(pPlayer);
|
return this.container.stillValid(pPlayer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static class PerkSlot extends Slot {
|
||||||
|
|
||||||
|
public Perk.Type type;
|
||||||
|
|
||||||
|
public PerkSlot(Container pContainer, int pSlot, Perk.Type type, int pX, int pY) {
|
||||||
|
super(pContainer, pSlot, pX, pY);
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean mayPlace(ItemStack pStack) {
|
||||||
|
return pStack.getItem() instanceof PerkItem perkItem && perkItem.getPerk().type == type;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getMaxStackSize() {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
Before Width: | Height: | Size: 1.8 KiB After Width: | Height: | Size: 1.8 KiB |
Loading…
Add table
Reference in a new issue