misc fixes
This commit is contained in:
parent
cfcb590574
commit
00ac4146bc
8 changed files with 119 additions and 116 deletions
|
@ -581,7 +581,7 @@ public class Client implements IThreadListener {
|
|||
@Variable(name = "chunk_build_time", category = CVarCategory.RENDER, min = 1, max = 100, display = "Zeit für Chunk-Bau", unit = "ms")
|
||||
public int maxBuildTime = 8;
|
||||
@Variable(name = "chunk_light_updates", category = CVarCategory.RENDER, min = 0, max = 10000, display = "Licht-Updates / Frame")
|
||||
private int lightUpdates = 150;
|
||||
private int lightUpdates = 300;
|
||||
@Variable(name = "chunk_light_range", category = CVarCategory.RENDER, min = 5, max = 512, display = "Radius Licht-Updates")
|
||||
private int lightRange = 32;
|
||||
@Variable(name = "draw_fov", category = CVarCategory.RENDER, min = 20.0f, max = 160.0f, display = "Sichtfeld (FOV)", unit = "°", precision = 1)
|
||||
|
@ -610,6 +610,8 @@ public class Client implements IThreadListener {
|
|||
private int scaleVar = 1;
|
||||
@Variable(name = "gui_scale_items", category = CVarCategory.GUI, display = "Gegenstände vergrößern", callback = ItemRedrawFunction.class)
|
||||
public boolean scaleItems = true;
|
||||
@Variable(name = "gui_scale_items_always", category = CVarCategory.GUI, display = "Immer vergrößern", callback = ItemRedrawFunction.class)
|
||||
public boolean scaleItemsAlways = false;
|
||||
@Variable(name = "gui_scale_hotbar", category = CVarCategory.GUI, display = "Leiste vergrößern")
|
||||
public boolean scaleHotbar = true;
|
||||
@Variable(name = "hud_margin", category = CVarCategory.GUI, min = 0, max = 120, unit = "px", display = "Seitenabstand der HUD")
|
||||
|
@ -2512,6 +2514,7 @@ public class Client implements IThreadListener {
|
|||
PerfSection.TICK.enter();
|
||||
this.doTicks();
|
||||
PerfSection.UPDATE.enter();
|
||||
this.update();
|
||||
PerfSection.RENDER.enter();
|
||||
this.render();
|
||||
PerfSection.GUI.enter();
|
||||
|
@ -2700,7 +2703,9 @@ public class Client implements IThreadListener {
|
|||
this.tickFraction = ((double)this.tick_torun) / 1000000.0;
|
||||
this.tick_ttime += this.tick_ftime;
|
||||
this.tick_time = this.tickFrame != 0 ? (this.tick_ftime / (long)this.tickFrame) : 0L;
|
||||
}
|
||||
|
||||
private void update() {
|
||||
if(this.player != null) {
|
||||
int radius = Math.min(this.renderDistance * 16, this.lightRange);
|
||||
for(int n = 0; n < this.lightUpdates; n++) {
|
||||
|
|
|
@ -97,6 +97,7 @@ public abstract class GuiContainer extends Gui
|
|||
private Label cheatLabel;
|
||||
private Field cheatSearch;
|
||||
private String cheatLast;
|
||||
private Label inventoryLabel;
|
||||
|
||||
public static String formatAmount(int amount) {
|
||||
if(amount < 0)
|
||||
|
@ -260,21 +261,22 @@ public abstract class GuiContainer extends Gui
|
|||
{
|
||||
this.inventorySlots = container;
|
||||
this.ignoreMouseUp = true;
|
||||
this.xSize = (container.getInventoryOffsetX() - 1) * 2 + 18 * 12;
|
||||
this.ySize = container.getInventoryOffsetY() + 6 + 18 * ((Equipment.INVENTORY_SLOTS + 11) / 12);
|
||||
this.xSize = (container.getInventoryOffsetX() - 1) * 2 + 18 * Container.INVENTORY_WIDTH;
|
||||
this.ySize = container.getInventoryOffsetY() + 26 + 18 * ((Equipment.INVENTORY_SLOTS + Container.INVENTORY_WIDTH - 1) / Container.INVENTORY_WIDTH);
|
||||
}
|
||||
|
||||
public void init(int width, int height) {
|
||||
this.itemRender = this.gm.getRenderItem();
|
||||
this.tooltip = null;
|
||||
this.cheatStack = null;
|
||||
this.container_scale = this.gm.scaleItems && this.xSize * 2 <= Client.MIN_WIDTH && this.ySize * 2 <= Client.MIN_HEIGHT ? 2 : 1;
|
||||
this.container_scale = this.gm.scaleItems && (this.gm.scaleItemsAlways || (this.xSize * 2 <= Client.MIN_WIDTH && this.ySize * 2 <= Client.MIN_HEIGHT)) ? 2 : 1;
|
||||
this.container_x = (width - (this.container_w = (this.xSize * this.container_scale))) / 2;
|
||||
this.container_y = (height - (this.container_h = (this.ySize * this.container_scale))) / 2;
|
||||
this.initGui();
|
||||
this.addButtons();
|
||||
this.addElements();
|
||||
this.label("Inventar", this.inventorySlots.getInventoryOffsetX(), this.inventorySlots.getInventoryOffsetY() - 2);
|
||||
this.inventoryLabel = this.label("", this.inventorySlots.getInventoryOffsetX() + 18 * Container.INVENTORY_WIDTH - 90, this.inventorySlots.getInventoryOffsetY() - 2);
|
||||
}
|
||||
|
||||
public void hover(String text, int x, int y) {
|
||||
|
@ -767,14 +769,18 @@ public abstract class GuiContainer extends Gui
|
|||
|
||||
public void updateScreen()
|
||||
{
|
||||
if (this.gm != null && this.gm.player != null && (!this.gm.player.isEntityAlive() || this.gm.player.dead))
|
||||
{
|
||||
if(this.gm != null && this.gm.player != null && (!this.gm.player.isEntityAlive() || this.gm.player.dead)) {
|
||||
this.gm.show(null);
|
||||
return;
|
||||
}
|
||||
else if(this.gm.itemCheat && !this.cheatSearch.getText().equals(this.cheatLast)) {
|
||||
|
||||
if(this.gm.itemCheat && !this.cheatSearch.getText().equals(this.cheatLast)) {
|
||||
this.cheatLast = this.cheatSearch.getText();
|
||||
this.setCurrentTab(selectedTab);
|
||||
}
|
||||
|
||||
if(this.gm != null && this.gm.player != null)
|
||||
this.inventoryLabel.setText((this.gm.player.getInventoryWeight() > this.gm.player.getInventoryCapacity() ? Color.RED : Color.NEON) + String.format("% 5d / % 5d", this.gm.player.getInventoryWeight(), this.gm.player.getInventoryCapacity()));
|
||||
}
|
||||
|
||||
public void renderItemOverlayIntoGUI(ItemStack stack, int xPosition, int yPosition, String text)
|
||||
|
|
|
@ -77,6 +77,7 @@ public class GuiStyle extends GuiOptions {
|
|||
this.addSelector("gui_font", H_SHIFT, y, 0, 0);
|
||||
|
||||
this.addSelector("gui_scale_items", 0, y += BASE_SHIFT, 0, 0);
|
||||
this.addSelector("gui_scale_items_always", H_SHIFT, y, 0, 0);
|
||||
|
||||
super.init(width, height);
|
||||
}
|
||||
|
|
|
@ -2484,7 +2484,7 @@ public abstract class EntityNPC extends EntityLiving implements IInventory
|
|||
}
|
||||
}
|
||||
|
||||
public int getHotbarSize() {
|
||||
public final int getHotbarSize() {
|
||||
return Equipment.INVENTORY_SLOTS;
|
||||
}
|
||||
|
||||
|
@ -2761,6 +2761,16 @@ public abstract class EntityNPC extends EntityLiving implements IInventory
|
|||
return 36;
|
||||
}
|
||||
|
||||
public int getInventoryWeight() {
|
||||
int total = 0;
|
||||
for(int z = 0; z < Equipment.INVENTORY_SLOTS; z++) {
|
||||
ItemStack stack = this.getInventory()[z];
|
||||
if(stack != null)
|
||||
total += stack.getSize() * stack.getItem().getWeight();
|
||||
}
|
||||
return total;
|
||||
}
|
||||
|
||||
public boolean hasArmorSlot(Equipment slot) {
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -8,11 +8,14 @@ import common.collect.Sets;
|
|||
import common.entity.npc.EntityNPC;
|
||||
import common.item.Item;
|
||||
import common.item.ItemStack;
|
||||
import common.item.material.ItemArmor;
|
||||
import common.network.IPlayer;
|
||||
import common.util.Equipment;
|
||||
|
||||
public abstract class Container
|
||||
{
|
||||
public static final int INVENTORY_WIDTH = 16;
|
||||
|
||||
public List<ItemStack> inventoryItemStacks = Lists.<ItemStack>newArrayList();
|
||||
public List<Slot> inventorySlots = Lists.<Slot>newArrayList();
|
||||
public int windowId;
|
||||
|
@ -33,13 +36,33 @@ public abstract class Container
|
|||
return this.offset;
|
||||
}
|
||||
|
||||
protected void addPlayerSlots(EntityNPC player) {
|
||||
this.offset = this.inventorySlots.size();
|
||||
protected void addPlayerSlots(final EntityNPC player) {
|
||||
int x = this.getInventoryOffsetX();
|
||||
int y = this.getInventoryOffsetY();
|
||||
for(Equipment slot : Equipment.ARMOR) {
|
||||
final Equipment type = slot;
|
||||
this.addSlotToContainer(new Slot(player, Equipment.INVENTORY_SLOTS + slot.getIndex(), x + slot.getIndex() * 18, y) {
|
||||
public boolean canStackItems() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isItemValid(ItemStack stack) {
|
||||
return stack != null && stack.getItem() instanceof ItemArmor armor && armor.getArmorType().canUseInSlot(player, type);
|
||||
}
|
||||
|
||||
public String getTexture() {
|
||||
return type.isRing() ? "ring" : type.getName();
|
||||
}
|
||||
|
||||
public boolean canDraw() {
|
||||
return player.hasArmorSlot(type);
|
||||
}
|
||||
});
|
||||
}
|
||||
this.offset = this.inventorySlots.size();
|
||||
List<SlotCommon> list = Lists.newArrayList();
|
||||
for(int z = 0; z < Equipment.INVENTORY_SLOTS; ++z) {
|
||||
this.addSlotToContainer(new SlotCommon(list, player, z, x + (z % 12) * 18, y + (z / 12) * 18));
|
||||
this.addSlotToContainer(new SlotCommon(list, player, z, x + (z % INVENTORY_WIDTH) * 18, y + 20 + (z / INVENTORY_WIDTH) * 18));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ public class ContainerChest extends Container
|
|||
}
|
||||
|
||||
public int getInventoryOffsetX() {
|
||||
return 8 + (this.width < 12 ? 0 : (this.width - 12) * 18 / 2);
|
||||
return 8 + (this.width < INVENTORY_WIDTH ? 0 : (this.width - INVENTORY_WIDTH) * 18 / 2);
|
||||
}
|
||||
|
||||
public int getInventoryOffsetY() {
|
||||
|
|
|
@ -1,47 +1,17 @@
|
|||
package common.inventory;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import common.collect.Lists;
|
||||
import common.entity.npc.EntityNPC;
|
||||
import common.item.ItemStack;
|
||||
import common.item.material.ItemArmor;
|
||||
import common.util.Equipment;
|
||||
|
||||
public class ContainerPlayer extends Container {
|
||||
private final EntityNPC thePlayer;
|
||||
|
||||
public ContainerPlayer(EntityNPC player)
|
||||
{
|
||||
this.thePlayer = player;
|
||||
|
||||
for (Equipment slot : Equipment.ARMOR)
|
||||
{
|
||||
final Equipment type = slot;
|
||||
this.addSlotToContainer(new Slot(player, Equipment.INVENTORY_SLOTS + slot.getIndex(), 8 + (slot.getIndex() / 4) * 18, 8 + (slot.getIndex() % 4) * 18)
|
||||
{
|
||||
public boolean canStackItems()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
public boolean isItemValid(ItemStack stack)
|
||||
{
|
||||
return stack != null && stack.getItem() instanceof ItemArmor armor && armor.getArmorType().canUseInSlot(ContainerPlayer.this.thePlayer, type);
|
||||
}
|
||||
public String getTexture() {
|
||||
return type.isRing() ? "ring" : type.getName();
|
||||
}
|
||||
public boolean canDraw() {
|
||||
return ContainerPlayer.this.thePlayer.hasArmorSlot(type);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public ContainerPlayer(EntityNPC player) {
|
||||
this.addPlayerSlots(player);
|
||||
}
|
||||
|
||||
public int getInventoryOffsetY() {
|
||||
return 92;
|
||||
return 16;
|
||||
}
|
||||
|
||||
public ItemStack getSingleRecipe(ItemStack stack) {
|
||||
|
@ -60,64 +30,52 @@ public class ContainerPlayer extends Container {
|
|||
return stack;
|
||||
}
|
||||
|
||||
public boolean canInteractWith(EntityNPC playerIn)
|
||||
{
|
||||
public boolean canInteractWith(EntityNPC playerIn) {
|
||||
return true;
|
||||
}
|
||||
|
||||
private int getFreeSlotFor(Equipment type) {
|
||||
for(Equipment slot : type.getPossibleSlots(this.thePlayer)) {
|
||||
private int getFreeSlotFor(EntityNPC player, Equipment type) {
|
||||
for(Equipment slot : type.getPossibleSlots(player)) {
|
||||
if(!this.inventorySlots.get(slot.getIndex()).getHasStack())
|
||||
return slot.getIndex();
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
public ItemStack transferStackInSlot(EntityNPC playerIn, int index)
|
||||
{
|
||||
public ItemStack transferStackInSlot(EntityNPC playerIn, int index) {
|
||||
ItemStack itemstack = null;
|
||||
Slot slot = (Slot)this.inventorySlots.get(index);
|
||||
Slot slot = this.inventorySlots.get(index);
|
||||
int idx;
|
||||
|
||||
if (slot != null && slot.getHasStack())
|
||||
{
|
||||
if(slot != null && slot.getHasStack()) {
|
||||
ItemStack itemstack1 = slot.getStack();
|
||||
itemstack = itemstack1.copy();
|
||||
|
||||
if (index >= 0 && index < Equipment.ARMOR_SLOTS)
|
||||
{
|
||||
if (!this.mergeItemStack(itemstack1, Equipment.ARMOR_SLOTS, Equipment.ARMOR_SLOTS + Equipment.INVENTORY_SLOTS))
|
||||
{
|
||||
if(index >= 0 && index < Equipment.ARMOR_SLOTS) {
|
||||
if(!this.mergeItemStack(itemstack1, Equipment.ARMOR_SLOTS, Equipment.ARMOR_SLOTS + Equipment.INVENTORY_SLOTS)) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else if (itemstack.getItem() instanceof ItemArmor armor && (idx = this.getFreeSlotFor(armor.getArmorType())) >= 0)
|
||||
{
|
||||
if (!this.mergeItemStack(itemstack1, idx, idx + 1))
|
||||
{
|
||||
else if(itemstack.getItem() instanceof ItemArmor armor && (idx = this.getFreeSlotFor(playerIn, armor.getArmorType())) >= 0) {
|
||||
if(!this.mergeItemStack(itemstack1, idx, idx + 1)) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else if (index >= Equipment.ARMOR_SLOTS && index < Equipment.ARMOR_SLOTS + Equipment.INVENTORY_SLOTS)
|
||||
{
|
||||
else if(index >= Equipment.ARMOR_SLOTS && index < Equipment.ARMOR_SLOTS + Equipment.INVENTORY_SLOTS) {
|
||||
return null;
|
||||
}
|
||||
else if (!this.mergeItemStack(itemstack1, Equipment.ARMOR_SLOTS, Equipment.ARMOR_SLOTS + Equipment.INVENTORY_SLOTS))
|
||||
{
|
||||
else if(!this.mergeItemStack(itemstack1, Equipment.ARMOR_SLOTS, Equipment.ARMOR_SLOTS + Equipment.INVENTORY_SLOTS)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (itemstack1.isEmpty())
|
||||
{
|
||||
if(itemstack1.isEmpty()) {
|
||||
slot.putStack((ItemStack)null);
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
slot.onSlotChanged();
|
||||
}
|
||||
|
||||
if (itemstack1.getSize() == itemstack.getSize())
|
||||
{
|
||||
if(itemstack1.getSize() == itemstack.getSize()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ public enum Equipment implements Identifyable, Displayable {
|
|||
|
||||
HORSE_ARMOR("horse_armor", "Pferderüstung", EntityHorse.class, 8, 0);
|
||||
|
||||
public static final int INVENTORY_SLOTS = 64;
|
||||
public static final int INVENTORY_SLOTS = 256;
|
||||
public static final int ARMOR_SLOTS;
|
||||
public static final Equipment[] ARMOR;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue