调整重铸台逻辑
This commit is contained in:
parent
2938663557
commit
40c7ab917e
2 changed files with 28 additions and 20 deletions
|
@ -19,6 +19,7 @@ import net.minecraftforge.api.distmarker.OnlyIn;
|
||||||
|
|
||||||
@OnlyIn(Dist.CLIENT)
|
@OnlyIn(Dist.CLIENT)
|
||||||
public class ReforgingTableScreen extends AbstractContainerScreen<ReforgingTableMenu> {
|
public class ReforgingTableScreen extends AbstractContainerScreen<ReforgingTableMenu> {
|
||||||
|
|
||||||
private static final ResourceLocation TEXTURE = ModUtils.loc("textures/gui/reforging_table.png");
|
private static final ResourceLocation TEXTURE = ModUtils.loc("textures/gui/reforging_table.png");
|
||||||
|
|
||||||
public ReforgingTableScreen(ReforgingTableMenu pMenu, Inventory pPlayerInventory, Component pTitle) {
|
public ReforgingTableScreen(ReforgingTableMenu pMenu, Inventory pPlayerInventory, Component pTitle) {
|
||||||
|
@ -46,26 +47,30 @@ public class ReforgingTableScreen extends AbstractContainerScreen<ReforgingTable
|
||||||
var damagePerkLevel = ReforgingTableScreen.this.menu.damagePerkLevel.get();
|
var damagePerkLevel = ReforgingTableScreen.this.menu.damagePerkLevel.get();
|
||||||
|
|
||||||
if (ammoPerkLevel > 0) {
|
if (ammoPerkLevel > 0) {
|
||||||
pGuiGraphics.blit(TEXTURE, this.leftPos + 140, this.topPos + 31, 5 * ammoPerkLevel - 5, 178, 5, 5, 200, 200);
|
renderNumber(pGuiGraphics, this.leftPos + 136, this.topPos + 31, 1, 178, ammoPerkLevel);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (funcPerkLevel > 0) {
|
if (funcPerkLevel > 0) {
|
||||||
pGuiGraphics.blit(TEXTURE, this.leftPos + 148, this.topPos + 31, 5 * funcPerkLevel - 5, 184, 5, 5, 200, 200);
|
renderNumber(pGuiGraphics, this.leftPos + 146, this.topPos + 31, 1, 184, funcPerkLevel);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (damagePerkLevel > 0) {
|
if (damagePerkLevel > 0) {
|
||||||
pGuiGraphics.blit(TEXTURE, this.leftPos + 156, this.topPos + 31, 5 * damagePerkLevel - 5, 190, 5, 5, 200, 200);
|
renderNumber(pGuiGraphics, this.leftPos + 156, this.topPos + 31, 1, 190, damagePerkLevel);
|
||||||
}
|
}
|
||||||
|
|
||||||
var upgradePoint = ReforgingTableScreen.this.menu.upgradePoint.get();
|
var upgradePoint = ReforgingTableScreen.this.menu.upgradePoint.get();
|
||||||
int pointG = upgradePoint / 10;
|
renderNumber(pGuiGraphics, this.leftPos + 43, this.topPos + 20, 51, 178, upgradePoint);
|
||||||
int pointS = upgradePoint % 10;
|
|
||||||
pGuiGraphics.blit(TEXTURE, this.leftPos + 43, this.topPos + 20, 51 + 5 * pointG, 178, 5, 5, 200, 200);
|
|
||||||
pGuiGraphics.blit(TEXTURE, this.leftPos + 47, this.topPos + 20, 51 + 5 * pointS, 178, 5, 5, 200, 200);
|
|
||||||
|
|
||||||
this.renderTooltip(pGuiGraphics, pMouseX, pMouseY);
|
this.renderTooltip(pGuiGraphics, pMouseX, pMouseY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void renderNumber(GuiGraphics guiGraphics, int x, int y, int u, int v, int number) {
|
||||||
|
int g = number / 10;
|
||||||
|
int s = number % 10;
|
||||||
|
guiGraphics.blit(TEXTURE, x, y, u + 5 * g, v, 5, 5, 200, 200);
|
||||||
|
guiGraphics.blit(TEXTURE, x + 4, y, u + 5 * s, v, 5, 5, 200, 200);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void init() {
|
protected void init() {
|
||||||
super.init();
|
super.init();
|
||||||
|
@ -103,7 +108,7 @@ public class ReforgingTableScreen extends AbstractContainerScreen<ReforgingTable
|
||||||
}
|
}
|
||||||
|
|
||||||
public ReforgeButton(int pX, int pY) {
|
public ReforgeButton(int pX, int pY) {
|
||||||
super(pX, pY, 40, 16, Component.translatable("button.superbwarfare.reforge"));
|
super(pX, pY, 40, 16, Component.literal(""));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -127,7 +132,7 @@ public class ReforgingTableScreen extends AbstractContainerScreen<ReforgingTable
|
||||||
public Perk.Type type;
|
public Perk.Type type;
|
||||||
|
|
||||||
public UpgradeButton(int pX, int pY, Perk.Type type) {
|
public UpgradeButton(int pX, int pY, Perk.Type type) {
|
||||||
super(pX, pY, 9, 9, Component.translatable("button.superbwarfare.upgrade"));
|
super(pX, pY, 9, 9, Component.literal(""));
|
||||||
this.type = type;
|
this.type = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -143,17 +148,17 @@ public class ReforgingTableScreen extends AbstractContainerScreen<ReforgingTable
|
||||||
}
|
}
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case AMMO -> {
|
case AMMO -> {
|
||||||
if (ReforgingTableScreen.this.menu.ammoPerkLevel.get() >= 50) {
|
if (ReforgingTableScreen.this.menu.ammoPerkLevel.get() >= ReforgingTableMenu.MAX_PERK_LEVEL) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case FUNCTIONAL -> {
|
case FUNCTIONAL -> {
|
||||||
if (ReforgingTableScreen.this.menu.funcPerkLevel.get() >= 50) {
|
if (ReforgingTableScreen.this.menu.funcPerkLevel.get() >= ReforgingTableMenu.MAX_PERK_LEVEL) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case DAMAGE -> {
|
case DAMAGE -> {
|
||||||
if (ReforgingTableScreen.this.menu.damagePerkLevel.get() >= 50) {
|
if (ReforgingTableScreen.this.menu.damagePerkLevel.get() >= ReforgingTableMenu.MAX_PERK_LEVEL) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -178,7 +183,7 @@ public class ReforgingTableScreen extends AbstractContainerScreen<ReforgingTable
|
||||||
}
|
}
|
||||||
|
|
||||||
public DowngradeButton(int pX, int pY, Perk.Type type) {
|
public DowngradeButton(int pX, int pY, Perk.Type type) {
|
||||||
super(pX, pY, 12, 12, Component.translatable("button.superbwarfare.downgrade"));
|
super(pX, pY, 12, 12, Component.literal(""));
|
||||||
this.type = type;
|
this.type = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,6 +31,9 @@ public class ReforgingTableMenu extends AbstractContainerMenu {
|
||||||
public static final int DAMAGE_PERK_SLOT = 3;
|
public static final int DAMAGE_PERK_SLOT = 3;
|
||||||
public static final int RESULT_SLOT = 4;
|
public static final int RESULT_SLOT = 4;
|
||||||
|
|
||||||
|
public static final int MAX_PERK_LEVEL = 50;
|
||||||
|
public static final int MAX_UPGRADE_POINT = 100;
|
||||||
|
|
||||||
public final DataSlot ammoPerkLevel = DataSlot.standalone();
|
public final DataSlot ammoPerkLevel = DataSlot.standalone();
|
||||||
public final DataSlot funcPerkLevel = DataSlot.standalone();
|
public final DataSlot funcPerkLevel = DataSlot.standalone();
|
||||||
public final DataSlot damagePerkLevel = DataSlot.standalone();
|
public final DataSlot damagePerkLevel = DataSlot.standalone();
|
||||||
|
@ -178,21 +181,21 @@ public class ReforgingTableMenu extends AbstractContainerMenu {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!upgrade && this.upgradePoint.get() >= 100 && !isCreative) {
|
if (!upgrade && this.upgradePoint.get() >= MAX_UPGRADE_POINT && !isCreative) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case AMMO ->
|
case AMMO ->
|
||||||
this.ammoPerkLevel.set(upgrade ? Math.min(50, this.ammoPerkLevel.get() + 1) : Math.max(1, this.ammoPerkLevel.get() - 1));
|
this.ammoPerkLevel.set(upgrade ? Math.min(MAX_PERK_LEVEL, this.ammoPerkLevel.get() + 1) : Math.max(1, this.ammoPerkLevel.get() - 1));
|
||||||
case FUNCTIONAL ->
|
case FUNCTIONAL ->
|
||||||
this.funcPerkLevel.set(upgrade ? Math.min(50, this.funcPerkLevel.get() + 1) : Math.max(1, this.funcPerkLevel.get() - 1));
|
this.funcPerkLevel.set(upgrade ? Math.min(MAX_PERK_LEVEL, this.funcPerkLevel.get() + 1) : Math.max(1, this.funcPerkLevel.get() - 1));
|
||||||
case DAMAGE ->
|
case DAMAGE ->
|
||||||
this.damagePerkLevel.set(upgrade ? Math.min(50, this.damagePerkLevel.get() + 1) : Math.max(1, this.damagePerkLevel.get() - 1));
|
this.damagePerkLevel.set(upgrade ? Math.min(MAX_PERK_LEVEL, this.damagePerkLevel.get() + 1) : Math.max(1, this.damagePerkLevel.get() - 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isCreative) {
|
if (!isCreative) {
|
||||||
this.upgradePoint.set(Mth.clamp(this.upgradePoint.get() + (upgrade ? -1 : 1), 0, 100));
|
this.upgradePoint.set(Mth.clamp(this.upgradePoint.get() + (upgrade ? -1 : 1), 0, MAX_UPGRADE_POINT));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -289,7 +292,7 @@ public class ReforgingTableMenu extends AbstractContainerMenu {
|
||||||
|
|
||||||
ItemStack output = gun.copy();
|
ItemStack output = gun.copy();
|
||||||
PerkHelper.removePerkByType(output, perkItem.getPerk().type);
|
PerkHelper.removePerkByType(output, perkItem.getPerk().type);
|
||||||
output.getOrCreateTag().putDouble("UpgradePoint", Math.min(100, level - 1 + output.getOrCreateTag().getDouble("UpgradePoint")));
|
output.getOrCreateTag().putDouble("UpgradePoint", Math.min(MAX_UPGRADE_POINT, level - 1 + output.getOrCreateTag().getDouble("UpgradePoint")));
|
||||||
this.upgradePoint.set((int) output.getOrCreateTag().getDouble("UpgradePoint"));
|
this.upgradePoint.set((int) output.getOrCreateTag().getDouble("UpgradePoint"));
|
||||||
|
|
||||||
this.container.setItem(INPUT_SLOT, output);
|
this.container.setItem(INPUT_SLOT, output);
|
||||||
|
@ -325,7 +328,7 @@ public class ReforgingTableMenu extends AbstractContainerMenu {
|
||||||
}
|
}
|
||||||
|
|
||||||
int point = (int) pStack.getOrCreateTag().getDouble("UpgradePoint");
|
int point = (int) pStack.getOrCreateTag().getDouble("UpgradePoint");
|
||||||
this.upgradePoint.set(Mth.clamp(point, 0, 100));
|
this.upgradePoint.set(Mth.clamp(point, 0, MAX_UPGRADE_POINT));
|
||||||
|
|
||||||
var ammoPerk = PerkHelper.getPerkByType(pStack, Perk.Type.AMMO);
|
var ammoPerk = PerkHelper.getPerkByType(pStack, Perk.Type.AMMO);
|
||||||
if (ammoPerk != null) {
|
if (ammoPerk != null) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue