From 8e0bbd06c2df17047157ead09313c71eac3bdb52 Mon Sep 17 00:00:00 2001 From: Sen Date: Fri, 30 May 2025 17:57:14 +0200 Subject: [PATCH] code cleanup: use records where possible --- client/src/main/java/client/Client.java | 40 ++-- .../src/main/java/client/gui/GuiConnect.java | 42 ++-- .../java/client/gui/character/GuiChar.java | 8 +- .../client/gui/character/GuiCharacters.java | 10 +- .../client/gui/container/GuiMerchant.java | 12 +- .../main/java/client/gui/ingame/GuiForm.java | 12 +- .../java/client/network/ClientPlayer.java | 3 +- .../java/client/network/DummyContainer.java | 12 + .../java/client/renderer/BlockRenderer.java | 8 +- .../java/client/renderer/ItemModelMesher.java | 2 +- .../java/client/renderer/RenderBuffer.java | 12 +- .../java/client/renderer/RenderGlobal.java | 4 +- .../java/client/renderer/Tessellator.java | 16 +- .../java/client/renderer/VertexFormat.java | 10 +- .../client/renderer/VertexFormatElement.java | 202 ++++++----------- .../renderer/blockmodel/BakedModel.java | 188 +++++----------- .../renderer/blockmodel/BuiltInModel.java | 55 ++--- .../renderer/blockmodel/IBakedModel.java | 12 +- .../renderer/blockmodel/ModelManager.java | 2 +- .../renderer/entity/RenderEntityItem.java | 12 +- .../client/renderer/entity/RenderItem.java | 35 +-- client/src/main/java/client/util/Message.java | 9 +- .../main/java/client/window/DisplayMode.java | 12 +- .../main/java/client/window/WindowEvent.java | 11 +- .../common/ai/EntityAIFindEntityNearest.java | 4 +- .../main/java/common/ai/EntityAITarget.java | 4 +- .../main/java/common/ai/EntityMoveHelper.java | 4 +- .../java/common/attributes/Attribute.java | 126 +++++------ .../common/attributes/AttributeInstance.java | 4 +- .../java/common/attributes/AttributeMap.java | 16 +- .../java/common/attributes/Attributes.java | 211 +++++++----------- .../java/common/block/tech/BlockChest.java | 8 +- .../common/block/tech/BlockDispenser.java | 7 +- .../java/common/block/tech/BlockDropper.java | 3 +- .../common/block/tech/BlockSourceImpl.java | 55 ----- .../main/java/common/dimension/Dimension.java | 42 ++-- .../src/main/java/common/dimension/Lake.java | 19 +- .../main/java/common/dimension/Liquid.java | 15 +- .../src/main/java/common/dimension/Ore.java | 19 +- .../java/common/dispenser/DispenserPos.java | 4 + .../common/dispenser/DispenserSource.java | 29 +++ .../java/common/dispenser/IBlockSource.java | 5 +- .../common/dispenser/ILocatableSource.java | 5 - .../main/java/common/dispenser/ILocation.java | 8 - .../java/common/dispenser/PositionImpl.java | 30 --- .../src/main/java/common/entity/Entity.java | 2 +- .../common/entity/animal/EntityChicken.java | 4 +- .../java/common/entity/animal/EntityCow.java | 4 +- .../common/entity/animal/EntityHorse.java | 30 +-- .../common/entity/animal/EntityMouse.java | 5 +- .../common/entity/animal/EntityOcelot.java | 4 +- .../java/common/entity/animal/EntityPig.java | 4 +- .../common/entity/animal/EntityRabbit.java | 4 +- .../common/entity/animal/EntitySheep.java | 4 +- .../java/common/entity/animal/EntityWolf.java | 12 +- .../entity/item/EntityCartContainer.java | 8 +- .../java/common/entity/npc/ClassInfo.java | 9 - .../common/entity/npc/EntityChaosMarine.java | 4 +- .../common/entity/npc/EntityFlyingNPC.java | 4 +- .../common/entity/npc/EntityGargoyle.java | 6 +- .../java/common/entity/npc/EntityGoblin.java | 4 +- .../java/common/entity/npc/EntityHaunter.java | 4 +- .../common/entity/npc/EntityHoveringNPC.java | 4 +- .../java/common/entity/npc/EntityMage.java | 5 +- .../java/common/entity/npc/EntityMobNPC.java | 3 +- .../java/common/entity/npc/EntityNPC.java | 32 +-- .../java/common/entity/npc/EntityOrc.java | 4 +- .../common/entity/npc/EntityPrimarch.java | 4 +- .../java/common/entity/npc/EntitySlime.java | 6 +- .../common/entity/npc/EntitySpaceMarine.java | 4 +- .../common/entity/npc/EntityTiefling.java | 4 +- .../java/common/entity/npc/EntityUndead.java | 4 +- .../java/common/entity/npc/EntityVampire.java | 4 +- .../java/common/entity/npc/EntityZombie.java | 24 +- .../common/entity/npc/PlayerCharacter.java | 19 +- .../java/common/entity/types/CombatEntry.java | 29 +-- .../common/entity/types/EntityLiving.java | 72 +++--- .../java/common/init/DispenserRegistry.java | 4 +- .../main/java/common/init/EntityEggInfo.java | 15 -- .../src/main/java/common/init/EntityInfo.java | 4 + .../main/java/common/init/EntityRegistry.java | 4 +- .../main/java/common/init/ItemRegistry.java | 4 +- .../common/inventory/ContainerLocalMenu.java | 8 +- .../common/inventory/InventoryLargeChest.java | 6 +- .../common/inventory/InventoryMerchant.java | 4 +- .../common/inventory/SlotMerchantResult.java | 4 +- .../src/main/java/common/item/ItemArmor.java | 4 +- .../main/java/common/item/ItemBucketMilk.java | 2 +- .../src/main/java/common/item/ItemMetal.java | 2 +- .../main/java/common/item/ItemMetalBlock.java | 2 +- .../java/common/item/ItemMonsterPlacer.java | 10 +- .../src/main/java/common/item/ItemPotion.java | 4 +- .../src/main/java/common/item/ItemStack.java | 15 +- .../src/main/java/common/item/ItemSword.java | 2 +- .../src/main/java/common/item/ItemTool.java | 4 +- .../main/java/common/model/BlockLayer.java | 27 +-- .../java/common/model/ItemMeshDefinition.java | 3 +- .../src/main/java/common/model/Transform.java | 36 +-- .../main/java/common/model/Transforms.java | 86 +++---- .../common/packet/SPacketCharacterList.java | 14 +- .../common/packet/SPacketDisplayForm.java | 6 +- .../packet/SPacketEntityProperties.java | 2 +- .../java/common/packet/SPacketTrades.java | 6 +- .../java/common/pathfinding/PathNavigate.java | 4 +- .../src/main/java/common/potion/Potion.java | 13 +- .../common/tileentity/ILockableContainer.java | 4 +- .../LocalBlockIntercommunication.java | 51 ----- .../main/java/common/tileentity/LockCode.java | 42 ---- .../main/java/common/tileentity/Passcode.java | 19 ++ .../common/tileentity/TileEntityLockable.java | 10 +- .../main/java/common/util/EncryptUtil.java | 4 +- common/src/main/java/common/util/Pair.java | 4 + .../src/main/java/common/util/Position.java | 17 +- common/src/main/java/common/util/Triplet.java | 8 +- common/src/main/java/common/util/Tuple.java | 11 - common/src/main/java/common/util/Util.java | 8 +- .../src/main/java/common/util/Vector3f.java | 6 +- .../java/common/village/MerchantRecipe.java | 40 +--- .../common/village/MerchantRecipeList.java | 18 +- server/src/main/java/server/Server.java | 2 +- .../main/java/server/command/Argument.java | 29 +-- .../java/server/command/ArgumentSplitter.java | 106 ++++----- .../java/server/command/CachedExecutable.java | 56 ++--- .../server/command/CommandEnvironment.java | 33 +-- .../java/server/command/DimensionParser.java | 2 +- .../java/server/command/DoubleParser.java | 10 +- .../main/java/server/command/Executable.java | 1 - .../java/server/command/FixedExecutor.java | 35 +-- .../main/java/server/command/IntParser.java | 6 +- .../main/java/server/command/Parameter.java | 48 +--- .../java/server/command/PatternReplacer.java | 32 +-- .../server/command/commands/CommandHelp.java | 24 +- .../command/commands/CommandOfflinetp.java | 2 +- .../server/command/commands/CommandTime.java | 2 +- .../server/command/commands/CommandTp.java | 2 +- .../server/command/commands/CommandWarp.java | 6 +- .../java/server/world/BlockEventData.java | 63 ------ .../src/main/java/server/world/TickEvent.java | 13 ++ .../main/java/server/world/WorldServer.java | 48 ++-- 139 files changed, 957 insertions(+), 1777 deletions(-) create mode 100755 client/src/main/java/client/network/DummyContainer.java delete mode 100755 common/src/main/java/common/block/tech/BlockSourceImpl.java create mode 100755 common/src/main/java/common/dispenser/DispenserPos.java create mode 100755 common/src/main/java/common/dispenser/DispenserSource.java delete mode 100755 common/src/main/java/common/dispenser/ILocatableSource.java delete mode 100755 common/src/main/java/common/dispenser/ILocation.java delete mode 100755 common/src/main/java/common/dispenser/PositionImpl.java delete mode 100755 common/src/main/java/common/entity/npc/ClassInfo.java delete mode 100755 common/src/main/java/common/init/EntityEggInfo.java create mode 100755 common/src/main/java/common/init/EntityInfo.java delete mode 100755 common/src/main/java/common/tileentity/LocalBlockIntercommunication.java delete mode 100755 common/src/main/java/common/tileentity/LockCode.java create mode 100755 common/src/main/java/common/tileentity/Passcode.java create mode 100644 common/src/main/java/common/util/Pair.java delete mode 100644 common/src/main/java/common/util/Tuple.java delete mode 100755 server/src/main/java/server/world/BlockEventData.java create mode 100755 server/src/main/java/server/world/TickEvent.java diff --git a/client/src/main/java/client/Client.java b/client/src/main/java/client/Client.java index 0d6a4d9..420bf47 100755 --- a/client/src/main/java/client/Client.java +++ b/client/src/main/java/client/Client.java @@ -1125,7 +1125,7 @@ public class Client implements IThreadListener { this.framecode(), this.framerate < 1.0f ? 1.0f / this.framerate : this.framerate, this.framerate < 1.0f ? "SPF" : "FPS", this.vsync ? TextColor.DGRAY + "VSYNC" : (this.syncLimited ? TextColor.GREEN + "" + this.syncLimit : TextColor.RED + "UNL"), (float)PerfSection.getTotal(false) / 1000.0f, this.fb_raw_x, this.fb_raw_y, - this.fullscreen ? " @ " + (this.vidMode == null ? "?" : this.vidMode.refresh) + " Hz" : "", + this.fullscreen ? " @ " + (this.vidMode == null ? "?" : this.vidMode.refresh()) + " Hz" : "", this.tpscode(), this.tickrate < 1.0f ? 1.0f / this.tickrate : this.tickrate, this.tickrate < 1.0f ? "SPT" : "TPS", (float)this.tickTarget / 1000.0f, (float)this.tick_time / 1000.0f, this.tickTimeout, @@ -2089,40 +2089,40 @@ public class Client implements IThreadListener { public void poll() { for(WindowEvent event : Window.poll()) { - switch(event.action) { + switch(event.action()) { case BUTTON: - if(event.param1 >= 0 && event.param1 < Button.values().length) - button(Button.values()[event.param1], event.param2 != 0); + if(event.param1() >= 0 && event.param1() < Button.values().length) + button(Button.values()[event.param1()], event.param2() != 0); break; case CHARACTER: - if(event.param1 >= (int)Log.CHR_SPC && event.param1 <= (int)Character.MAX_VALUE) - character((char)event.param1); + if(event.param1() >= (int)Log.CHR_SPC && event.param1() <= (int)Character.MAX_VALUE) + character((char)event.param1()); break; case CLOSED: closed(); break; case CURSOR: - mouse(event.param1, event.param2); + mouse(event.param1(), event.param2()); break; case FOCUS: - focus(event.param1 != 0); + focus(event.param1() != 0); break; case KEY: - if(event.param1 >= 0 && event.param1 < Keysym.values().length) - key(Keysym.values()[event.param1], KeyEvent.values()[event.param2 % KeyEvent.values().length]); + if(event.param1() >= 0 && event.param1() < Keysym.values().length) + key(Keysym.values()[event.param1()], KeyEvent.values()[event.param2() % KeyEvent.values().length]); break; case POSITION: - pos(event.param1, event.param2); + pos(event.param1(), event.param2()); break; case REDRAW: // redraw(); disable as it is pretty useless break; case RESIZE: - fbsize(event.param1, event.param2); + fbsize(event.param1(), event.param2()); break; case SCROLL: - if(event.param1 != 0 || event.param2 != 0) - scroll(event.param1, event.param2); + if(event.param1() != 0 || event.param2() != 0) + scroll(event.param1(), event.param2()); break; } } @@ -2138,7 +2138,7 @@ public class Client implements IThreadListener { public void full(boolean full) { if((full != fullscreen || full) && (!full || vidMode != null)) { if(full) { - Window.setFullscreen(vidMode.width, vidMode.height, vidMode.refresh); + Window.setFullscreen(vidMode.width(), vidMode.height(), vidMode.refresh()); } else { Window.setWindowed(saved_xpos, saved_ypos, xsize, ysize); @@ -2156,7 +2156,7 @@ public class Client implements IThreadListener { } else { DisplayMode mode = Window.getDisplayMode(); - syncLimit = mode != null ? mode.refresh : 60; + syncLimit = mode != null ? mode.refresh() : 60; } Window.setVSync(vsync); } @@ -3113,13 +3113,13 @@ public class Client implements IThreadListener { y = up ? y - Font.YGLYPH : y; for(Iterator iter = log.iterator(); iter.hasNext();) { Message msg = iter.next(); - if((this.tmr_current - msg.time) <= fade || (log == this.chat && this.chatPermanent)) { + if((this.tmr_current - msg.time()) <= fade || (log == this.chat && this.chatPermanent)) { if(align > 0) - Drawing.drawTextbox(msg.message, x, y, bg); + Drawing.drawTextbox(msg.message(), x, y, bg); else if(align < 0) - Drawing.drawTextboxRight(msg.message, x, y, bg); + Drawing.drawTextboxRight(msg.message(), x, y, bg); else - Drawing.drawTextboxCentered(msg.message, x, y, bg); + Drawing.drawTextboxCentered(msg.message(), x, y, bg); y += up ? -(Font.YGLYPH) : Font.YGLYPH; } else { diff --git a/client/src/main/java/client/gui/GuiConnect.java b/client/src/main/java/client/gui/GuiConnect.java index da6a589..1cfd886 100644 --- a/client/src/main/java/client/gui/GuiConnect.java +++ b/client/src/main/java/client/gui/GuiConnect.java @@ -20,7 +20,7 @@ import common.color.TextColor; import common.log.Log; import common.network.IPlayer; import common.util.EncryptUtil; -import common.util.Tuple; +import common.util.Pair; import common.util.Util; public class GuiConnect extends GuiList implements ButtonCallback { @@ -225,35 +225,35 @@ public class GuiConnect extends GuiList implements Button } } else { - Tuple value = Util.getKeyValue(line); - if(value.first.equals("address")) - address = value.second; - else if(value.first.equals("port")) + Pair value = Util.getKeyValue(line); + if(value.first().equals("address")) + address = value.second(); + else if(value.first().equals("port")) try { - port = Integer.parseInt(value.second); + port = Integer.parseInt(value.second()); } catch(NumberFormatException e) { } - else if(value.first.equals("user")) - user = value.second; - else if(value.first.equals("password")) - password = value.second; - else if(value.first.equals("access")) - access = value.second; - else if(value.first.equals("connected")) + else if(value.first().equals("user")) + user = value.second(); + else if(value.first().equals("password")) + password = value.second(); + else if(value.first().equals("access")) + access = value.second(); + else if(value.first().equals("connected")) try { - time = Long.parseLong(value.second); + time = Long.parseLong(value.second()); } catch(NumberFormatException e) { } - else if(value.first.equals("encryption_enforced")) + else if(value.first().equals("encryption_enforced")) enforceEnc = true; - else if(value.first.equals("serverkey")) - serverKey = Util.fromHexString(value.second); - else if(value.first.equals("key")) - key = Util.fromHexString(value.second); - else if(value.first.equals("pubkey")) - pubkey = Util.fromHexString(value.second); + else if(value.first().equals("serverkey")) + serverKey = Util.fromHexString(value.second()); + else if(value.first().equals("key")) + key = Util.fromHexString(value.second()); + else if(value.first().equals("pubkey")) + pubkey = Util.fromHexString(value.second()); } } Collections.sort(this.elements); diff --git a/client/src/main/java/client/gui/character/GuiChar.java b/client/src/main/java/client/gui/character/GuiChar.java index b361056..7a04ca4 100755 --- a/client/src/main/java/client/gui/character/GuiChar.java +++ b/client/src/main/java/client/gui/character/GuiChar.java @@ -54,7 +54,7 @@ import common.entity.npc.EntityHuman; import common.entity.npc.EntityNPC; import common.entity.npc.SpeciesInfo; import common.entity.types.EntityLiving; -import common.init.EntityEggInfo; +import common.init.EntityInfo; import common.init.EntityRegistry; import common.init.SpeciesRegistry; import common.init.UniverseRegistry; @@ -399,9 +399,9 @@ public class GuiChar extends GuiList }, IPlayer.VALID_NICK, this.gm.player == null ? "" : this.gm.player.getCustomNameTag())); this.templateButton.enabled = false; this.dimension = new Random().zrange(UniverseRegistry.getBaseDimensions().size()); - EntityEggInfo egg = EntityRegistry.SPAWN_EGGS.get(this.gm.player == null ? EntityRegistry.getEntityString(EntityHuman.class) : EntityRegistry.getEntityString(this.gm.player)); - if(egg != null && egg.origin != null) { - Dimension dim = UniverseRegistry.getDimension(egg.origin); + EntityInfo egg = EntityRegistry.SPAWN_EGGS.get(this.gm.player == null ? EntityRegistry.getEntityString(EntityHuman.class) : EntityRegistry.getEntityString(this.gm.player)); + if(egg != null && egg.origin() != null) { + Dimension dim = UniverseRegistry.getDimension(egg.origin()); if(dim != null) { for(int z = 0; z < UniverseRegistry.getBaseDimensions().size(); z++) { if(UniverseRegistry.getBaseDimensions().get(z).getDimensionId() == dim.getDimensionId()) { diff --git a/client/src/main/java/client/gui/character/GuiCharacters.java b/client/src/main/java/client/gui/character/GuiCharacters.java index 46e99d8..99f7d96 100644 --- a/client/src/main/java/client/gui/character/GuiCharacters.java +++ b/client/src/main/java/client/gui/character/GuiCharacters.java @@ -33,10 +33,10 @@ public class GuiCharacters extends GuiList impleme Drawing.drawRect(x, y, 1, 36, 0xffaf0000); String str = this.character == null ? TextColor.BLUE + "[" + TextColor.CYAN + "+" + TextColor.BLUE + "]" : String.format(TextColor.GREEN + "Level " + TextColor.DGREEN + "%d " + TextColor.YELLOW + "%s " + TextColor.VIOLET + "%s" + TextColor.GRAY + " [%s%s" + TextColor.GRAY + "]", - character.level, character.type, character.name, character.align.color, character.align.display); + character.level(), character.type(), character.name(), character.align().color, character.align().display); String pos = this.character == null ? TextColor.BROWN + "Neuen Charakter erstellen" : String.format(TextColor.NEON + "%s " + TextColor.GRAY + "bei " + TextColor.ACID + "%d" + TextColor.GRAY + ", " + TextColor.ACID + "%d" + TextColor.GRAY + ", " + TextColor.ACID + "%d", - character.dim, character.pos.getX(), character.pos.getY(), character.pos.getZ()); + character.dim(), character.pos().getX(), character.pos().getY(), character.pos().getZ()); Drawing.drawText(str, x + 3, y, 0xffffffff); Drawing.drawText(pos, x + 3, y + 16, 0xffffffff); } @@ -60,7 +60,7 @@ public class GuiCharacters extends GuiList impleme private void updateButtons() { CharacterEntry entry = this.getSelected(); - this.descField.setText(entry == null ? "" : (entry.character == null ? "*neuer Charakter*" : (entry.character.info == null ? "*keine Beschreibung vorhanden*" : this.getSelected().character.info))); + this.descField.setText(entry == null ? "" : (entry.character == null ? "*neuer Charakter*" : (entry.character.info() == null ? "*keine Beschreibung vorhanden*" : this.getSelected().character.info()))); this.actionButtom.setText(entry != null && entry.character == null ? "Charakter erstellen" : "Charakter spielen"); this.actionButtom.enabled = entry != null && !entry.initial; this.deleteButtom.enabled = entry != null && entry.character != null && !entry.initial; @@ -74,7 +74,7 @@ public class GuiCharacters extends GuiList impleme if(this.gm.getNetHandler() != null) { int initialSelection = this.gm.getNetHandler().getSelectedCharacter(); for(PlayerCharacter character : this.gm.getNetHandler().getCharacterList()) { - this.elements.add(new CharacterEntry(initialSelection == this.elements.size() ? new PlayerCharacter(character.name, character.info, character.align, this.gm.player.worldObj.dimension.getFormattedName(false), this.gm.player.getPosition(), character.type, this.gm.player.experienceLevel) : character, initialSelection == this.elements.size())); + this.elements.add(new CharacterEntry(initialSelection == this.elements.size() ? new PlayerCharacter(character.name(), character.info(), character.align(), this.gm.player.worldObj.dimension.getFormattedName(false), this.gm.player.getPosition(), character.type(), this.gm.player.experienceLevel) : character, initialSelection == this.elements.size())); } this.elements.add(new CharacterEntry(null, false)); this.setSelected(initialSelection); @@ -116,7 +116,7 @@ public class GuiCharacters extends GuiList impleme GuiCharacters.this.gm.getNetHandler().addToSendQueue(new CPacketAction(CPacketAction.Action.DELETE_CHARACTER, GuiCharacters.this.selectedElement)); GuiCharacters.this.gm.displayGuiScreen(GuiCharacters.this); } - }, "Möchtest du diesen Charakter wirklich löschen?", "Der Fortschritt, die Gegenstände und die Historie von \"" + entry.character.name + "\" werden für imer verloren sein!", "Löschen", "Abbrechen")); + }, "Möchtest du diesen Charakter wirklich löschen?", "Der Fortschritt, die Gegenstände und die Historie von \"" + entry.character.name() + "\" werden für imer verloren sein!", "Löschen", "Abbrechen")); } } } diff --git a/client/src/main/java/client/gui/container/GuiMerchant.java b/client/src/main/java/client/gui/container/GuiMerchant.java index 1cf557a..f76faa9 100755 --- a/client/src/main/java/client/gui/container/GuiMerchant.java +++ b/client/src/main/java/client/gui/container/GuiMerchant.java @@ -81,9 +81,9 @@ public class GuiMerchant extends GuiContainer if (merchantrecipelist != null && !merchantrecipelist.isEmpty()) { int k = this.selectedMerchantRecipe; MerchantRecipe merchantrecipe = (MerchantRecipe)merchantrecipelist.get(k); - ItemStack itemstack = merchantrecipe.getBuying(); - ItemStack itemstack1 = merchantrecipe.getSecondBuy(); - ItemStack itemstack2 = merchantrecipe.getSelling(); + ItemStack itemstack = merchantrecipe.first(); + ItemStack itemstack1 = merchantrecipe.second(); + ItemStack itemstack2 = merchantrecipe.result(); this.renderItemOverlayIntoGUI(itemstack, 36, 24, null); if(itemstack1 != null) this.renderItemOverlayIntoGUI(itemstack1, 62, 24, null); @@ -180,9 +180,9 @@ public class GuiMerchant extends GuiContainer // int j = (this.height - this.ySize) / 2; int k = this.selectedMerchantRecipe; MerchantRecipe merchantrecipe = (MerchantRecipe)merchantrecipelist.get(k); - ItemStack itemstack = merchantrecipe.getBuying(); - ItemStack itemstack1 = merchantrecipe.getSecondBuy(); - ItemStack itemstack2 = merchantrecipe.getSelling(); + ItemStack itemstack = merchantrecipe.first(); + ItemStack itemstack1 = merchantrecipe.second(); + ItemStack itemstack2 = merchantrecipe.result(); GL11.glPushMatrix(); ItemRenderer.enableGUIStandardItemLighting(); GlState.disableLighting(); diff --git a/client/src/main/java/client/gui/ingame/GuiForm.java b/client/src/main/java/client/gui/ingame/GuiForm.java index 3533242..19c9636 100644 --- a/client/src/main/java/client/gui/ingame/GuiForm.java +++ b/client/src/main/java/client/gui/ingame/GuiForm.java @@ -35,9 +35,9 @@ public class GuiForm extends Gui implements ButtonCallback { this.add(new Label(0, -100, 300, 20, this.title)); for(int z = 0; z < this.inputs.length; z++) { final int index = z; - final String name = this.inputData[z].first; - Object obj = this.inputData[z].second; - int param = this.inputData[z].third; + final String name = this.inputData[z].first(); + Object obj = this.inputData[z].second(); + int param = this.inputData[z].third(); if(obj instanceof Boolean) { this.inputs[z] = this.add(new Toggle(0, 50 * z, 300, 24, (Boolean)obj, (Boolean)obj, new ToggleCallback() { public void use(Toggle elem, boolean value) { @@ -97,15 +97,15 @@ public class GuiForm extends Gui implements ButtonCallback { this.inputData = data; this.outputData = new Object[data.length]; for(int z = 0; z < data.length; z++) { - Object obj = data[z].second; - this.outputData[z] = obj instanceof String[] ? data[z].third : obj; + Object obj = data[z].second(); + this.outputData[z] = obj instanceof String[] ? data[z].third() : obj; } } public void use(ActButton elem, PressType action) { for(int z = 0; z < this.inputs.length; z++) { if(this.inputs[z] instanceof Field) { - int min = (this.inputData[z].third & 0x7fffffff) >> 16; + int min = (this.inputData[z].third() & 0x7fffffff) >> 16; String text = this.inputs[z].getText(); if(text.length() < min) { if(!GuiForm.this.labels[z].getText().startsWith("" + TextColor.RED)) diff --git a/client/src/main/java/client/network/ClientPlayer.java b/client/src/main/java/client/network/ClientPlayer.java index 08399ac..d91d530 100755 --- a/client/src/main/java/client/network/ClientPlayer.java +++ b/client/src/main/java/client/network/ClientPlayer.java @@ -135,7 +135,6 @@ import common.potion.PotionEffect; import common.rng.Random; import common.sound.Sound; import common.tileentity.IInteractionObject; -import common.tileentity.LocalBlockIntercommunication; import common.tileentity.TileEntity; import common.tileentity.TileEntityMachine; import common.tileentity.TileEntitySign; @@ -1171,7 +1170,7 @@ public class ClientPlayer extends NetHandler implements IClientPlayer } else if (!packetIn.hasSlots()) { - entityplayersp.displayGui(new LocalBlockIntercommunication(packetIn.getGuiId(), packetIn.getWindowTitle())); + entityplayersp.displayGui(new DummyContainer(packetIn.getGuiId(), packetIn.getWindowTitle())); entityplayersp.openContainer.windowId = packetIn.getWindowId(); } else diff --git a/client/src/main/java/client/network/DummyContainer.java b/client/src/main/java/client/network/DummyContainer.java new file mode 100755 index 0000000..634ce22 --- /dev/null +++ b/client/src/main/java/client/network/DummyContainer.java @@ -0,0 +1,12 @@ +package client.network; + +import common.entity.npc.EntityNPC; +import common.inventory.Container; +import common.inventory.InventoryPlayer; +import common.tileentity.IInteractionObject; + +public record DummyContainer(String getGuiID, String getCommandName) implements IInteractionObject { + public Container createContainer(InventoryPlayer playerInventory, EntityNPC playerIn) { + throw new UnsupportedOperationException(); + } +} diff --git a/client/src/main/java/client/renderer/BlockRenderer.java b/client/src/main/java/client/renderer/BlockRenderer.java index 6a3ff0b..70838df 100755 --- a/client/src/main/java/client/renderer/BlockRenderer.java +++ b/client/src/main/java/client/renderer/BlockRenderer.java @@ -189,7 +189,7 @@ public class BlockRenderer for (Facing enumfacing : Facing.values()) { - List list = modelIn.getFaceQuads(enumfacing); + List list = modelIn.getFace(enumfacing); if (!list.isEmpty()) { @@ -204,7 +204,7 @@ public class BlockRenderer } } - List list1 = modelIn.getGeneralQuads(); + List list1 = modelIn.getQuads(); if (list1.size() > 0) { @@ -348,10 +348,10 @@ public class BlockRenderer { for (Facing enumfacing : Facing.values()) { - this.renderModelBrightnessColorQuads(p_178262_2_, red, green, blue, bakedModel.getFaceQuads(enumfacing)); + this.renderModelBrightnessColorQuads(p_178262_2_, red, green, blue, bakedModel.getFace(enumfacing)); } - this.renderModelBrightnessColorQuads(p_178262_2_, red, green, blue, bakedModel.getGeneralQuads()); + this.renderModelBrightnessColorQuads(p_178262_2_, red, green, blue, bakedModel.getQuads()); } private void renderModelBrightness(IBakedModel model, State p_178266_2_, float brightness, boolean p_178266_4_) diff --git a/client/src/main/java/client/renderer/ItemModelMesher.java b/client/src/main/java/client/renderer/ItemModelMesher.java index b242df1..5fb6ee1 100755 --- a/client/src/main/java/client/renderer/ItemModelMesher.java +++ b/client/src/main/java/client/renderer/ItemModelMesher.java @@ -37,7 +37,7 @@ public class ItemModelMesher public TextureAtlasSprite getParticleIcon(Item item, int meta) { - return this.getItemModel(new ItemStack(item, 1, meta)).getParticleTexture(); + return this.getItemModel(new ItemStack(item, 1, meta)).getBaseTexture(); } public IBakedModel getItemModel(ItemStack stack) diff --git a/client/src/main/java/client/renderer/RenderBuffer.java b/client/src/main/java/client/renderer/RenderBuffer.java index a6cde1d..ceaa45a 100755 --- a/client/src/main/java/client/renderer/RenderBuffer.java +++ b/client/src/main/java/client/renderer/RenderBuffer.java @@ -196,7 +196,7 @@ public class RenderBuffer { int i = this.vertexCount * this.vertexFormat.getNextOffset() + this.vertexFormat.getOffset(this.vertexFormatIndex); - switch (this.vertexFormatElement.getType()) + switch (this.vertexFormatElement.type()) { case FLOAT: this.byteBuffer.putFloat(i, (float)u); @@ -229,7 +229,7 @@ public class RenderBuffer { int i = this.vertexCount * this.vertexFormat.getNextOffset() + this.vertexFormat.getOffset(this.vertexFormatIndex); - switch (this.vertexFormatElement.getType()) + switch (this.vertexFormatElement.type()) { case FLOAT: this.byteBuffer.putFloat(i, (float)p_181671_1_); @@ -381,7 +381,7 @@ public class RenderBuffer { int i = this.vertexCount * this.vertexFormat.getNextOffset() + this.vertexFormat.getOffset(this.vertexFormatIndex); - switch (this.vertexFormatElement.getType()) + switch (this.vertexFormatElement.type()) { case FLOAT: this.byteBuffer.putFloat(i, (float)red / 255.0F); @@ -447,7 +447,7 @@ public class RenderBuffer { int i = this.vertexCount * this.vertexFormat.getNextOffset() + this.vertexFormat.getOffset(this.vertexFormatIndex); - switch (this.vertexFormatElement.getType()) + switch (this.vertexFormatElement.type()) { case FLOAT: this.byteBuffer.putFloat(i, (float)(x + this.xOffset)); @@ -500,7 +500,7 @@ public class RenderBuffer this.vertexFormatIndex %= this.vertexFormat.getElementCount(); this.vertexFormatElement = this.vertexFormat.getElement(this.vertexFormatIndex); - if (this.vertexFormatElement.getUsage() == VertexFormatElement.EnumUsage.PADDING) + if (this.vertexFormatElement.usage() == VertexFormatElement.EnumUsage.PADDING) { this.nextVertexFormatIndex(); } @@ -510,7 +510,7 @@ public class RenderBuffer { int i = this.vertexCount * this.vertexFormat.getNextOffset() + this.vertexFormat.getOffset(this.vertexFormatIndex); - switch (this.vertexFormatElement.getType()) + switch (this.vertexFormatElement.type()) { case FLOAT: this.byteBuffer.putFloat(i, p_181663_1_); diff --git a/client/src/main/java/client/renderer/RenderGlobal.java b/client/src/main/java/client/renderer/RenderGlobal.java index 46d270e..9f87e5f 100755 --- a/client/src/main/java/client/renderer/RenderGlobal.java +++ b/client/src/main/java/client/renderer/RenderGlobal.java @@ -1042,8 +1042,8 @@ public class RenderGlobal // { for (VertexFormatElement vertexformatelement : DefaultVertexFormats.BLOCK.getElements()) { - VertexFormatElement.EnumUsage vertexformatelement$enumusage = vertexformatelement.getUsage(); - int i = vertexformatelement.getIndex(); + VertexFormatElement.EnumUsage vertexformatelement$enumusage = vertexformatelement.usage(); + int i = vertexformatelement.index(); switch (vertexformatelement$enumusage) { diff --git a/client/src/main/java/client/renderer/Tessellator.java b/client/src/main/java/client/renderer/Tessellator.java index 014e658..c7d69b9 100755 --- a/client/src/main/java/client/renderer/Tessellator.java +++ b/client/src/main/java/client/renderer/Tessellator.java @@ -28,27 +28,27 @@ public abstract class Tessellator for (int j = 0; j < list.size(); ++j) { VertexFormatElement vertexformatelement = (VertexFormatElement)list.get(j); - VertexFormatElement.EnumUsage vertexformatelement$enumusage = vertexformatelement.getUsage(); - int k = vertexformatelement.getType().getGlConstant(); - int l = vertexformatelement.getIndex(); + VertexFormatElement.EnumUsage vertexformatelement$enumusage = vertexformatelement.usage(); + int k = vertexformatelement.type().getGlConstant(); + int l = vertexformatelement.index(); bytebuffer.position(vertexformat.getOffset(j)); switch (vertexformatelement$enumusage) { case POSITION: - GL11.glVertexPointer(vertexformatelement.getElementCount(), k, i, bytebuffer); + GL11.glVertexPointer(vertexformatelement.count(), k, i, bytebuffer); GL11.glEnableClientState(GL11.GL_VERTEX_ARRAY); break; case UV: GL13.glClientActiveTexture(GL13.GL_TEXTURE0 + l); - GL11.glTexCoordPointer(vertexformatelement.getElementCount(), k, i, bytebuffer); + GL11.glTexCoordPointer(vertexformatelement.count(), k, i, bytebuffer); GL11.glEnableClientState(GL11.GL_TEXTURE_COORD_ARRAY); GL13.glClientActiveTexture(GL13.GL_TEXTURE0); break; case COLOR: - GL11.glColorPointer(vertexformatelement.getElementCount(), k, i, bytebuffer); + GL11.glColorPointer(vertexformatelement.count(), k, i, bytebuffer); GL11.glEnableClientState(GL11.GL_COLOR_ARRAY); break; @@ -64,8 +64,8 @@ public abstract class Tessellator for (int j1 = list.size(); i1 < j1; ++i1) { VertexFormatElement vertexformatelement1 = (VertexFormatElement)list.get(i1); - VertexFormatElement.EnumUsage vertexformatelement$enumusage1 = vertexformatelement1.getUsage(); - int k1 = vertexformatelement1.getIndex(); + VertexFormatElement.EnumUsage vertexformatelement$enumusage1 = vertexformatelement1.usage(); + int k1 = vertexformatelement1.index(); switch (vertexformatelement$enumusage1) { diff --git a/client/src/main/java/client/renderer/VertexFormat.java b/client/src/main/java/client/renderer/VertexFormat.java index 1091d82..0ab4281 100755 --- a/client/src/main/java/client/renderer/VertexFormat.java +++ b/client/src/main/java/client/renderer/VertexFormat.java @@ -51,7 +51,7 @@ public class VertexFormat public VertexFormat addElement(VertexFormatElement element) { - if (element.isPositionElement() && this.hasPosition()) + if (element.isPosition() && this.hasPosition()) { Log.RENDER.warn("VertexFormat-Fehler: Versuche eine Position vom Typ VertexFormatElement hinzuzufügen, während eine bereits existiert, ignoriere."); return this; @@ -61,7 +61,7 @@ public class VertexFormat this.elements.add(element); this.offsets.add(Integer.valueOf(this.nextOffset)); - switch (element.getUsage()) + switch (element.usage()) { case NORMAL: this.normalElementOffset = this.nextOffset; @@ -72,10 +72,10 @@ public class VertexFormat break; case UV: - this.uvOffsetsById.add(element.getIndex(), Integer.valueOf(this.nextOffset)); + this.uvOffsetsById.add(element.index(), Integer.valueOf(this.nextOffset)); } - this.nextOffset += element.getSize(); + this.nextOffset += element.size(); return this; } } @@ -135,7 +135,7 @@ public class VertexFormat { VertexFormatElement vertexformatelement = (VertexFormatElement)this.elements.get(i); - if (vertexformatelement.isPositionElement()) + if (vertexformatelement.isPosition()) { return true; } diff --git a/client/src/main/java/client/renderer/VertexFormatElement.java b/client/src/main/java/client/renderer/VertexFormatElement.java index 11d4e4e..9062f91 100755 --- a/client/src/main/java/client/renderer/VertexFormatElement.java +++ b/client/src/main/java/client/renderer/VertexFormatElement.java @@ -2,155 +2,83 @@ package client.renderer; import org.lwjgl.opengl.GL11; -import common.log.Log; +public record VertexFormatElement(int index, VertexFormatElement.EnumType type, VertexFormatElement.EnumUsage usage, int count) { + public String toString() { + return this.count + "," + this.usage.getName() + "," + this.type.getName(); + } -public class VertexFormatElement -{ - private final VertexFormatElement.EnumType type; - private final VertexFormatElement.EnumUsage usage; - private int index; - private int elementCount; + public int size() { + return this.type.getSize() * this.count; + } - public VertexFormatElement(int indexIn, VertexFormatElement.EnumType typeIn, VertexFormatElement.EnumUsage usageIn, int count) - { - if (!this.isValid(indexIn, usageIn)) - { - Log.RENDER.warn("Mehrere Vertex-Elemente des gleichen Typs außer UVs sind nicht unterstützt. Erzwinge Typ UV."); - this.usage = VertexFormatElement.EnumUsage.UV; - } - else - { - this.usage = usageIn; - } + public boolean isPosition() { + return this.usage == VertexFormatElement.EnumUsage.POSITION; + } - this.type = typeIn; - this.index = indexIn; - this.elementCount = count; - } + public boolean equals(Object other) { + if(this == other) + return true; + if(!(other instanceof VertexFormatElement)) + return false; + VertexFormatElement elem = (VertexFormatElement)other; + return this.count == elem.count && this.index == elem.index && this.type == elem.type && this.usage == elem.usage; + } - private final boolean isValid(int index, VertexFormatElement.EnumUsage usage) - { - return index == 0 || usage == VertexFormatElement.EnumUsage.UV; - } + public int hashCode() { + int i = this.type.hashCode(); + i = 31 * i + this.usage.hashCode(); + i = 31 * i + this.index; + i = 31 * i + this.count; + return i; + } - public final VertexFormatElement.EnumType getType() - { - return this.type; - } + public static enum EnumType { + FLOAT(4, "Float", GL11.GL_FLOAT), + UBYTE(1, "Unsigned Byte", GL11.GL_UNSIGNED_BYTE), + BYTE(1, "Byte", GL11.GL_BYTE), + USHORT(2, "Unsigned Short", GL11.GL_UNSIGNED_SHORT), + SHORT(2, "Short", GL11.GL_SHORT), + UINT(4, "Unsigned Int", GL11.GL_UNSIGNED_INT), + INT(4, "Int", GL11.GL_INT); - public final VertexFormatElement.EnumUsage getUsage() - { - return this.usage; - } + private final int size; + private final String name; + private final int glConstant; - public final int getElementCount() - { - return this.elementCount; - } + private EnumType(int size, String name, int glConstant) { + this.size = size; + this.name = name; + this.glConstant = glConstant; + } - public final int getIndex() - { - return this.index; - } + public int getSize() { + return this.size; + } - public String toString() - { - return this.elementCount + "," + this.usage.getDisplayName() + "," + this.type.getDisplayName(); - } + public String getName() { + return this.name; + } - public final int getSize() - { - return this.type.getSize() * this.elementCount; - } + public int getGlConstant() { + return this.glConstant; + } + } - public final boolean isPositionElement() - { - return this.usage == VertexFormatElement.EnumUsage.POSITION; - } + public static enum EnumUsage { + POSITION("Position"), + NORMAL("Normal"), + COLOR("Vertex Color"), + UV("UV"), + PADDING("Padding"); - public boolean equals(Object p_equals_1_) - { - if (this == p_equals_1_) - { - return true; - } - else if (p_equals_1_ != null && this.getClass() == p_equals_1_.getClass()) - { - VertexFormatElement vertexformatelement = (VertexFormatElement)p_equals_1_; - return this.elementCount != vertexformatelement.elementCount ? false : (this.index != vertexformatelement.index ? false : (this.type != vertexformatelement.type ? false : this.usage == vertexformatelement.usage)); - } - else - { - return false; - } - } + private final String name; - public int hashCode() - { - int i = this.type.hashCode(); - i = 31 * i + this.usage.hashCode(); - i = 31 * i + this.index; - i = 31 * i + this.elementCount; - return i; - } + private EnumUsage(String name) { + this.name = name; + } - public static enum EnumType - { - FLOAT(4, "Float", GL11.GL_FLOAT), - UBYTE(1, "Unsigned Byte", GL11.GL_UNSIGNED_BYTE), - BYTE(1, "Byte", GL11.GL_BYTE), - USHORT(2, "Unsigned Short", GL11.GL_UNSIGNED_SHORT), - SHORT(2, "Short", GL11.GL_SHORT), - UINT(4, "Unsigned Int", GL11.GL_UNSIGNED_INT), - INT(4, "Int", GL11.GL_INT); - - private final int size; - private final String displayName; - private final int glConstant; - - private EnumType(int sizeIn, String displayNameIn, int glConstantIn) - { - this.size = sizeIn; - this.displayName = displayNameIn; - this.glConstant = glConstantIn; - } - - public int getSize() - { - return this.size; - } - - public String getDisplayName() - { - return this.displayName; - } - - public int getGlConstant() - { - return this.glConstant; - } - } - - public static enum EnumUsage - { - POSITION("Position"), - NORMAL("Normal"), - COLOR("Vertex Color"), - UV("UV"), -// MATRIX("Bone Matrix"), -// BLEND_WEIGHT("Blend Weight"), - PADDING("Padding"); - - private final String displayName; - - private EnumUsage(String displayNameIn) - { - this.displayName = displayNameIn; - } - - public String getDisplayName() - { - return this.displayName; - } - } + public String getName() { + return this.name; + } + } } diff --git a/client/src/main/java/client/renderer/blockmodel/BakedModel.java b/client/src/main/java/client/renderer/blockmodel/BakedModel.java index d383523..c0ccd78 100755 --- a/client/src/main/java/client/renderer/blockmodel/BakedModel.java +++ b/client/src/main/java/client/renderer/blockmodel/BakedModel.java @@ -8,146 +8,80 @@ import common.collect.Lists; import common.model.Transforms; import common.util.Facing; -public class BakedModel implements IBakedModel -{ - protected final List generalQuads; - protected final List> faceQuads; - protected final boolean ambientOcclusion; - protected final boolean gui3d; - protected final TextureAtlasSprite texture; - protected final Transforms cameraTransforms; +public record BakedModel(List getQuads, List> getFace, boolean isGui3d, TextureAtlasSprite getBaseTexture, Transforms getTransforms) implements IBakedModel { + public List getFace(Facing face) { + return this.getFace.get(face.ordinal()); + } - public BakedModel(List generalQuadsIn, List> faceQuadsIn, boolean ambientOcclusionIn, boolean gui3dIn, TextureAtlasSprite textureIn, Transforms cameraTransformsIn) - { - this.generalQuads = generalQuadsIn; - this.faceQuads = faceQuadsIn; - this.ambientOcclusion = ambientOcclusionIn; - this.gui3d = gui3dIn; - this.texture = textureIn; - this.cameraTransforms = cameraTransformsIn; - } + public boolean isBuiltin() { + return false; + } - public List getFaceQuads(Facing facing) - { - return this.faceQuads.get(facing.ordinal()); - } + public static class Builder { + private final List quads; + private final List> faces; + private TextureAtlasSprite texture; + private boolean gui3d; + private Transforms transforms; - public List getGeneralQuads() - { - return this.generalQuads; - } + public Builder(ModelBlock model) { + this(model.isGui3d(), model.getTransform()); + } - public boolean isAmbientOcclusion() - { - return this.ambientOcclusion; - } + public Builder(IBakedModel model, TextureAtlasSprite texture) { + this(model.isGui3d(), model.getTransforms()); + this.texture = model.getBaseTexture(); - public boolean isGui3d() - { - return this.gui3d; - } + for(Facing face : Facing.values()) { + this.addFaceBreakingFours(model, texture, face); + } - public boolean isBuiltInRenderer() - { - return false; - } + this.addGeneralBreakingFours(model, texture); + } - public TextureAtlasSprite getParticleTexture() - { - return this.texture; - } + private void addFaceBreakingFours(IBakedModel model, TextureAtlasSprite texture, Facing facing) { + for(BakedQuad quad : model.getFace(facing)) { + this.addFaceQuad(facing, new BreakingFour(quad, texture)); + } + } - public Transforms getItemCameraTransforms() - { - return this.cameraTransforms; - } + private void addGeneralBreakingFours(IBakedModel model, TextureAtlasSprite texture) { + for(BakedQuad quad : model.getQuads()) { + this.addGeneralQuad(new BreakingFour(quad, texture)); + } + } - public static class Builder - { - private final List builderGeneralQuads; - private final List> builderFaceQuads; - private final boolean builderAmbientOcclusion; - private TextureAtlasSprite builderTexture; - private boolean builderGui3d; - private Transforms builderCameraTransforms; + private Builder(boolean gui3d, Transforms transforms) { + this.quads = Lists.newArrayList(); + this.faces = new ArrayList>(6); - public Builder(ModelBlock model) - { - this(model.isAmbientOcclusion(), model.isGui3d(), model.getTransform()); - } + for(Facing face : Facing.values()) { + this.faces.add(Lists.newArrayList()); + } - public Builder(IBakedModel bakedModel, TextureAtlasSprite texture) - { - this(bakedModel.isAmbientOcclusion(), bakedModel.isGui3d(), bakedModel.getItemCameraTransforms()); - this.builderTexture = bakedModel.getParticleTexture(); + this.gui3d = gui3d; + this.transforms = transforms; + } - for (Facing enumfacing : Facing.values()) - { - this.addFaceBreakingFours(bakedModel, texture, enumfacing); - } + public BakedModel.Builder addFaceQuad(Facing face, BakedQuad quad) { + this.faces.get(face.ordinal()).add(quad); + return this; + } - this.addGeneralBreakingFours(bakedModel, texture); - } + public BakedModel.Builder addGeneralQuad(BakedQuad quad) { + this.quads.add(quad); + return this; + } - private void addFaceBreakingFours(IBakedModel bakedModel, TextureAtlasSprite texture, Facing facing) - { - for (BakedQuad bakedquad : bakedModel.getFaceQuads(facing)) - { - this.addFaceQuad(facing, new BreakingFour(bakedquad, texture)); - } - } + public BakedModel.Builder setTexture(TextureAtlasSprite texture) { + this.texture = texture; + return this; + } - private void addGeneralBreakingFours(IBakedModel p_177647_1_, TextureAtlasSprite texture) - { - for (BakedQuad bakedquad : p_177647_1_.getGeneralQuads()) - { - this.addGeneralQuad(new BreakingFour(bakedquad, texture)); - } - } - - private Builder(boolean ambientOcclusion, boolean gui3d, Transforms cameraTransforms) - { - this.builderGeneralQuads = Lists.newArrayList(); - this.builderFaceQuads = new ArrayList>(6); - - for (Facing enumfacing : Facing.values()) - { - this.builderFaceQuads.add(Lists.newArrayList()); - } - - this.builderAmbientOcclusion = ambientOcclusion; - this.builderGui3d = gui3d; - this.builderCameraTransforms = cameraTransforms; - } - - public BakedModel.Builder addFaceQuad(Facing facing, BakedQuad quad) - { - ((List)this.builderFaceQuads.get(facing.ordinal())).add(quad); - return this; - } - - public BakedModel.Builder addGeneralQuad(BakedQuad quad) - { - this.builderGeneralQuads.add(quad); - return this; - } - - public BakedModel.Builder setTexture(TextureAtlasSprite texture) - { - this.builderTexture = texture; - return this; - } - - public BakedModel makeBakedModel() - { - if (this.builderTexture == null) - { - throw new RuntimeException("Missing particle!"); - } - else - { - return new BakedModel(this.builderGeneralQuads, this.builderFaceQuads, this.builderAmbientOcclusion, this.builderGui3d, this.builderTexture, this.builderCameraTransforms); - } - } - } + public BakedModel makeBakedModel() { + if(this.texture == null) + throw new RuntimeException("Fehlende Basistextur"); + return new BakedModel(this.quads, this.faces, this.gui3d, this.texture, this.transforms); + } + } } diff --git a/client/src/main/java/client/renderer/blockmodel/BuiltInModel.java b/client/src/main/java/client/renderer/blockmodel/BuiltInModel.java index 802fcc9..fd40a16 100755 --- a/client/src/main/java/client/renderer/blockmodel/BuiltInModel.java +++ b/client/src/main/java/client/renderer/blockmodel/BuiltInModel.java @@ -6,47 +6,24 @@ import client.renderer.texture.TextureAtlasSprite; import common.model.Transforms; import common.util.Facing; -public class BuiltInModel implements IBakedModel -{ - private Transforms cameraTransforms; +public record BuiltInModel(Transforms getTransforms) implements IBakedModel { + public List getFace(Facing face) { + return null; + } - public BuiltInModel(Transforms p_i46086_1_) - { - this.cameraTransforms = p_i46086_1_; - } + public List getQuads() { + return null; + } - public List getFaceQuads(Facing facing) - { - return null; - } + public boolean isGui3d() { + return true; + } - public List getGeneralQuads() - { - return null; - } + public boolean isBuiltin() { + return true; + } - public boolean isAmbientOcclusion() - { - return false; - } - - public boolean isGui3d() - { - return true; - } - - public boolean isBuiltInRenderer() - { - return true; - } - - public TextureAtlasSprite getParticleTexture() - { - return null; - } - - public Transforms getItemCameraTransforms() - { - return this.cameraTransforms; - } + public TextureAtlasSprite getBaseTexture() { + return null; + } } diff --git a/client/src/main/java/client/renderer/blockmodel/IBakedModel.java b/client/src/main/java/client/renderer/blockmodel/IBakedModel.java index 490f71b..d1de616 100755 --- a/client/src/main/java/client/renderer/blockmodel/IBakedModel.java +++ b/client/src/main/java/client/renderer/blockmodel/IBakedModel.java @@ -8,17 +8,15 @@ import common.util.Facing; public interface IBakedModel { - List getFaceQuads(Facing facing); + List getFace(Facing facing); - List getGeneralQuads(); - - boolean isAmbientOcclusion(); + List getQuads(); boolean isGui3d(); - boolean isBuiltInRenderer(); + boolean isBuiltin(); - TextureAtlasSprite getParticleTexture(); + TextureAtlasSprite getBaseTexture(); - Transforms getItemCameraTransforms(); + Transforms getTransforms(); } diff --git a/client/src/main/java/client/renderer/blockmodel/ModelManager.java b/client/src/main/java/client/renderer/blockmodel/ModelManager.java index 50484e1..e550d93 100755 --- a/client/src/main/java/client/renderer/blockmodel/ModelManager.java +++ b/client/src/main/java/client/renderer/blockmodel/ModelManager.java @@ -124,7 +124,7 @@ public class ModelManager ibakedmodel = this.defaultModel; } - return ibakedmodel.getParticleTexture(); + return ibakedmodel.getBaseTexture(); } public IBakedModel getModelForState(State state) diff --git a/client/src/main/java/client/renderer/entity/RenderEntityItem.java b/client/src/main/java/client/renderer/entity/RenderEntityItem.java index 3a61d04..4ba2eff 100755 --- a/client/src/main/java/client/renderer/entity/RenderEntityItem.java +++ b/client/src/main/java/client/renderer/entity/RenderEntityItem.java @@ -40,7 +40,7 @@ public class RenderEntityItem extends Render int i = this.func_177078_a(itemstack); float f = 0.25F; float f1 = ExtMath.sin(((float)itemIn.getAge() + p_177077_8_) / 10.0F + itemIn.hoverStart) * 0.1F + 0.1F; - float f2 = p_177077_9_.getItemCameraTransforms().get(Transforms.Camera.GROUND).scale.y; + float f2 = p_177077_9_.getTransforms().get(Transforms.Camera.GROUND).scale(); GL11.glTranslatef((float)p_177077_2_, (float)p_177077_4_ + f1 + 0.25F * f2, (float)p_177077_6_); if (flag || this.renderManager.gm != null) @@ -126,20 +126,18 @@ public class RenderEntityItem extends Render } GL11.glScalef(0.5F, 0.5F, 0.5F); - RenderItem.apply(ibakedmodel.getItemCameraTransforms(), Transforms.Camera.GROUND); + RenderItem.apply(ibakedmodel.getTransforms(), Transforms.Camera.GROUND); this.itemRenderer.renderItem(itemstack, ibakedmodel); GL11.glPopMatrix(); } else { GL11.glPushMatrix(); - RenderItem.apply(ibakedmodel.getItemCameraTransforms(), Transforms.Camera.GROUND); + RenderItem.apply(ibakedmodel.getTransforms(), Transforms.Camera.GROUND); this.itemRenderer.renderItem(itemstack, ibakedmodel); GL11.glPopMatrix(); - float f3 = ibakedmodel.getItemCameraTransforms().ground.scale.x; - float f4 = ibakedmodel.getItemCameraTransforms().ground.scale.y; - float f5 = ibakedmodel.getItemCameraTransforms().ground.scale.z; - GL11.glTranslatef(0.0F * f3, 0.0F * f4, 0.046875F * f5); + float f3 = ibakedmodel.getTransforms().ground.scale(); + GL11.glTranslatef(0.0F, 0.0F, 0.046875F * f3); } } diff --git a/client/src/main/java/client/renderer/entity/RenderItem.java b/client/src/main/java/client/renderer/entity/RenderItem.java index d1ab920..a2a790f 100755 --- a/client/src/main/java/client/renderer/entity/RenderItem.java +++ b/client/src/main/java/client/renderer/entity/RenderItem.java @@ -77,10 +77,10 @@ public class RenderItem for (Facing enumfacing : Facing.values()) { - this.renderQuads(worldrenderer, model.getFaceQuads(enumfacing), color, stack); + this.renderQuads(worldrenderer, model.getFace(enumfacing), color, stack); } - this.renderQuads(worldrenderer, model.getGeneralQuads(), color, stack); + this.renderQuads(worldrenderer, model.getQuads(), color, stack); Tessellator.draw(); } @@ -91,7 +91,7 @@ public class RenderItem GL11.glPushMatrix(); GL11.glScalef(0.5F, 0.5F, 0.5F); - if (model.isBuiltInRenderer()) + if (model.isBuiltin()) { GL11.glRotatef(180.0F, 0.0F, 1.0F, 0.0F); GL11.glTranslatef(-0.5F, -0.5F, -0.5F); @@ -270,14 +270,9 @@ public class RenderItem GlState.enableBlend(); GlState.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ZERO); GL11.glPushMatrix(); - Transforms itemcameratransforms = model.getItemCameraTransforms(); + Transforms itemcameratransforms = model.getTransforms(); RenderItem.apply(itemcameratransforms, cameraTransformType); - if (this.isThereOneNegativeScale(itemcameratransforms.get(cameraTransformType))) - { - GlState.cullFace(GL11.GL_FRONT); - } - this.renderItem(stack, model); GlState.cullFace(GL11.GL_BACK); GL11.glPopMatrix(); @@ -287,16 +282,6 @@ public class RenderItem // this.textureManager.getTexture(TextureMap.locationBlocksTexture).restoreLastMipmap(); } - /** - * Return true if only one scale is negative - * - * @param itemTranformVec The ItemTransformVec3f instance - */ - private boolean isThereOneNegativeScale(Transform itemTranformVec) - { - return itemTranformVec.scale.x < 0.0F ^ itemTranformVec.scale.y < 0.0F ^ itemTranformVec.scale.z < 0.0F; - } - private void renderItemIntoGUI(ItemStack stack, int x, int y) { IBakedModel ibakedmodel = this.itemModelMesher.getItemModel(stack); @@ -310,7 +295,7 @@ public class RenderItem GlState.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GlState.color(1.0F, 1.0F, 1.0F, 1.0F); this.setupGuiTransform(x, y, ibakedmodel.isGui3d()); - RenderItem.apply(ibakedmodel.getItemCameraTransforms(), Transforms.Camera.GUI); + RenderItem.apply(ibakedmodel.getTransforms(), Transforms.Camera.GUI); this.renderItem(stack, ibakedmodel); GlState.disableAlpha(); GlState.disableRescaleNormal(); @@ -362,11 +347,11 @@ public class RenderItem public static void apply(Transforms trans, Transforms.Camera type) { Transform vec = trans.get(type); if(vec != Transform.IDENTITY) { - GL11.glTranslatef(vec.translation.x, vec.translation.y, vec.translation.z); - GL11.glRotatef(vec.rotation.y, 0.0F, 1.0F, 0.0F); - GL11.glRotatef(vec.rotation.x, 1.0F, 0.0F, 0.0F); - GL11.glRotatef(vec.rotation.z, 0.0F, 0.0F, 1.0F); - GL11.glScalef(vec.scale.x, vec.scale.y, vec.scale.z); + GL11.glTranslatef(vec.translationX(), vec.translationY(), vec.translationZ()); + GL11.glRotatef(vec.rotationY(), 0.0F, 1.0F, 0.0F); + GL11.glRotatef(vec.rotationX(), 1.0F, 0.0F, 0.0F); + GL11.glRotatef(vec.rotationZ(), 0.0F, 0.0F, 1.0F); + GL11.glScalef(vec.scale(), vec.scale(), vec.scale()); } } } diff --git a/client/src/main/java/client/util/Message.java b/client/src/main/java/client/util/Message.java index 441a7b0..284196c 100644 --- a/client/src/main/java/client/util/Message.java +++ b/client/src/main/java/client/util/Message.java @@ -1,11 +1,4 @@ package client.util; -public class Message { - public final String message; - public final long time; - - public Message(String message, long time) { - this.message = message; - this.time = time; - } +public record Message(String message, long time) { } diff --git a/client/src/main/java/client/window/DisplayMode.java b/client/src/main/java/client/window/DisplayMode.java index 8d2e079..d9dfb47 100644 --- a/client/src/main/java/client/window/DisplayMode.java +++ b/client/src/main/java/client/window/DisplayMode.java @@ -1,16 +1,6 @@ package client.window; -public class DisplayMode { - public final int width; - public final int height; - public final int refresh; - - public DisplayMode(int width, int height, int refresh) { - this.width = width; - this.height = height; - this.refresh = refresh; - } - +public record DisplayMode(int width, int height, int refresh) { public String toString() { return String.format("%dx%d @ %d Hz", this.width, this.height, this.refresh); } diff --git a/client/src/main/java/client/window/WindowEvent.java b/client/src/main/java/client/window/WindowEvent.java index 294b005..b92f7a6 100644 --- a/client/src/main/java/client/window/WindowEvent.java +++ b/client/src/main/java/client/window/WindowEvent.java @@ -1,13 +1,4 @@ package client.window; -public class WindowEvent { - public final WindowAction action; - public final int param1; - public final int param2; - - public WindowEvent(WindowAction action, int p1, int p2) { - this.action = action; - this.param1 = p1; - this.param2 = p2; - } +public record WindowEvent(WindowAction action, int param1, int param2) { } diff --git a/common/src/main/java/common/ai/EntityAIFindEntityNearest.java b/common/src/main/java/common/ai/EntityAIFindEntityNearest.java index 87eb994..d7e991d 100755 --- a/common/src/main/java/common/ai/EntityAIFindEntityNearest.java +++ b/common/src/main/java/common/ai/EntityAIFindEntityNearest.java @@ -4,8 +4,8 @@ import java.util.Collections; import java.util.List; import java.util.function.Predicate; +import common.attributes.Attribute; import common.attributes.AttributeInstance; -import common.attributes.Attributes; import common.entity.types.EntityLiving; public class EntityAIFindEntityNearest extends EntityAIBase @@ -105,7 +105,7 @@ public class EntityAIFindEntityNearest extends EntityAIBase protected double getFollowRange() { - AttributeInstance iattributeinstance = this.mob.getEntityAttribute(Attributes.FOLLOW_RANGE); + AttributeInstance iattributeinstance = this.mob.getEntityAttribute(Attribute.FOLLOW_RANGE); return iattributeinstance == null ? 16.0D : iattributeinstance.getAttributeValue(); } } diff --git a/common/src/main/java/common/ai/EntityAITarget.java b/common/src/main/java/common/ai/EntityAITarget.java index 58d7769..f61437a 100755 --- a/common/src/main/java/common/ai/EntityAITarget.java +++ b/common/src/main/java/common/ai/EntityAITarget.java @@ -1,7 +1,7 @@ package common.ai; +import common.attributes.Attribute; import common.attributes.AttributeInstance; -import common.attributes.Attributes; import common.entity.types.EntityLiving; import common.entity.types.IEntityOwnable; import common.init.Config; @@ -107,7 +107,7 @@ public abstract class EntityAITarget extends EntityAIBase protected double getTargetDistance() { - AttributeInstance iattributeinstance = this.taskOwner.getEntityAttribute(Attributes.FOLLOW_RANGE); + AttributeInstance iattributeinstance = this.taskOwner.getEntityAttribute(Attribute.FOLLOW_RANGE); return iattributeinstance == null ? 16.0D : iattributeinstance.getAttributeValue(); } diff --git a/common/src/main/java/common/ai/EntityMoveHelper.java b/common/src/main/java/common/ai/EntityMoveHelper.java index 74f4f40..03d7742 100755 --- a/common/src/main/java/common/ai/EntityMoveHelper.java +++ b/common/src/main/java/common/ai/EntityMoveHelper.java @@ -1,6 +1,6 @@ package common.ai; -import common.attributes.Attributes; +import common.attributes.Attribute; import common.entity.types.EntityLiving; import common.util.ExtMath; @@ -63,7 +63,7 @@ public class EntityMoveHelper { float f = (float)(ExtMath.atan2(d1, d0) * 180.0D / Math.PI) - 90.0F; this.entity.rotYaw = this.limitAngle(this.entity.rotYaw, f, 30.0F); - this.entity.setAIMoveSpeed((float)(this.speed * this.entity.getEntityAttribute(Attributes.MOVEMENT_SPEED).getAttributeValue())); + this.entity.setAIMoveSpeed((float)(this.speed * this.entity.getEntityAttribute(Attribute.MOVEMENT_SPEED).getAttributeValue())); if (d2 > 0.0D && d0 * d0 + d1 * d1 < 1.0D) { diff --git a/common/src/main/java/common/attributes/Attribute.java b/common/src/main/java/common/attributes/Attribute.java index ed6c7e9..384430e 100755 --- a/common/src/main/java/common/attributes/Attribute.java +++ b/common/src/main/java/common/attributes/Attribute.java @@ -3,82 +3,76 @@ package common.attributes; import java.util.Map; import common.collect.Maps; +import common.util.Displayable; import common.util.ExtMath; +import common.util.Identifyable; + +public enum Attribute implements Identifyable, Displayable { + MAX_HEALTH("generic.maxHealth", "Maximale Gesundheit", 20.0D, 0.0D, 1024.0D, true), + FOLLOW_RANGE("generic.followRange", "Kreaturen-Folgedistanz", 32.0D, 0.0D, 2048.0D, false), + KNOCKBACK_RESISTANCE("generic.knockbackResistance", "Standfestigkeit", 0.0D, 0.0D, 1.0D, false), + MOVEMENT_SPEED("generic.movementSpeed", "Geschwindigkeit", 0.699999988079071D, 0.0D, 1024.0D, true), + ATTACK_DAMAGE("generic.attackDamage", "Angriffsschaden", 2.0D, 0.0D, 2048.0D, false), + RADIATION("generic.radiation", "Strahlung", 0.0D, 0.0D, 16384.0D, false), + RADIATION_RESISTANCE("generic.radiationResistance", "Strahlungsresistenz", 10.0D, 0.0D, 16384.0D, false), + MANA_CAPACITY("generic.manaCapacity", "Mana-Kapazität", 0.0D, 0.0D, 2048.0D, false), + MAGIC_RESISTANCE("generic.magicResistance", "Magieresistenz", 0.0D, 0.0D, 4096.0D, false), + REINFORCEMENT_CHANCE("zombie.spawnReinforcements", "Zombie-Verstärkung", 0.0D, 0.0D, 1.0D, false), + HORSE_JUMP_STRENGTH("horse.jumpStrength", "Pferdesprungstärke", 0.7D, 0.0D, 2.0D, true); -public class Attribute -{ private static final Map ATTRIBUTES = Maps.newHashMap(); - - private final String name; - private final String display; - private final double defValue; - private final double minValue; - private final double maxValue; - private final boolean shouldWatch; - - public static Attribute getAttribute(String name) { - return ATTRIBUTES.get(name); - } - public Attribute(String name, String display, double def, double min, double max, boolean watch) - { - this.name = name; - this.display = display; - this.defValue = def; - if(name == null) - throw new IllegalArgumentException("Name cannot be null!"); - this.minValue = min; - this.maxValue = max; - this.shouldWatch = watch; + private final String name; + private final String display; + private final double defValue; + private final double minValue; + private final double maxValue; + private final boolean watch; - if (min > max) - { - throw new IllegalArgumentException("Minimum value cannot be bigger than maximum value!"); - } - else if (def < min) - { - throw new IllegalArgumentException("Default value cannot be lower than minimum value!"); - } - else if (def > max) - { - throw new IllegalArgumentException("Default value cannot be bigger than maximum value!"); - } - - ATTRIBUTES.put(name, this); - } + static { + for(Attribute attr : values()) { + ATTRIBUTES.put(attr.name, attr); + } + } - public String getUnlocalizedName() - { - return this.name; - } + public static Attribute getAttribute(String name) { + return ATTRIBUTES.get(name); + } - public String getDisplayName() - { - return this.display; - } + private Attribute(String name, String display, double def, double min, double max, boolean watch) { + if(name == null) + throw new IllegalArgumentException("Name kann nicht null sein"); + else if(min > max) + throw new IllegalArgumentException("Mindestwert kann nicht größer als Maximalwert sein"); + else if(def < min) + throw new IllegalArgumentException("Standardwert kann nicht kleiner als Mindestwert sein"); + else if(def > max) + throw new IllegalArgumentException("Standardwert kann nicht größer als Maximalwert sein"); + this.name = name; + this.display = display; + this.defValue = def; + this.minValue = min; + this.maxValue = max; + this.watch = watch; + } - public double getDefaultValue() - { - return this.defValue; - } + public String getName() { + return this.name; + } - public boolean getShouldWatch() - { - return this.shouldWatch; - } + public String getDisplay() { + return this.display; + } - public double clampValue(double value) - { - return ExtMath.clampd(value, this.minValue, this.maxValue); - } + public double getDefault() { + return this.defValue; + } - public int hashCode() - { - return this.name.hashCode(); - } + public boolean isWatched() { + return this.watch; + } - public boolean equals(Object obj) - { - return obj instanceof Attribute && this.name.equals(((Attribute)obj).getUnlocalizedName()); - } + public double clamp(double value) { + return ExtMath.clampd(value, this.minValue, this.maxValue); + } } diff --git a/common/src/main/java/common/attributes/AttributeInstance.java b/common/src/main/java/common/attributes/AttributeInstance.java index 299161b..f6f1bb1 100755 --- a/common/src/main/java/common/attributes/AttributeInstance.java +++ b/common/src/main/java/common/attributes/AttributeInstance.java @@ -24,7 +24,7 @@ public class AttributeInstance { this.attributeMap = attributeMapIn; this.genericAttribute = genericAttributeIn; - this.baseValue = genericAttributeIn.getDefaultValue(); + this.baseValue = genericAttributeIn.getDefault(); } public Attribute getAttribute() @@ -168,7 +168,7 @@ public class AttributeInstance base *= 1.0D + attributemodifier2.getAmount(); } - return this.genericAttribute.clampValue(base); + return this.genericAttribute.clamp(base); } // private Collection getModifierList(AttributeOp operation) diff --git a/common/src/main/java/common/attributes/AttributeMap.java b/common/src/main/java/common/attributes/AttributeMap.java index c859fd3..408d465 100755 --- a/common/src/main/java/common/attributes/AttributeMap.java +++ b/common/src/main/java/common/attributes/AttributeMap.java @@ -40,10 +40,10 @@ public class AttributeMap public AttributeInstance registerAttribute(Attribute attribute) { - if(this.nameMap.containsKey(attribute.getUnlocalizedName())) + if(this.nameMap.containsKey(attribute.getName())) throw new IllegalArgumentException("Attribute is already registered!"); AttributeInstance inst = new AttributeInstance(this, attribute); - this.nameMap.put(attribute.getUnlocalizedName(), inst); + this.nameMap.put(attribute.getName(), inst); this.attributes.put(attribute, inst); // for (BaseAttribute iattribute = attribute.func_180372_d(); iattribute != null; iattribute = iattribute.func_180372_d()) // { @@ -61,7 +61,7 @@ public class AttributeMap public void flagDirty(AttributeInstance instance) { - if (this.dirtyAttributes != null && instance.getAttribute().getShouldWatch()) + if (this.dirtyAttributes != null && instance.getAttribute().isWatched()) { this.dirtyAttributes.add(instance); } @@ -88,7 +88,7 @@ public class AttributeMap for (AttributeInstance iattributeinstance : this.getAllAttributes()) { - if (iattributeinstance.getAttribute().getShouldWatch()) + if (iattributeinstance.getAttribute().isWatched()) { set.add(iattributeinstance); } @@ -101,7 +101,7 @@ public class AttributeMap { for (Entry> entry : modifiers.entrySet()) { - AttributeInstance iattributeinstance = this.getAttributeInstanceByName(entry.getKey().getUnlocalizedName()); + AttributeInstance iattributeinstance = this.getAttributeInstanceByName(entry.getKey().getName()); if (iattributeinstance != null) { @@ -116,7 +116,7 @@ public class AttributeMap { for (Entry> entry : modifiers.entrySet()) { - AttributeInstance iattributeinstance = this.getAttributeInstanceByName(entry.getKey().getUnlocalizedName()); + AttributeInstance iattributeinstance = this.getAttributeInstanceByName(entry.getKey().getName()); if (iattributeinstance != null) { @@ -132,7 +132,7 @@ public class AttributeMap { for (Entry> entry : modifiers.entrySet()) { - AttributeInstance iattributeinstance = this.getAttributeInstanceByName(entry.getKey().getUnlocalizedName()); + AttributeInstance iattributeinstance = this.getAttributeInstanceByName(entry.getKey().getName()); if (iattributeinstance != null) { @@ -148,7 +148,7 @@ public class AttributeMap { for (Entry> entry : modifiers.entrySet()) { - AttributeInstance iattributeinstance = this.getAttributeInstanceByName(entry.getKey().getUnlocalizedName()); + AttributeInstance iattributeinstance = this.getAttributeInstanceByName(entry.getKey().getName()); if (iattributeinstance != null) { diff --git a/common/src/main/java/common/attributes/Attributes.java b/common/src/main/java/common/attributes/Attributes.java index 99b33cd..afc2cea 100755 --- a/common/src/main/java/common/attributes/Attributes.java +++ b/common/src/main/java/common/attributes/Attributes.java @@ -7,156 +7,105 @@ import common.log.Log; import common.tags.TagObject; import java.util.List; -public class Attributes -{ - public static final Attribute MAX_HEALTH = (new Attribute("generic.maxHealth", "Maximale Gesundheit", 20.0D, 0.0D, 1024.0D, true)); - public static final Attribute FOLLOW_RANGE = (new Attribute("generic.followRange", "Kreaturen-Folgedistanz", 32.0D, 0.0D, 2048.0D, false)); - public static final Attribute KNOCKBACK_RESISTANCE = (new Attribute("generic.knockbackResistance", "Standfestigkeit", 0.0D, 0.0D, 1.0D, false)); - public static final Attribute MOVEMENT_SPEED = (new Attribute("generic.movementSpeed", "Geschwindigkeit", 0.699999988079071D, 0.0D, 1024.0D, true)); - public static final Attribute ATTACK_DAMAGE = new Attribute("generic.attackDamage", "Angriffsschaden", 2.0D, 0.0D, 2048.0D, false); - public static final Attribute RADIATION = new Attribute("generic.radiation", "Strahlung", 0.0D, 0.0D, 16384.0D, false); - public static final Attribute RADIATION_RESISTANCE = new Attribute("generic.radiationResistance", "Strahlungsresistenz", 10.0D, 0.0D, 16384.0D, false); - public static final Attribute MANA_CAPACITY = new Attribute("generic.manaCapacity", "Mana-Kapazität", 0.0D, 0.0D, 2048.0D, false); - public static final Attribute MAGIC_RESISTANCE = new Attribute("generic.magicResistance", "Magieresistenz", 0.0D, 0.0D, 4096.0D, false); - public static final Attribute REINFORCEMENT_CHANCE = (new Attribute("zombie.spawnReinforcements", "Zombie-Verstärkung", 0.0D, 0.0D, 1.0D, false)); - public static final Attribute HORSE_JUMP_STRENGTH = (new Attribute("horse.jumpStrength", "Pferdesprungstärke", 0.7D, 0.0D, 2.0D, true)); +public class Attributes { + public static final AttributeModifier RUSHING_SPEED_MOD = new AttributeModifier(AttributeModifier.getModifierId("RushSpd"), "Attacking speed boost", 0.05, false, false); + public static final AttributeModifier MAGE_POTSPEED_MOD = new AttributeModifier(AttributeModifier.getModifierId("MagePot"), "Drinking speed penalty", -0.25, false, false); + public static final AttributeModifier ZOMBIE_BABY_MOD = new AttributeModifier(AttributeModifier.getModifierId("ZombSpd"), "Baby speed boost", 0.5, true); + public static final AttributeModifier FLEEING_SPEED_MOD = new AttributeModifier(AttributeModifier.getModifierId("FleeSpd"), "Fleeing speed bonus", 2.0, true, false); + public static final AttributeModifier SPRINT_SPEED_MOD = new AttributeModifier(AttributeModifier.getModifierId("Sprint"), "Sprinting speed boost", 0.3, true, false); + public static final AttributeModifier MOUSE_SPEEDY_MOD = new AttributeModifier(AttributeModifier.getModifierId("SpeedyG"), "Mouse speed boost", 1.0, true); -// public static final long ATTACK_SPEED_ID = AttributeModifier.getModifierId("EnderSp"); -// public static final AttributeModifier ATTACK_SPEED_MOD = (new AttributeModifier(ATTACK_SPEED_ID, "Attacking speed boost", 0.15000000596046448D, false, false)); - public static final long RUSHING_SPEED_ID = AttributeModifier.getModifierId("RushSpd"); - public static final AttributeModifier RUSHING_SPEED_MOD = (new AttributeModifier(RUSHING_SPEED_ID, "Attacking speed boost", 0.05D, false, false)); - public static final long MAGE_POTSPEED_ID = AttributeModifier.getModifierId("MagePot"); - public static final AttributeModifier MAGE_POTSPEED_MOD = (new AttributeModifier(MAGE_POTSPEED_ID, "Drinking speed penalty", -0.25D, false, false)); - public static final long ZOMBIE_BABY_ID = AttributeModifier.getModifierId("ZombSpd"); - public static final AttributeModifier ZOMBIE_BABY_MOD = new AttributeModifier(ZOMBIE_BABY_ID, "Baby speed boost", 0.5D, true); - public static final long FLEEING_SPEED_ID = AttributeModifier.getModifierId("FleeSpd"); - public static final AttributeModifier FLEEING_SPEED_MOD = (new AttributeModifier(FLEEING_SPEED_ID, "Fleeing speed bonus", 2.0D, true, false)); - public static final long SPRINT_SPEED_ID = AttributeModifier.getModifierId("Sprint"); - public static final AttributeModifier SPRINT_SPEED_MOD = (new AttributeModifier(SPRINT_SPEED_ID, "Sprinting speed boost", 0.30000001192092896D, true, false)); public static final long ITEM_VAL_ID = AttributeModifier.getModifierId("ItemVal"); - public static final long RADIATION_BASE = AttributeModifier.getModifierId("NukeVal"); - public static final long MOUSE_SPEEDY_ID = AttributeModifier.getModifierId("SpeedyG"); - public static final AttributeModifier MOUSE_SPEEDY_MOD = new AttributeModifier(MOUSE_SPEEDY_ID, "Mouse speed boost", 1.0D, true); + public static final long ITEM_DMG_ID = AttributeModifier.getModifierId("ItemDmg"); - /** - * Creates an NBTTagList from a BaseAttributeMap, including all its AttributeInstances - */ - public static List writeBaseAttributeMapToNBT(AttributeMap map) - { - List nbttaglist = Lists.newArrayList(); + public static List writeBaseAttributeMapToNBT(AttributeMap map) { + List attrs = Lists.newArrayList(); - for (AttributeInstance iattributeinstance : map.getAllAttributes()) - { - nbttaglist.add(writeAttributeInstanceToNBT(iattributeinstance)); - } + for(AttributeInstance instance : map.getAllAttributes()) { + attrs.add(writeAttributeInstanceToNBT(instance)); + } - return nbttaglist; - } + return attrs; + } - /** - * Creates an NBTTagCompound from an AttributeInstance, including its AttributeModifiers - */ - private static TagObject writeAttributeInstanceToNBT(AttributeInstance instance) - { - TagObject nbttagcompound = new TagObject(); - Attribute iattribute = instance.getAttribute(); - nbttagcompound.setString("Name", iattribute.getUnlocalizedName()); - nbttagcompound.setDouble("Base", instance.getBaseValue()); - Collection collection = instance.getModifiers(); + private static TagObject writeAttributeInstanceToNBT(AttributeInstance instance) { + TagObject tag = new TagObject(); + Attribute attr = instance.getAttribute(); + tag.setString("Name", attr.getName()); + tag.setDouble("Base", instance.getBaseValue()); + Collection modifiers = instance.getModifiers(); - if (collection != null && !collection.isEmpty()) - { - List nbttaglist = Lists.newArrayList(); + if(modifiers != null && !modifiers.isEmpty()) { + List mods = Lists.newArrayList(); - for (AttributeModifier attributemodifier : collection) - { - if (attributemodifier.isSaved()) - { - nbttaglist.add(writeAttributeModifierToNBT(attributemodifier)); - } - } + for(AttributeModifier mod : modifiers) { + if(mod.isSaved()) { + mods.add(writeAttributeModifierToNBT(mod)); + } + } - nbttagcompound.setList("Modifiers", nbttaglist); - } + tag.setList("Modifiers", mods); + } - return nbttagcompound; - } + return tag; + } - /** - * Creates an NBTTagCompound from an AttributeModifier - */ - private static TagObject writeAttributeModifierToNBT(AttributeModifier modifier) - { - TagObject nbttagcompound = new TagObject(); - nbttagcompound.setString("Name", modifier.getName()); - nbttagcompound.setDouble("Amount", modifier.getAmount()); - nbttagcompound.setBool("Multiply", modifier.isMultiplied()); - nbttagcompound.setLong("AttrId", modifier.getID()); - return nbttagcompound; - } + private static TagObject writeAttributeModifierToNBT(AttributeModifier mod) { + TagObject tag = new TagObject(); + tag.setString("Name", mod.getName()); + tag.setDouble("Amount", mod.getAmount()); + tag.setBool("Multiply", mod.isMultiplied()); + tag.setLong("AttrId", mod.getID()); + return tag; + } - public static void setAttributeModifiers(AttributeMap map, List list) - { - for (int i = 0; i < list.size(); ++i) - { - TagObject nbttagcompound = list.get(i); - AttributeInstance iattributeinstance = map.getAttributeInstanceByName(nbttagcompound.getString("Name")); + public static void setAttributeModifiers(AttributeMap map, List mods) { + for(int i = 0; i < mods.size(); ++i) { + TagObject mod = mods.get(i); + AttributeInstance instance = map.getAttributeInstanceByName(mod.getString("Name")); - if (iattributeinstance != null) - { - applyModifiersToAttributeInstance(iattributeinstance, nbttagcompound); - } - else - { - Log.TICK.warn("Ignoriere unbekannte Attribute \'" + nbttagcompound.getString("Name") + "\'"); - } - } - } + if(instance != null) { + applyModifiersToAttributeInstance(instance, mod); + } + else { + Log.TICK.warn("Ignoriere unbekannte Attribute \'" + mod.getString("Name") + "\'"); + } + } + } - private static void applyModifiersToAttributeInstance(AttributeInstance instance, TagObject compound) - { - instance.setBaseValue(compound.getDouble("Base")); + private static void applyModifiersToAttributeInstance(AttributeInstance instance, TagObject tag) { + instance.setBaseValue(tag.getDouble("Base")); - if (compound.hasList("Modifiers")) - { - List nbttaglist = compound.getList("Modifiers"); + if(tag.hasList("Modifiers")) { + List mods = tag.getList("Modifiers"); - for (int i = 0; i < nbttaglist.size(); ++i) - { - AttributeModifier attributemodifier = readAttributeModifierFromNBT(nbttaglist.get(i)); + for(int i = 0; i < mods.size(); ++i) { + AttributeModifier mod = readAttributeModifierFromNBT(mods.get(i)); - if (attributemodifier != null) - { - AttributeModifier attributemodifier1 = instance.getModifier(attributemodifier.getID()); + if(mod != null) { + AttributeModifier old = instance.getModifier(mod.getID()); - if (attributemodifier1 != null) - { - instance.removeModifier(attributemodifier1); - } + if(old != null) { + instance.removeModifier(old); + } - instance.applyModifier(attributemodifier); - } - } - } - } + instance.applyModifier(mod); + } + } + } + } - /** - * Creates an AttributeModifier from an NBTTagCompound - */ - public static AttributeModifier readAttributeModifierFromNBT(TagObject compound) - { - long id = compound.getLong("AttrId"); - if(id == 0L) - return null; + public static AttributeModifier readAttributeModifierFromNBT(TagObject tag) { + long id = tag.getLong("AttrId"); + if(id == 0L) + return null; - try - { - return new AttributeModifier(id, compound.getString("Name"), compound.getDouble("Amount"), compound.getBool("Multiply")); - } - catch (Exception exception) - { - Log.TICK.warn("Konnte Attribute nicht erstellen: " + exception.getMessage()); - return null; - } - } + try { + return new AttributeModifier(id, tag.getString("Name"), tag.getDouble("Amount"), tag.getBool("Multiply")); + } + catch(Exception e) { + Log.TICK.warn("Konnte Attribute nicht erstellen: " + e.getMessage()); + return null; + } + } } diff --git a/common/src/main/java/common/block/tech/BlockChest.java b/common/src/main/java/common/block/tech/BlockChest.java index b4bcac3..8110fbb 100755 --- a/common/src/main/java/common/block/tech/BlockChest.java +++ b/common/src/main/java/common/block/tech/BlockChest.java @@ -21,7 +21,7 @@ import common.packet.SPacketSoundEffect; import common.properties.IProperty; import common.properties.PropertyDirection; import common.tileentity.ILockableContainer; -import common.tileentity.LockCode; +import common.tileentity.Passcode; import common.tileentity.TileEntity; import common.tileentity.TileEntityChest; import common.util.BlockPos; @@ -446,8 +446,8 @@ public class BlockChest extends BlockContainer ItemStack stack = Config.locking ? playerIn.getHeldItem() : null; if(stack != null && stack.getItem() == Items.key) { if(ilockablecontainer.isLocked()) { - if(stack.hasDisplayName() && stack.getDisplayName().equals(ilockablecontainer.getLockCode().getLock())) { - ilockablecontainer.setLockCode(LockCode.EMPTY_CODE); + if(stack.hasDisplayName() && stack.getDisplayName().equals(ilockablecontainer.getLockCode().code())) { + ilockablecontainer.setLockCode(Passcode.EMPTY_CODE); // playerIn.triggerAchievement(StatRegistry.chestUnlockedStat); playerIn.connection.addHotbar(TextColor.BLUE + "%s wurde entriegelt", ilockablecontainer.getCommandName()); playerIn.connection.sendPacket(new SPacketSoundEffect(SoundEvent.DOOR, playerIn.posX, playerIn.posY, playerIn.posZ, 1.0F)); @@ -455,7 +455,7 @@ public class BlockChest extends BlockContainer } } else if(stack.hasDisplayName()) { - ilockablecontainer.setLockCode(new LockCode(stack.getDisplayName())); + ilockablecontainer.setLockCode(new Passcode(stack.getDisplayName())); // playerIn.triggerAchievement(StatRegistry.chestLockedStat); playerIn.connection.addHotbar(TextColor.ORANGE + "%s wurde verriegelt", ilockablecontainer.getCommandName()); playerIn.connection.sendPacket(new SPacketSoundEffect(SoundEvent.DOOR, playerIn.posX, playerIn.posY, playerIn.posZ, 1.0F)); diff --git a/common/src/main/java/common/block/tech/BlockDispenser.java b/common/src/main/java/common/block/tech/BlockDispenser.java index 5f25e04..4421fbb 100755 --- a/common/src/main/java/common/block/tech/BlockDispenser.java +++ b/common/src/main/java/common/block/tech/BlockDispenser.java @@ -7,7 +7,8 @@ import common.dispenser.BehaviorDefaultDispenseItem; import common.dispenser.IBehaviorDispenseItem; import common.dispenser.IBlockSource; import common.dispenser.IPosition; -import common.dispenser.PositionImpl; +import common.dispenser.DispenserPos; +import common.dispenser.DispenserSource; import common.entity.npc.EntityNPC; import common.entity.types.EntityLiving; import common.init.DispenserRegistry; @@ -125,7 +126,7 @@ public class BlockDispenser extends BlockContainer protected void dispense(World worldIn, BlockPos pos) { - BlockSourceImpl blocksourceimpl = new BlockSourceImpl(worldIn, pos); + DispenserSource blocksourceimpl = new DispenserSource(worldIn, pos); TileEntityDispenser tileentitydispenser = (TileEntityDispenser)blocksourceimpl.getBlockTileEntity(); if (tileentitydispenser != null) @@ -239,7 +240,7 @@ public class BlockDispenser extends BlockContainer double d0 = coords.getX() + 0.7D * (double)enumfacing.getFrontOffsetX(); double d1 = coords.getY() + 0.7D * (double)enumfacing.getFrontOffsetY(); double d2 = coords.getZ() + 0.7D * (double)enumfacing.getFrontOffsetZ(); - return new PositionImpl(d0, d1, d2); + return new DispenserPos(d0, d1, d2); } /** diff --git a/common/src/main/java/common/block/tech/BlockDropper.java b/common/src/main/java/common/block/tech/BlockDropper.java index f6bf2d5..8d2f890 100755 --- a/common/src/main/java/common/block/tech/BlockDropper.java +++ b/common/src/main/java/common/block/tech/BlockDropper.java @@ -1,6 +1,7 @@ package common.block.tech; import common.dispenser.BehaviorDefaultDispenseItem; +import common.dispenser.DispenserSource; import common.dispenser.IBehaviorDispenseItem; import common.inventory.IInventory; import common.item.ItemStack; @@ -31,7 +32,7 @@ public class BlockDropper extends BlockDispenser protected void dispense(World worldIn, BlockPos pos) { - BlockSourceImpl blocksourceimpl = new BlockSourceImpl(worldIn, pos); + DispenserSource blocksourceimpl = new DispenserSource(worldIn, pos); TileEntityDispenser tileentitydispenser = (TileEntityDispenser)blocksourceimpl.getBlockTileEntity(); if (tileentitydispenser != null) diff --git a/common/src/main/java/common/block/tech/BlockSourceImpl.java b/common/src/main/java/common/block/tech/BlockSourceImpl.java deleted file mode 100755 index f22c91d..0000000 --- a/common/src/main/java/common/block/tech/BlockSourceImpl.java +++ /dev/null @@ -1,55 +0,0 @@ -package common.block.tech; - -import common.dispenser.IBlockSource; -import common.tileentity.TileEntity; -import common.util.BlockPos; -import common.world.State; -import common.world.World; - -public class BlockSourceImpl implements IBlockSource -{ - private final World worldObj; - private final BlockPos pos; - - public BlockSourceImpl(World worldIn, BlockPos posIn) - { - this.worldObj = worldIn; - this.pos = posIn; - } - - public World getWorld() - { - return this.worldObj; - } - - public double getX() - { - return (double)this.pos.getX() + 0.5D; - } - - public double getY() - { - return (double)this.pos.getY() + 0.5D; - } - - public double getZ() - { - return (double)this.pos.getZ() + 0.5D; - } - - public BlockPos getBlockPos() - { - return this.pos; - } - - public int getBlockMetadata() - { - State iblockstate = this.worldObj.getState(this.pos); - return iblockstate.getBlock().getMetaFromState(iblockstate); - } - - public T getBlockTileEntity() - { - return (T)this.worldObj.getTileEntity(this.pos); - } -} diff --git a/common/src/main/java/common/dimension/Dimension.java b/common/src/main/java/common/dimension/Dimension.java index 03c1c1a..85e02fe 100755 --- a/common/src/main/java/common/dimension/Dimension.java +++ b/common/src/main/java/common/dimension/Dimension.java @@ -1204,13 +1204,13 @@ public abstract class Dimension extends Nameable implements Comparable list = Lists.newArrayList(); for(Ore gen : this.ores) { TagObject ore = new TagObject(); - ore.setString("Block", BlockRegistry.toIdName(gen.state)); - ore.setBool("Distrib", gen.dist); - ore.setInt("Size", gen.size); - ore.setInt("Count", gen.count); - ore.setInt("Add", gen.more); - ore.setInt("MinC", gen.min); - ore.setInt("MaxS", gen.max); + ore.setString("Block", BlockRegistry.toIdName(gen.state())); + ore.setBool("Distrib", gen.dist()); + ore.setInt("Size", gen.size()); + ore.setInt("Count", gen.count()); + ore.setInt("Add", gen.more()); + ore.setInt("MinC", gen.min()); + ore.setInt("MaxS", gen.max()); list.add(ore); } tag.setList("Ores", list); @@ -1219,15 +1219,15 @@ public abstract class Dimension extends Nameable implements Comparable list = Lists.newArrayList(); for(Lake gen : this.lakes) { TagObject lake = new TagObject(); - lake.setString("Block", BlockRegistry.toIdName(gen.state)); - if(gen.filler != null) - lake.setString("Filler", BlockRegistry.toIdName(gen.filler)); - if(gen.top != null) - lake.setString("Top", BlockRegistry.toIdName(gen.top)); - lake.setBool("Ratiod", gen.ratiod); - lake.setInt("Chance", gen.chance); - lake.setInt("Min", gen.minHeight); - lake.setInt("Max", gen.maxHeight); + lake.setString("Block", BlockRegistry.toIdName(gen.state())); + if(gen.filler() != null) + lake.setString("Filler", BlockRegistry.toIdName(gen.filler())); + if(gen.top() != null) + lake.setString("Top", BlockRegistry.toIdName(gen.top())); + lake.setBool("Ratiod", gen.ratiod()); + lake.setInt("Chance", gen.chance()); + lake.setInt("Min", gen.minHeight()); + lake.setInt("Max", gen.maxHeight()); list.add(lake); } tag.setList("Lakes", list); @@ -1236,11 +1236,11 @@ public abstract class Dimension extends Nameable implements Comparable list = Lists.newArrayList(); for(Liquid gen : this.liquids) { TagObject liquid = new TagObject(); - liquid.setString("Block", BlockRegistry.toIdName(gen.state)); - liquid.setBool("Lower", gen.lower); - liquid.setInt("Chance", gen.chance); - liquid.setInt("Min", gen.minHeight); - liquid.setInt("Max", gen.maxHeight); + liquid.setString("Block", BlockRegistry.toIdName(gen.state())); + liquid.setBool("Lower", gen.lower()); + liquid.setInt("Chance", gen.chance()); + liquid.setInt("Min", gen.minHeight()); + liquid.setInt("Max", gen.maxHeight()); list.add(liquid); } tag.setList("Liquids", list); diff --git a/common/src/main/java/common/dimension/Lake.java b/common/src/main/java/common/dimension/Lake.java index 2b21b58..6b32f6b 100644 --- a/common/src/main/java/common/dimension/Lake.java +++ b/common/src/main/java/common/dimension/Lake.java @@ -2,22 +2,5 @@ package common.dimension; import common.world.State; -public class Lake { - public final State state; - public final State filler; - public final State top; - public final int chance; - public final int minHeight; - public final int maxHeight; - public final boolean ratiod; - - public Lake(State state, State filler, State top, int chance, int minHeight, int maxHeight, boolean ratiod) { - this.state = state; - this.filler = filler; - this.top = top; - this.chance = chance; - this.minHeight = minHeight; - this.maxHeight = maxHeight; - this.ratiod = ratiod; - } +public record Lake(State state, State filler, State top, int chance, int minHeight, int maxHeight, boolean ratiod) { } diff --git a/common/src/main/java/common/dimension/Liquid.java b/common/src/main/java/common/dimension/Liquid.java index b1643f3..191a84d 100644 --- a/common/src/main/java/common/dimension/Liquid.java +++ b/common/src/main/java/common/dimension/Liquid.java @@ -2,18 +2,5 @@ package common.dimension; import common.world.State; -public class Liquid { - public final State state; - public final int chance; - public final int minHeight; - public final int maxHeight; - public final boolean lower; - - public Liquid(State state, int chance, int minHeight, int maxHeight, boolean lower) { - this.state = state; - this.chance = chance; - this.minHeight = minHeight; - this.maxHeight = maxHeight; - this.lower = lower; - } +public record Liquid(State state, int chance, int minHeight, int maxHeight, boolean lower) { } diff --git a/common/src/main/java/common/dimension/Ore.java b/common/src/main/java/common/dimension/Ore.java index 5171c68..6bbdb93 100644 --- a/common/src/main/java/common/dimension/Ore.java +++ b/common/src/main/java/common/dimension/Ore.java @@ -2,22 +2,5 @@ package common.dimension; import common.world.State; -public class Ore { - public final State state; - public final int count; - public final int more; - public final int size; - public final int min; - public final int max; - public final boolean dist; - - public Ore(State state, int count, int more, int size, int min, int max, boolean dist) { - this.state = state; - this.count = count; - this.more = more; - this.size = size; - this.min = min; - this.max = max; - this.dist = dist; - } +public record Ore(State state, int count, int more, int size, int min, int max, boolean dist) { } diff --git a/common/src/main/java/common/dispenser/DispenserPos.java b/common/src/main/java/common/dispenser/DispenserPos.java new file mode 100755 index 0000000..d3e5f5f --- /dev/null +++ b/common/src/main/java/common/dispenser/DispenserPos.java @@ -0,0 +1,4 @@ +package common.dispenser; + +public record DispenserPos(double getX, double getY, double getZ) implements IPosition { +} diff --git a/common/src/main/java/common/dispenser/DispenserSource.java b/common/src/main/java/common/dispenser/DispenserSource.java new file mode 100755 index 0000000..2709dba --- /dev/null +++ b/common/src/main/java/common/dispenser/DispenserSource.java @@ -0,0 +1,29 @@ +package common.dispenser; + +import common.tileentity.TileEntity; +import common.util.BlockPos; +import common.world.State; +import common.world.World; + +public record DispenserSource(World getWorld, BlockPos getBlockPos) implements IBlockSource { + public double getX() { + return (double)this.getBlockPos.getX() + 0.5D; + } + + public double getY() { + return (double)this.getBlockPos.getY() + 0.5D; + } + + public double getZ() { + return (double)this.getBlockPos.getZ() + 0.5D; + } + + public int getBlockMetadata() { + State state = this.getWorld.getState(this.getBlockPos); + return state.getBlock().getMetaFromState(state); + } + + public T getBlockTileEntity() { + return (T)this.getWorld.getTileEntity(this.getBlockPos); + } +} diff --git a/common/src/main/java/common/dispenser/IBlockSource.java b/common/src/main/java/common/dispenser/IBlockSource.java index c56f8c3..21cb62e 100755 --- a/common/src/main/java/common/dispenser/IBlockSource.java +++ b/common/src/main/java/common/dispenser/IBlockSource.java @@ -2,14 +2,17 @@ package common.dispenser; import common.tileentity.TileEntity; import common.util.BlockPos; +import common.world.World; -public interface IBlockSource extends ILocatableSource +public interface IBlockSource extends IPosition { double getX(); double getY(); double getZ(); + + World getWorld(); BlockPos getBlockPos(); diff --git a/common/src/main/java/common/dispenser/ILocatableSource.java b/common/src/main/java/common/dispenser/ILocatableSource.java deleted file mode 100755 index b0875cb..0000000 --- a/common/src/main/java/common/dispenser/ILocatableSource.java +++ /dev/null @@ -1,5 +0,0 @@ -package common.dispenser; - -public interface ILocatableSource extends ILocation -{ -} diff --git a/common/src/main/java/common/dispenser/ILocation.java b/common/src/main/java/common/dispenser/ILocation.java deleted file mode 100755 index e4eb4ae..0000000 --- a/common/src/main/java/common/dispenser/ILocation.java +++ /dev/null @@ -1,8 +0,0 @@ -package common.dispenser; - -import common.world.World; - -public interface ILocation extends IPosition -{ - World getWorld(); -} diff --git a/common/src/main/java/common/dispenser/PositionImpl.java b/common/src/main/java/common/dispenser/PositionImpl.java deleted file mode 100755 index 9150126..0000000 --- a/common/src/main/java/common/dispenser/PositionImpl.java +++ /dev/null @@ -1,30 +0,0 @@ -package common.dispenser; - -public class PositionImpl implements IPosition -{ - protected final double x; - protected final double y; - protected final double z; - - public PositionImpl(double xCoord, double yCoord, double zCoord) - { - this.x = xCoord; - this.y = yCoord; - this.z = zCoord; - } - - public double getX() - { - return this.x; - } - - public double getY() - { - return this.y; - } - - public double getZ() - { - return this.z; - } -} diff --git a/common/src/main/java/common/entity/Entity.java b/common/src/main/java/common/entity/Entity.java index 64e5b4e..4002d7a 100755 --- a/common/src/main/java/common/entity/Entity.java +++ b/common/src/main/java/common/entity/Entity.java @@ -1826,7 +1826,7 @@ public abstract class Entity // } public final void teleport(Position pos) { - this.teleport(pos.x, pos.y, pos.z, pos.yaw, pos.pitch, pos.dim); + this.teleport(pos.x(), pos.y(), pos.z(), pos.yaw(), pos.pitch(), pos.dim()); } public final void teleport(BlockPos pos, int dim) { diff --git a/common/src/main/java/common/entity/animal/EntityChicken.java b/common/src/main/java/common/entity/animal/EntityChicken.java index ee1ada9..a606c94 100755 --- a/common/src/main/java/common/entity/animal/EntityChicken.java +++ b/common/src/main/java/common/entity/animal/EntityChicken.java @@ -8,7 +8,7 @@ import common.ai.EntityAISwimming; import common.ai.EntityAITempt; import common.ai.EntityAIWander; import common.ai.EntityAIWatchClosest; -import common.attributes.Attributes; +import common.attributes.Attribute; import common.entity.npc.EntityNPC; import common.entity.types.EntityAnimal; import common.entity.types.EntityLiving; @@ -57,7 +57,7 @@ public class EntityChicken extends EntityAnimal { super.applyEntityAttributes(); this.setMaxHealth(4); - this.getEntityAttribute(Attributes.MOVEMENT_SPEED).setBaseValue(0.25D); + this.getEntityAttribute(Attribute.MOVEMENT_SPEED).setBaseValue(0.25D); } /** diff --git a/common/src/main/java/common/entity/animal/EntityCow.java b/common/src/main/java/common/entity/animal/EntityCow.java index b649434..da35c3a 100755 --- a/common/src/main/java/common/entity/animal/EntityCow.java +++ b/common/src/main/java/common/entity/animal/EntityCow.java @@ -8,7 +8,7 @@ import common.ai.EntityAISwimming; import common.ai.EntityAITempt; import common.ai.EntityAIWander; import common.ai.EntityAIWatchClosest; -import common.attributes.Attributes; +import common.attributes.Attribute; import common.entity.npc.EntityNPC; import common.entity.types.EntityAnimal; import common.entity.types.EntityLiving; @@ -40,7 +40,7 @@ public class EntityCow extends EntityAnimal { super.applyEntityAttributes(); this.setMaxHealth(10); - this.getEntityAttribute(Attributes.MOVEMENT_SPEED).setBaseValue(0.20000000298023224D); + this.getEntityAttribute(Attribute.MOVEMENT_SPEED).setBaseValue(0.20000000298023224D); } /** diff --git a/common/src/main/java/common/entity/animal/EntityHorse.java b/common/src/main/java/common/entity/animal/EntityHorse.java index 5ba138a..b34c369 100755 --- a/common/src/main/java/common/entity/animal/EntityHorse.java +++ b/common/src/main/java/common/entity/animal/EntityHorse.java @@ -10,8 +10,8 @@ import common.ai.EntityAIRunAroundLikeCrazy; import common.ai.EntityAISwimming; import common.ai.EntityAIWander; import common.ai.EntityAIWatchClosest; +import common.attributes.Attribute; import common.attributes.AttributeInstance; -import common.attributes.Attributes; import common.block.Block; import common.block.SoundType; import common.collect.Lists; @@ -553,7 +553,7 @@ public class EntityHorse extends EntityAnimal implements IInvBasic public double getHorseJumpStrength() { - return this.getEntityAttribute(Attributes.HORSE_JUMP_STRENGTH).getAttributeValue(); + return this.getEntityAttribute(Attribute.HORSE_JUMP_STRENGTH).getAttributeValue(); } /** @@ -663,9 +663,9 @@ public class EntityHorse extends EntityAnimal implements IInvBasic protected void applyEntityAttributes() { super.applyEntityAttributes(); - this.getAttributeMap().registerAttribute(Attributes.HORSE_JUMP_STRENGTH); + this.getAttributeMap().registerAttribute(Attribute.HORSE_JUMP_STRENGTH); this.setMaxHealth(53); - this.getEntityAttribute(Attributes.MOVEMENT_SPEED).setBaseValue(0.22499999403953552D); + this.getEntityAttribute(Attribute.MOVEMENT_SPEED).setBaseValue(0.22499999403953552D); } /** @@ -1354,7 +1354,7 @@ public class EntityHorse extends EntityAnimal implements IInvBasic if (!this.worldObj.client) { - this.setAIMoveSpeed((float)this.getEntityAttribute(Attributes.MOVEMENT_SPEED).getAttributeValue()); + this.setAIMoveSpeed((float)this.getEntityAttribute(Attribute.MOVEMENT_SPEED).getAttributeValue()); super.moveEntityWithHeading(strafe, forward); } @@ -1462,7 +1462,7 @@ public class EntityHorse extends EntityAnimal implements IInvBasic if (iattributeinstance != null) { - this.getEntityAttribute(Attributes.MOVEMENT_SPEED).setBaseValue(iattributeinstance.getBaseValue() * 0.25D); + this.getEntityAttribute(Attribute.MOVEMENT_SPEED).setBaseValue(iattributeinstance.getBaseValue() * 0.25D); } if (this.isChested()) @@ -1595,10 +1595,10 @@ public class EntityHorse extends EntityAnimal implements IInvBasic entityhorse1.setHorseType(k); int d1 = this.getRawMaxHealth() + ageable.getRawMaxHealth() + this.getModifiedMaxHealth(); entityhorse1.setMaxHealth(d1 / 3); - double d2 = this.getEntityAttribute(Attributes.HORSE_JUMP_STRENGTH).getBaseValue() + ageable.getEntityAttribute(Attributes.HORSE_JUMP_STRENGTH).getBaseValue() + this.getModifiedJumpStrength(); - entityhorse1.getEntityAttribute(Attributes.HORSE_JUMP_STRENGTH).setBaseValue(d2 / 3.0D); - double d0 = this.getEntityAttribute(Attributes.MOVEMENT_SPEED).getBaseValue() + ageable.getEntityAttribute(Attributes.MOVEMENT_SPEED).getBaseValue() + this.getModifiedMovementSpeed(); - entityhorse1.getEntityAttribute(Attributes.MOVEMENT_SPEED).setBaseValue(d0 / 3.0D); + double d2 = this.getEntityAttribute(Attribute.HORSE_JUMP_STRENGTH).getBaseValue() + ageable.getEntityAttribute(Attribute.HORSE_JUMP_STRENGTH).getBaseValue() + this.getModifiedJumpStrength(); + entityhorse1.getEntityAttribute(Attribute.HORSE_JUMP_STRENGTH).setBaseValue(d2 / 3.0D); + double d0 = this.getEntityAttribute(Attribute.MOVEMENT_SPEED).getBaseValue() + ageable.getEntityAttribute(Attribute.MOVEMENT_SPEED).getBaseValue() + this.getModifiedMovementSpeed(); + entityhorse1.getEntityAttribute(Attribute.MOVEMENT_SPEED).setBaseValue(d0 / 3.0D); return entityhorse1; } @@ -1648,26 +1648,26 @@ public class EntityHorse extends EntityAnimal implements IInvBasic if (i == 0) { - this.getEntityAttribute(Attributes.MOVEMENT_SPEED).setBaseValue(this.getModifiedMovementSpeed()); + this.getEntityAttribute(Attribute.MOVEMENT_SPEED).setBaseValue(this.getModifiedMovementSpeed()); } else { - this.getEntityAttribute(Attributes.MOVEMENT_SPEED).setBaseValue(0.17499999701976776D); + this.getEntityAttribute(Attribute.MOVEMENT_SPEED).setBaseValue(0.17499999701976776D); } } else { this.setMaxHealth(15); - this.getEntityAttribute(Attributes.MOVEMENT_SPEED).setBaseValue(0.20000000298023224D); + this.getEntityAttribute(Attribute.MOVEMENT_SPEED).setBaseValue(0.20000000298023224D); } if (i != 2 && i != 1) { - this.getEntityAttribute(Attributes.HORSE_JUMP_STRENGTH).setBaseValue(this.getModifiedJumpStrength()); + this.getEntityAttribute(Attribute.HORSE_JUMP_STRENGTH).setBaseValue(this.getModifiedJumpStrength()); } else { - this.getEntityAttribute(Attributes.HORSE_JUMP_STRENGTH).setBaseValue(0.5D); + this.getEntityAttribute(Attribute.HORSE_JUMP_STRENGTH).setBaseValue(0.5D); } this.setHealth(this.getMaxHealth()); diff --git a/common/src/main/java/common/entity/animal/EntityMouse.java b/common/src/main/java/common/entity/animal/EntityMouse.java index e304a0f..2c42bf3 100755 --- a/common/src/main/java/common/entity/animal/EntityMouse.java +++ b/common/src/main/java/common/entity/animal/EntityMouse.java @@ -10,6 +10,7 @@ import common.ai.EntityAISwimming; import common.ai.EntityAITempt; import common.ai.EntityAIWander; import common.ai.EntityAIWatchClosest; +import common.attributes.Attribute; import common.attributes.AttributeInstance; import common.attributes.Attributes; import common.block.Block; @@ -46,7 +47,7 @@ public class EntityMouse extends EntityAnimal { protected void applyEntityAttributes() { super.applyEntityAttributes(); this.setMaxHealth(1); - this.getEntityAttribute(Attributes.MOVEMENT_SPEED).setBaseValue(0.25D); + this.getEntityAttribute(Attribute.MOVEMENT_SPEED).setBaseValue(0.25D); } // protected String getLivingSound() { @@ -119,7 +120,7 @@ public class EntityMouse extends EntityAnimal { public void setCustomNameTag(String name) { super.setCustomNameTag(name); if(this.worldObj != null && !this.worldObj.client) { - AttributeInstance speed = this.getEntityAttribute(Attributes.MOVEMENT_SPEED); + AttributeInstance speed = this.getEntityAttribute(Attribute.MOVEMENT_SPEED); speed.removeModifier(Attributes.MOUSE_SPEEDY_MOD); if(name.equals("Gonzales") || name.equals("Gonzalez")) speed.applyModifier(Attributes.MOUSE_SPEEDY_MOD); diff --git a/common/src/main/java/common/entity/animal/EntityOcelot.java b/common/src/main/java/common/entity/animal/EntityOcelot.java index de02698..19d2f3e 100755 --- a/common/src/main/java/common/entity/animal/EntityOcelot.java +++ b/common/src/main/java/common/entity/animal/EntityOcelot.java @@ -13,7 +13,7 @@ import common.ai.EntityAITargetNonTamed; import common.ai.EntityAITempt; import common.ai.EntityAIWander; import common.ai.EntityAIWatchClosest; -import common.attributes.Attributes; +import common.attributes.Attribute; import common.entity.DamageSource; import common.entity.Entity; import common.entity.npc.Alignment; @@ -113,7 +113,7 @@ public class EntityOcelot extends EntityTameable { super.applyEntityAttributes(); this.setMaxHealth(10); - this.getEntityAttribute(Attributes.MOVEMENT_SPEED).setBaseValue(0.30000001192092896D); + this.getEntityAttribute(Attribute.MOVEMENT_SPEED).setBaseValue(0.30000001192092896D); } public void fall(float distance, float damageMultiplier) diff --git a/common/src/main/java/common/entity/animal/EntityPig.java b/common/src/main/java/common/entity/animal/EntityPig.java index 17edb16..1346e49 100755 --- a/common/src/main/java/common/entity/animal/EntityPig.java +++ b/common/src/main/java/common/entity/animal/EntityPig.java @@ -9,7 +9,7 @@ import common.ai.EntityAISwimming; import common.ai.EntityAITempt; import common.ai.EntityAIWander; import common.ai.EntityAIWatchClosest; -import common.attributes.Attributes; +import common.attributes.Attribute; import common.entity.npc.EntityNPC; import common.entity.types.EntityAnimal; import common.entity.types.EntityLiving; @@ -47,7 +47,7 @@ public class EntityPig extends EntityAnimal { super.applyEntityAttributes(); this.setMaxHealth(10); - this.getEntityAttribute(Attributes.MOVEMENT_SPEED).setBaseValue(0.25D); + this.getEntityAttribute(Attribute.MOVEMENT_SPEED).setBaseValue(0.25D); } /** diff --git a/common/src/main/java/common/entity/animal/EntityRabbit.java b/common/src/main/java/common/entity/animal/EntityRabbit.java index 61c9319..0e548f7 100755 --- a/common/src/main/java/common/entity/animal/EntityRabbit.java +++ b/common/src/main/java/common/entity/animal/EntityRabbit.java @@ -15,7 +15,7 @@ import common.ai.EntityAIWander; import common.ai.EntityAIWatchClosest; import common.ai.EntityJumpHelper; import common.ai.EntityMoveHelper; -import common.attributes.Attributes; +import common.attributes.Attribute; import common.block.Block; import common.block.foliage.BlockTallGrass; import common.entity.DamageSource; @@ -195,7 +195,7 @@ public class EntityRabbit extends EntityAnimal { protected void applyEntityAttributes() { super.applyEntityAttributes(); this.setMaxHealth(5); - this.getEntityAttribute(Attributes.MOVEMENT_SPEED).setBaseValue(0.30000001192092896D); + this.getEntityAttribute(Attribute.MOVEMENT_SPEED).setBaseValue(0.30000001192092896D); } public void writeEntity(TagObject tagCompound) { diff --git a/common/src/main/java/common/entity/animal/EntitySheep.java b/common/src/main/java/common/entity/animal/EntitySheep.java index 2966c1b..054137a 100755 --- a/common/src/main/java/common/entity/animal/EntitySheep.java +++ b/common/src/main/java/common/entity/animal/EntitySheep.java @@ -11,7 +11,7 @@ import common.ai.EntityAISwimming; import common.ai.EntityAITempt; import common.ai.EntityAIWander; import common.ai.EntityAIWatchClosest; -import common.attributes.Attributes; +import common.attributes.Attribute; import common.biome.Biome; import common.collect.Maps; import common.color.DyeColor; @@ -104,7 +104,7 @@ public class EntitySheep extends EntityAnimal { super.applyEntityAttributes(); this.setMaxHealth(8); - this.getEntityAttribute(Attributes.MOVEMENT_SPEED).setBaseValue(0.23000000417232513D); + this.getEntityAttribute(Attribute.MOVEMENT_SPEED).setBaseValue(0.23000000417232513D); } protected void entityInit() diff --git a/common/src/main/java/common/entity/animal/EntityWolf.java b/common/src/main/java/common/entity/animal/EntityWolf.java index af2159d..2be9280 100755 --- a/common/src/main/java/common/entity/animal/EntityWolf.java +++ b/common/src/main/java/common/entity/animal/EntityWolf.java @@ -15,7 +15,7 @@ import common.ai.EntityAISwimming; import common.ai.EntityAITargetNonTamed; import common.ai.EntityAIWander; import common.ai.EntityAIWatchClosest; -import common.attributes.Attributes; +import common.attributes.Attribute; import common.color.DyeColor; import common.entity.DamageSource; import common.entity.Entity; @@ -86,7 +86,7 @@ public class EntityWolf extends EntityTameable protected void applyEntityAttributes() { super.applyEntityAttributes(); - this.getEntityAttribute(Attributes.MOVEMENT_SPEED).setBaseValue(0.30000001192092896D); + this.getEntityAttribute(Attribute.MOVEMENT_SPEED).setBaseValue(0.30000001192092896D); if (this.isTamed()) { @@ -97,8 +97,8 @@ public class EntityWolf extends EntityTameable this.setMaxHealth(8); } - this.getAttributeMap().registerAttribute(Attributes.ATTACK_DAMAGE); - this.getEntityAttribute(Attributes.ATTACK_DAMAGE).setBaseValue(2.0D); + this.getAttributeMap().registerAttribute(Attribute.ATTACK_DAMAGE); + this.getEntityAttribute(Attribute.ATTACK_DAMAGE).setBaseValue(2.0D); } /** @@ -350,7 +350,7 @@ public class EntityWolf extends EntityTameable { if(!this.worldObj.client && !Config.damageMobs) return false; - boolean flag = entityIn.attackEntityFrom(DamageSource.causeMobDamage(this), ((int)this.getEntityAttribute(Attributes.ATTACK_DAMAGE).getAttributeValue())); + boolean flag = entityIn.attackEntityFrom(DamageSource.causeMobDamage(this), ((int)this.getEntityAttribute(Attribute.ATTACK_DAMAGE).getAttributeValue())); if (flag) { @@ -373,7 +373,7 @@ public class EntityWolf extends EntityTameable this.setMaxHealth(8); } - this.getEntityAttribute(Attributes.ATTACK_DAMAGE).setBaseValue(4.0D); + this.getEntityAttribute(Attribute.ATTACK_DAMAGE).setBaseValue(4.0D); } /** diff --git a/common/src/main/java/common/entity/item/EntityCartContainer.java b/common/src/main/java/common/entity/item/EntityCartContainer.java index e6f9629..7a778f8 100755 --- a/common/src/main/java/common/entity/item/EntityCartContainer.java +++ b/common/src/main/java/common/entity/item/EntityCartContainer.java @@ -11,7 +11,7 @@ import common.item.ItemStack; import common.tags.TagObject; import java.util.List; import common.tileentity.ILockableContainer; -import common.tileentity.LockCode; +import common.tileentity.Passcode; import common.util.BlockPos; import common.util.PortalType; import common.world.World; @@ -269,13 +269,13 @@ public abstract class EntityCartContainer extends EntityCart implements ILockabl return false; } - public void setLockCode(LockCode code) + public void setLockCode(Passcode code) { } - public LockCode getLockCode() + public Passcode getLockCode() { - return LockCode.EMPTY_CODE; + return Passcode.EMPTY_CODE; } public void clear() diff --git a/common/src/main/java/common/entity/npc/ClassInfo.java b/common/src/main/java/common/entity/npc/ClassInfo.java deleted file mode 100755 index e4561a0..0000000 --- a/common/src/main/java/common/entity/npc/ClassInfo.java +++ /dev/null @@ -1,9 +0,0 @@ -package common.entity.npc; - -public class ClassInfo { - public final Enum type; - - public ClassInfo(Enum type) { - this.type = type; - } -} diff --git a/common/src/main/java/common/entity/npc/EntityChaosMarine.java b/common/src/main/java/common/entity/npc/EntityChaosMarine.java index 13790fa..d8424a1 100755 --- a/common/src/main/java/common/entity/npc/EntityChaosMarine.java +++ b/common/src/main/java/common/entity/npc/EntityChaosMarine.java @@ -2,7 +2,7 @@ package common.entity.npc; import java.util.List; -import common.attributes.Attributes; +import common.attributes.Attribute; import common.collect.Lists; import common.init.Items; import common.init.SpeciesRegistry; @@ -118,7 +118,7 @@ public class EntityChaosMarine extends EntityNPC { protected void applyEntityAttributes() { super.applyEntityAttributes(); - this.getEntityAttribute(Attributes.ATTACK_DAMAGE).setBaseValue(12.0D); + this.getEntityAttribute(Attribute.ATTACK_DAMAGE).setBaseValue(12.0D); } protected ItemStack pickItem() { diff --git a/common/src/main/java/common/entity/npc/EntityFlyingNPC.java b/common/src/main/java/common/entity/npc/EntityFlyingNPC.java index 01d180b..8692eb1 100755 --- a/common/src/main/java/common/entity/npc/EntityFlyingNPC.java +++ b/common/src/main/java/common/entity/npc/EntityFlyingNPC.java @@ -2,7 +2,7 @@ package common.entity.npc; import common.ai.EntityAIBase; import common.ai.EntityMoveHelper; -import common.attributes.Attributes; +import common.attributes.Attribute; import common.block.Block; import common.entity.types.EntityLiving; import common.potion.Potion; @@ -25,7 +25,7 @@ public abstract class EntityFlyingNPC extends EntityNPC protected void applyEntityAttributes() { super.applyEntityAttributes(); - this.getEntityAttribute(Attributes.FOLLOW_RANGE).setBaseValue(48.0D); + this.getEntityAttribute(Attribute.FOLLOW_RANGE).setBaseValue(48.0D); } public float getArmRotation() { diff --git a/common/src/main/java/common/entity/npc/EntityGargoyle.java b/common/src/main/java/common/entity/npc/EntityGargoyle.java index 2c3c874..80c117e 100755 --- a/common/src/main/java/common/entity/npc/EntityGargoyle.java +++ b/common/src/main/java/common/entity/npc/EntityGargoyle.java @@ -1,7 +1,7 @@ package common.entity.npc; import common.ai.AIFlyingBoxAttack; -import common.attributes.Attributes; +import common.attributes.Attribute; import common.entity.DamageSource; import common.init.Config; import common.item.ItemStack; @@ -165,8 +165,8 @@ public class EntityGargoyle extends EntityFlyingNPC protected void applyEntityAttributes() { super.applyEntityAttributes(); - this.getEntityAttribute(Attributes.MOVEMENT_SPEED).setBaseValue(0.6000000238418579D); - this.getEntityAttribute(Attributes.FOLLOW_RANGE).setBaseValue(40.0D); + this.getEntityAttribute(Attribute.MOVEMENT_SPEED).setBaseValue(0.6000000238418579D); + this.getEntityAttribute(Attribute.FOLLOW_RANGE).setBaseValue(40.0D); } public int getInvulTime() diff --git a/common/src/main/java/common/entity/npc/EntityGoblin.java b/common/src/main/java/common/entity/npc/EntityGoblin.java index b80ef9a..e32df99 100755 --- a/common/src/main/java/common/entity/npc/EntityGoblin.java +++ b/common/src/main/java/common/entity/npc/EntityGoblin.java @@ -1,6 +1,6 @@ package common.entity.npc; -import common.attributes.Attributes; +import common.attributes.Attribute; import common.entity.types.EntityLiving; import common.rng.Random; import common.world.World; @@ -44,7 +44,7 @@ public class EntityGoblin extends EntityNPC { protected void applyEntityAttributes() { super.applyEntityAttributes(); - this.getEntityAttribute(Attributes.ATTACK_DAMAGE).setBaseValue(1.0D); + this.getEntityAttribute(Attribute.ATTACK_DAMAGE).setBaseValue(1.0D); } public boolean canAmbush(EntityLiving entity) { diff --git a/common/src/main/java/common/entity/npc/EntityHaunter.java b/common/src/main/java/common/entity/npc/EntityHaunter.java index ec73db7..ae58c00 100755 --- a/common/src/main/java/common/entity/npc/EntityHaunter.java +++ b/common/src/main/java/common/entity/npc/EntityHaunter.java @@ -1,7 +1,7 @@ package common.entity.npc; import common.ai.EntityAIExplode; -import common.attributes.Attributes; +import common.attributes.Attribute; import common.entity.Entity; import common.entity.effect.EntityLightning; import common.entity.types.EntityLiving; @@ -28,7 +28,7 @@ public class EntityHaunter extends EntityNPC { protected void applyEntityAttributes() { super.applyEntityAttributes(); - this.getEntityAttribute(Attributes.MOVEMENT_SPEED).setBaseValue(0.25D); + this.getEntityAttribute(Attribute.MOVEMENT_SPEED).setBaseValue(0.25D); } public int getMaxFallHeight() diff --git a/common/src/main/java/common/entity/npc/EntityHoveringNPC.java b/common/src/main/java/common/entity/npc/EntityHoveringNPC.java index 4781923..e021466 100755 --- a/common/src/main/java/common/entity/npc/EntityHoveringNPC.java +++ b/common/src/main/java/common/entity/npc/EntityHoveringNPC.java @@ -1,6 +1,6 @@ package common.entity.npc; -import common.attributes.Attributes; +import common.attributes.Attribute; import common.entity.types.EntityLiving; import common.packet.CPacketAction; import common.world.World; @@ -34,7 +34,7 @@ public abstract class EntityHoveringNPC extends EntityNPC protected void applyEntityAttributes() { super.applyEntityAttributes(); - this.getEntityAttribute(Attributes.FOLLOW_RANGE).setBaseValue(32.0D); + this.getEntityAttribute(Attribute.FOLLOW_RANGE).setBaseValue(32.0D); } public boolean isSneakingVisually() { diff --git a/common/src/main/java/common/entity/npc/EntityMage.java b/common/src/main/java/common/entity/npc/EntityMage.java index 4abe982..ecedfe9 100755 --- a/common/src/main/java/common/entity/npc/EntityMage.java +++ b/common/src/main/java/common/entity/npc/EntityMage.java @@ -2,6 +2,7 @@ package common.entity.npc; import java.util.List; +import common.attributes.Attribute; import common.attributes.AttributeInstance; import common.attributes.Attributes; import common.entity.effect.EntityLightning; @@ -52,7 +53,7 @@ public class EntityMage extends EntityNPC } } - this.getEntityAttribute(Attributes.MOVEMENT_SPEED).removeModifier(Attributes.MAGE_POTSPEED_MOD); + this.getEntityAttribute(Attribute.MOVEMENT_SPEED).removeModifier(Attributes.MAGE_POTSPEED_MOD); } } else @@ -86,7 +87,7 @@ public class EntityMage extends EntityNPC this.setItem(0, new ItemStack(Items.potion, 1, i)); this.attackTimer = this.getHeldItem().getMaxItemUseDuration(); this.drinking = true; - AttributeInstance iattributeinstance = this.getEntityAttribute(Attributes.MOVEMENT_SPEED); + AttributeInstance iattributeinstance = this.getEntityAttribute(Attribute.MOVEMENT_SPEED); iattributeinstance.removeModifier(Attributes.MAGE_POTSPEED_MOD); iattributeinstance.applyModifier(Attributes.MAGE_POTSPEED_MOD); } diff --git a/common/src/main/java/common/entity/npc/EntityMobNPC.java b/common/src/main/java/common/entity/npc/EntityMobNPC.java index e1a5706..6f5d6aa 100755 --- a/common/src/main/java/common/entity/npc/EntityMobNPC.java +++ b/common/src/main/java/common/entity/npc/EntityMobNPC.java @@ -1,6 +1,7 @@ package common.entity.npc; import common.ai.EntityAIHurtByTarget; +import common.attributes.Attribute; import common.attributes.AttributeInstance; import common.attributes.Attributes; import common.entity.DamageSource; @@ -62,7 +63,7 @@ public abstract class EntityMobNPC extends EntityNPC protected void updateAITasks() { - AttributeInstance iattributeinstance = this.getEntityAttribute(Attributes.MOVEMENT_SPEED); + AttributeInstance iattributeinstance = this.getEntityAttribute(Attribute.MOVEMENT_SPEED); if (this.isAngry()) { diff --git a/common/src/main/java/common/entity/npc/EntityNPC.java b/common/src/main/java/common/entity/npc/EntityNPC.java index d0ab4de..b4ab6b3 100755 --- a/common/src/main/java/common/entity/npc/EntityNPC.java +++ b/common/src/main/java/common/entity/npc/EntityNPC.java @@ -19,8 +19,8 @@ import common.ai.EntityAISwimming; import common.ai.EntityAIWander; import common.ai.EntityAIWatchClosest; import common.ai.EntityAIWatchClosest2; +import common.attributes.Attribute; import common.attributes.AttributeInstance; -import common.attributes.Attributes; import common.block.Block; import common.block.artificial.BlockBed; import common.collect.Lists; @@ -86,7 +86,7 @@ import common.rng.Random; import common.sound.MovingSoundMinecartRiding; import common.tags.TagObject; import common.tileentity.IInteractionObject; -import common.tileentity.LockCode; +import common.tileentity.Passcode; import common.tileentity.TileEntitySign; import common.util.BlockPos; import common.util.BoundingBox; @@ -385,7 +385,7 @@ public abstract class EntityNPC extends EntityLiving this.fireResistance = 20; this.noPickup = true; // this.getEntityAttribute(Attributes.ATTACK_DAMAGE).setBaseValue(1.0D); - this.getEntityAttribute(Attributes.MOVEMENT_SPEED).setBaseValue(this.getEntityAttribute(Attributes.MOVEMENT_SPEED).getBaseValue() / 3.0); // 0.10000000149011612D); + this.getEntityAttribute(Attribute.MOVEMENT_SPEED).setBaseValue(this.getEntityAttribute(Attribute.MOVEMENT_SPEED).getBaseValue() / 3.0); // 0.10000000149011612D); } public final void setServerPlayer(IPlayer connection) { @@ -545,12 +545,12 @@ public abstract class EntityNPC extends EntityLiving protected void applyEntityAttributes() { super.applyEntityAttributes(); - this.getEntityAttribute(Attributes.FOLLOW_RANGE).setBaseValue(20.0D); - this.getAttributeMap().registerAttribute(Attributes.ATTACK_DAMAGE).setBaseValue(2.0D); - this.getEntityAttribute(Attributes.MOVEMENT_SPEED).setBaseValue(0.3D); + this.getEntityAttribute(Attribute.FOLLOW_RANGE).setBaseValue(20.0D); + this.getAttributeMap().registerAttribute(Attribute.ATTACK_DAMAGE).setBaseValue(2.0D); + this.getEntityAttribute(Attribute.MOVEMENT_SPEED).setBaseValue(0.3D); this.setMaxHealth(this.getBaseHealth(this.rand)); - this.getAttributeMap().registerAttribute(Attributes.MANA_CAPACITY); - this.getEntityAttribute(Attributes.MANA_CAPACITY).setBaseValue(20.0D); + this.getAttributeMap().registerAttribute(Attribute.MANA_CAPACITY); + this.getEntityAttribute(Attribute.MANA_CAPACITY).setBaseValue(20.0D); } // protected int getExperiencePoints(EntityNPC player) @@ -682,7 +682,7 @@ public abstract class EntityNPC extends EntityLiving { if(!this.worldObj.client && !Config.damageMobs) return false; - int f = (int)this.getEntityAttribute(Attributes.ATTACK_DAMAGE).getAttributeValue(); + int f = (int)this.getEntityAttribute(Attribute.ATTACK_DAMAGE).getAttributeValue(); int i = 0; if (entityIn instanceof EntityLiving) @@ -1187,7 +1187,7 @@ public abstract class EntityNPC extends EntityLiving // } public int getMaxMana() { - return (int)this.getEntityAttribute(Attributes.MANA_CAPACITY).getAttributeValue(); + return (int)this.getEntityAttribute(Attribute.MANA_CAPACITY).getAttributeValue(); } public MerchantRecipeList getTrades(EntityNPC player) { @@ -2553,7 +2553,7 @@ public abstract class EntityNPC extends EntityLiving this.prevCameraYaw = this.cameraYaw; // super.onLivingUpdate(); this.onNpcUpdate(); - AttributeInstance iattributeinstance = this.getEntityAttribute(Attributes.MOVEMENT_SPEED); + AttributeInstance iattributeinstance = this.getEntityAttribute(Attribute.MOVEMENT_SPEED); this.jumpMovement = this.speedInAir; @@ -3748,7 +3748,7 @@ public abstract class EntityNPC extends EntityLiving { if (!targetEntity.hitByEntity(this)) { - int f = (int)this.getEntityAttribute(Attributes.ATTACK_DAMAGE).getAttributeValue(); + int f = (int)this.getEntityAttribute(Attribute.ATTACK_DAMAGE).getAttributeValue(); int i = 0; int f1 = // 0; @@ -3978,7 +3978,7 @@ public abstract class EntityNPC extends EntityLiving */ public float getAIMoveSpeed() { - return this.isPlayer() ? (float)this.getEntityAttribute(Attributes.MOVEMENT_SPEED).getAttributeValue() : super.getAIMoveSpeed(); + return this.isPlayer() ? (float)this.getEntityAttribute(Attribute.MOVEMENT_SPEED).getAttributeValue() : super.getAIMoveSpeed(); } /** @@ -4323,13 +4323,13 @@ public abstract class EntityNPC extends EntityLiving return this.isPlayer() ? this.getDataWatcher().getWatchableObjectInt(30) : super.getAbsorptionAmount(); } - public boolean canOpen(LockCode code) + public boolean canOpen(Passcode code) { - if (code.isEmpty()) + if (code.empty()) return true; ItemStack stack = this.getCurrentEquippedItem(); return stack != null && stack.getItem() == Items.key && - stack.hasDisplayName() && stack.getDisplayName().equals(code.getLock()); + stack.hasDisplayName() && stack.getDisplayName().equals(code.code()); } // public boolean isWearing(ModelPart part) diff --git a/common/src/main/java/common/entity/npc/EntityOrc.java b/common/src/main/java/common/entity/npc/EntityOrc.java index 96cdb66..654a7a5 100755 --- a/common/src/main/java/common/entity/npc/EntityOrc.java +++ b/common/src/main/java/common/entity/npc/EntityOrc.java @@ -1,6 +1,6 @@ package common.entity.npc; -import common.attributes.Attributes; +import common.attributes.Attribute; import common.rng.Random; import common.world.World; @@ -72,6 +72,6 @@ public class EntityOrc extends EntityNPC { protected void applyEntityAttributes() { super.applyEntityAttributes(); - this.getEntityAttribute(Attributes.ATTACK_DAMAGE).setBaseValue(4.0D); + this.getEntityAttribute(Attribute.ATTACK_DAMAGE).setBaseValue(4.0D); } } diff --git a/common/src/main/java/common/entity/npc/EntityPrimarch.java b/common/src/main/java/common/entity/npc/EntityPrimarch.java index e4c29f8..628944e 100755 --- a/common/src/main/java/common/entity/npc/EntityPrimarch.java +++ b/common/src/main/java/common/entity/npc/EntityPrimarch.java @@ -2,7 +2,7 @@ package common.entity.npc; import java.util.List; -import common.attributes.Attributes; +import common.attributes.Attribute; import common.collect.Lists; import common.rng.Random; import common.util.Identifyable; @@ -154,7 +154,7 @@ public class EntityPrimarch extends EntityMobNPC { protected void applyEntityAttributes() { super.applyEntityAttributes(); - this.getEntityAttribute(Attributes.ATTACK_DAMAGE).setBaseValue(20.0D); + this.getEntityAttribute(Attribute.ATTACK_DAMAGE).setBaseValue(20.0D); } // public TextComponent getPrefix() { diff --git a/common/src/main/java/common/entity/npc/EntitySlime.java b/common/src/main/java/common/entity/npc/EntitySlime.java index 4f5b5cc..6250579 100755 --- a/common/src/main/java/common/entity/npc/EntitySlime.java +++ b/common/src/main/java/common/entity/npc/EntitySlime.java @@ -2,7 +2,7 @@ package common.entity.npc; import common.ai.EntityAIBase; import common.ai.EntityMoveHelper; -import common.attributes.Attributes; +import common.attributes.Attribute; import common.biome.Biome; import common.entity.DamageSource; import common.entity.Entity; @@ -661,7 +661,7 @@ public class EntitySlime extends EntityNPC if (this.entity.onGround) { - this.entity.setAIMoveSpeed((float)(this.speed * this.entity.getEntityAttribute(Attributes.MOVEMENT_SPEED).getAttributeValue())); + this.entity.setAIMoveSpeed((float)(this.speed * this.entity.getEntityAttribute(Attribute.MOVEMENT_SPEED).getAttributeValue())); if (this.jumpDelay-- <= 0) { @@ -688,7 +688,7 @@ public class EntitySlime extends EntityNPC } else { - this.entity.setAIMoveSpeed((float)(this.speed * this.entity.getEntityAttribute(Attributes.MOVEMENT_SPEED).getAttributeValue())); + this.entity.setAIMoveSpeed((float)(this.speed * this.entity.getEntityAttribute(Attribute.MOVEMENT_SPEED).getAttributeValue())); } } } diff --git a/common/src/main/java/common/entity/npc/EntitySpaceMarine.java b/common/src/main/java/common/entity/npc/EntitySpaceMarine.java index 566360c..82dd32e 100755 --- a/common/src/main/java/common/entity/npc/EntitySpaceMarine.java +++ b/common/src/main/java/common/entity/npc/EntitySpaceMarine.java @@ -2,7 +2,7 @@ package common.entity.npc; import java.util.List; -import common.attributes.Attributes; +import common.attributes.Attribute; import common.collect.Lists; import common.init.Items; import common.init.SpeciesRegistry; @@ -118,7 +118,7 @@ public class EntitySpaceMarine extends EntityNPC { protected void applyEntityAttributes() { super.applyEntityAttributes(); - this.getEntityAttribute(Attributes.ATTACK_DAMAGE).setBaseValue(12.0D); + this.getEntityAttribute(Attribute.ATTACK_DAMAGE).setBaseValue(12.0D); } protected ItemStack pickItem() { diff --git a/common/src/main/java/common/entity/npc/EntityTiefling.java b/common/src/main/java/common/entity/npc/EntityTiefling.java index f3134f1..507d49c 100755 --- a/common/src/main/java/common/entity/npc/EntityTiefling.java +++ b/common/src/main/java/common/entity/npc/EntityTiefling.java @@ -1,6 +1,6 @@ package common.entity.npc; -import common.attributes.Attributes; +import common.attributes.Attribute; import common.rng.Random; import common.world.World; @@ -80,6 +80,6 @@ public class EntityTiefling extends EntityMobNPC { protected void applyEntityAttributes() { super.applyEntityAttributes(); - this.getEntityAttribute(Attributes.ATTACK_DAMAGE).setBaseValue(3.0D); + this.getEntityAttribute(Attribute.ATTACK_DAMAGE).setBaseValue(3.0D); } } diff --git a/common/src/main/java/common/entity/npc/EntityUndead.java b/common/src/main/java/common/entity/npc/EntityUndead.java index af39d58..73441b1 100755 --- a/common/src/main/java/common/entity/npc/EntityUndead.java +++ b/common/src/main/java/common/entity/npc/EntityUndead.java @@ -1,7 +1,7 @@ package common.entity.npc; import common.ai.EntityAIAvoidEntity; -import common.attributes.Attributes; +import common.attributes.Attribute; import common.entity.animal.EntityWolf; import common.entity.types.EntityLiving; import common.init.Items; @@ -21,7 +21,7 @@ public class EntityUndead extends EntityNPC protected void applyEntityAttributes() { super.applyEntityAttributes(); - this.getEntityAttribute(Attributes.MOVEMENT_SPEED).setBaseValue(0.25D); + this.getEntityAttribute(Attribute.MOVEMENT_SPEED).setBaseValue(0.25D); } // protected String getLivingSound() diff --git a/common/src/main/java/common/entity/npc/EntityVampire.java b/common/src/main/java/common/entity/npc/EntityVampire.java index 0733ab9..8972361 100755 --- a/common/src/main/java/common/entity/npc/EntityVampire.java +++ b/common/src/main/java/common/entity/npc/EntityVampire.java @@ -1,6 +1,6 @@ package common.entity.npc; -import common.attributes.Attributes; +import common.attributes.Attribute; import common.entity.effect.EntityLightning; import common.rng.Random; import common.world.World; @@ -75,6 +75,6 @@ public class EntityVampire extends EntityNPC { protected void applyEntityAttributes() { super.applyEntityAttributes(); - this.getEntityAttribute(Attributes.ATTACK_DAMAGE).setBaseValue(5.0D); + this.getEntityAttribute(Attribute.ATTACK_DAMAGE).setBaseValue(5.0D); } } diff --git a/common/src/main/java/common/entity/npc/EntityZombie.java b/common/src/main/java/common/entity/npc/EntityZombie.java index a38a61f..c8f47b2 100755 --- a/common/src/main/java/common/entity/npc/EntityZombie.java +++ b/common/src/main/java/common/entity/npc/EntityZombie.java @@ -4,8 +4,8 @@ import java.util.List; import java.util.function.Predicate; import common.ai.EntityAIMoveThroughVillage; +import common.attributes.Attribute; import common.attributes.AttributeModifier; -import common.attributes.Attributes; import common.entity.DamageSource; import common.entity.animal.EntityChicken; import common.entity.types.EntityLiving; @@ -27,10 +27,10 @@ public class EntityZombie extends EntityNPC protected void applyEntityAttributes() { super.applyEntityAttributes(); - this.getEntityAttribute(Attributes.FOLLOW_RANGE).setBaseValue(28.0D); - this.getEntityAttribute(Attributes.MOVEMENT_SPEED).setBaseValue(0.23000000417232513D); - this.getEntityAttribute(Attributes.ATTACK_DAMAGE).setBaseValue(3.0D); - this.getAttributeMap().registerAttribute(Attributes.REINFORCEMENT_CHANCE).setBaseValue(this.rand.doublev() * 0.10000000149011612D); + this.getEntityAttribute(Attribute.FOLLOW_RANGE).setBaseValue(28.0D); + this.getEntityAttribute(Attribute.MOVEMENT_SPEED).setBaseValue(0.23000000417232513D); + this.getEntityAttribute(Attribute.ATTACK_DAMAGE).setBaseValue(3.0D); + this.getAttributeMap().registerAttribute(Attribute.REINFORCEMENT_CHANCE).setBaseValue(this.rand.doublev() * 0.10000000149011612D); } public void onLivingUpdate() @@ -53,7 +53,7 @@ public class EntityZombie extends EntityNPC entitylivingbase = (EntityLiving)source.getEntity(); } - if (entitylivingbase != null && /* this.worldObj.getDifficulty() == Difficulty.HARD && */ (double)this.rand.floatv() < this.getEntityAttribute(Attributes.REINFORCEMENT_CHANCE).getAttributeValue() && Config.mobs && Config.spawnMoreZombie) + if (entitylivingbase != null && /* this.worldObj.getDifficulty() == Difficulty.HARD && */ (double)this.rand.floatv() < this.getEntityAttribute(Attribute.REINFORCEMENT_CHANCE).getAttributeValue() && Config.mobs && Config.spawnMoreZombie) { int i = ExtMath.floord(this.posX); int j = ExtMath.floord(this.posY); @@ -75,8 +75,8 @@ public class EntityZombie extends EntityNPC this.worldObj.spawnEntityInWorld(entityzombie); entityzombie.setAttackTarget(entitylivingbase); entityzombie.onInitialSpawn(null); - this.getEntityAttribute(Attributes.REINFORCEMENT_CHANCE).applyModifier(new AttributeModifier("Zombie reinforcement caller charge", -0.05000000074505806D, false)); - entityzombie.getEntityAttribute(Attributes.REINFORCEMENT_CHANCE).applyModifier(new AttributeModifier("Zombie reinforcement callee charge", -0.05000000074505806D, false)); + this.getEntityAttribute(Attribute.REINFORCEMENT_CHANCE).applyModifier(new AttributeModifier("Zombie reinforcement caller charge", -0.05000000074505806D, false)); + entityzombie.getEntityAttribute(Attribute.REINFORCEMENT_CHANCE).applyModifier(new AttributeModifier("Zombie reinforcement callee charge", -0.05000000074505806D, false)); break; } } @@ -250,18 +250,18 @@ public class EntityZombie extends EntityNPC // } // } - this.getEntityAttribute(Attributes.KNOCKBACK_RESISTANCE).applyModifier(new AttributeModifier("Random spawn bonus", this.rand.doublev() * 0.05000000074505806D, false)); + this.getEntityAttribute(Attribute.KNOCKBACK_RESISTANCE).applyModifier(new AttributeModifier("Random spawn bonus", this.rand.doublev() * 0.05000000074505806D, false)); double d0 = this.rand.doublev() * 15.0; if (d0 > 1.0D) { - this.getEntityAttribute(Attributes.FOLLOW_RANGE).applyModifier(new AttributeModifier("Random zombie-spawn bonus", d0, false)); + this.getEntityAttribute(Attribute.FOLLOW_RANGE).applyModifier(new AttributeModifier("Random zombie-spawn bonus", d0, false)); } if (this.rand.chance(30)) { - this.getEntityAttribute(Attributes.REINFORCEMENT_CHANCE).applyModifier(new AttributeModifier("Leader zombie bonus", this.rand.doublev() * 0.25D + 0.5D, false)); - this.getEntityAttribute(Attributes.MAX_HEALTH).applyModifier(new AttributeModifier("Leader zombie bonus", this.rand.roll(4), true)); + this.getEntityAttribute(Attribute.REINFORCEMENT_CHANCE).applyModifier(new AttributeModifier("Leader zombie bonus", this.rand.doublev() * 0.25D + 0.5D, false)); + this.getEntityAttribute(Attribute.MAX_HEALTH).applyModifier(new AttributeModifier("Leader zombie bonus", this.rand.roll(4), true)); // this.setBreakDoorsAItask(true); } diff --git a/common/src/main/java/common/entity/npc/PlayerCharacter.java b/common/src/main/java/common/entity/npc/PlayerCharacter.java index c9e6c74..89874f4 100644 --- a/common/src/main/java/common/entity/npc/PlayerCharacter.java +++ b/common/src/main/java/common/entity/npc/PlayerCharacter.java @@ -2,22 +2,5 @@ package common.entity.npc; import common.util.BlockPos; -public class PlayerCharacter { - public final String name; - public final String info; - public final Alignment align; - public final String dim; - public final BlockPos pos; - public final String type; - public final int level; - - public PlayerCharacter(String name, String info, Alignment align, String dim, BlockPos pos, String type, int level) { - this.name = name; - this.info = info; - this.align = align; - this.dim = dim; - this.pos = pos; - this.type = type; - this.level = level; - } +public record PlayerCharacter(String name, String info, Alignment align, String dim, BlockPos pos, String type, int level) { } diff --git a/common/src/main/java/common/entity/types/CombatEntry.java b/common/src/main/java/common/entity/types/CombatEntry.java index d630ff5..9d9b6e7 100755 --- a/common/src/main/java/common/entity/types/CombatEntry.java +++ b/common/src/main/java/common/entity/types/CombatEntry.java @@ -2,32 +2,5 @@ package common.entity.types; import common.entity.DamageSource; -public class CombatEntry { - private final DamageSource source; - private final int damage; - private final String blockType; - private final float fallDistance; - - public CombatEntry(DamageSource source, int damage, String blockType, float fallDistance) { - this.source = source; - this.damage = damage; - this.blockType = blockType; - this.fallDistance = fallDistance; - } - - public DamageSource getSource() { - return this.source; - } - - public int getDamage() { - return this.damage; - } - - public String getBlockType() { - return this.blockType; - } - - public float getFallDistance() { - return this.source == DamageSource.outOfWorld ? Float.MAX_VALUE : this.fallDistance; - } +public record CombatEntry(DamageSource source, int damage, String blockType, float fallDistance) { } diff --git a/common/src/main/java/common/entity/types/EntityLiving.java b/common/src/main/java/common/entity/types/EntityLiving.java index c482140..e6915c5 100755 --- a/common/src/main/java/common/entity/types/EntityLiving.java +++ b/common/src/main/java/common/entity/types/EntityLiving.java @@ -192,13 +192,13 @@ public abstract class EntityLiving extends Entity protected void applyEntityAttributes() { - this.getAttributeMap().registerAttribute(Attributes.MAX_HEALTH); - this.getAttributeMap().registerAttribute(Attributes.KNOCKBACK_RESISTANCE); - this.getAttributeMap().registerAttribute(Attributes.MOVEMENT_SPEED); - this.getAttributeMap().registerAttribute(Attributes.RADIATION); - this.getAttributeMap().registerAttribute(Attributes.RADIATION_RESISTANCE); + this.getAttributeMap().registerAttribute(Attribute.MAX_HEALTH); + this.getAttributeMap().registerAttribute(Attribute.KNOCKBACK_RESISTANCE); + this.getAttributeMap().registerAttribute(Attribute.MOVEMENT_SPEED); + this.getAttributeMap().registerAttribute(Attribute.RADIATION); + this.getAttributeMap().registerAttribute(Attribute.RADIATION_RESISTANCE); - this.getAttributeMap().registerAttribute(Attributes.FOLLOW_RANGE).setBaseValue(16.0D); + this.getAttributeMap().registerAttribute(Attribute.FOLLOW_RANGE).setBaseValue(16.0D); } protected void updateFallState(double y, boolean onGroundIn, Block blockIn, BlockPos pos) @@ -367,8 +367,8 @@ public abstract class EntityLiving extends Entity if(!this.worldObj.client) { if(!this.firstEffectUpdate && Config.radiation) { // && // (!(this.isPlayer()) || !((EntityNPCMP)this).creative)) { - float radiation = this.radiation + (float)this.attributes.getAttributeInstance(Attributes.RADIATION).getAttributeValue(); - radiation -= (float)this.attributes.getAttributeInstance(Attributes.RADIATION_RESISTANCE).getAttributeValue(); + float radiation = this.radiation + (float)this.attributes.getAttributeInstance(Attribute.RADIATION).getAttributeValue(); + radiation -= (float)this.attributes.getAttributeInstance(Attribute.RADIATION_RESISTANCE).getAttributeValue(); // if(this.isPlayer()) // Log.SERVER.info("rad:" + radiation); if(radiation >= 0.0f) { @@ -1153,7 +1153,7 @@ public abstract class EntityLiving extends Entity */ public void knockBack(Entity source, float damage, double xfactor, double zfactor) { - if (this.rand.doublev() >= this.getEntityAttribute(Attributes.KNOCKBACK_RESISTANCE).getAttributeValue()) + if (this.rand.doublev() >= this.getEntityAttribute(Attribute.KNOCKBACK_RESISTANCE).getAttributeValue()) { this.isAirBorne = true; float div = ExtMath.sqrtd(xfactor * xfactor + zfactor * zfactor); @@ -1379,17 +1379,17 @@ public abstract class EntityLiving extends Entity public final int getMaxHealth() { - return (int)this.getEntityAttribute(Attributes.MAX_HEALTH).getAttributeValue(); + return (int)this.getEntityAttribute(Attribute.MAX_HEALTH).getAttributeValue(); } public final int getRawMaxHealth() { - return (int)this.getEntityAttribute(Attributes.MAX_HEALTH).getBaseValue(); + return (int)this.getEntityAttribute(Attribute.MAX_HEALTH).getBaseValue(); } public final void setMaxHealth(int max) { - this.getEntityAttribute(Attributes.MAX_HEALTH).setBaseValue((double)max); + this.getEntityAttribute(Attribute.MAX_HEALTH).setBaseValue((double)max); } public int getMaxMana() { @@ -1550,9 +1550,9 @@ public abstract class EntityLiving extends Entity public void setSprinting(boolean sprinting) { super.setSprinting(sprinting); - AttributeInstance iattributeinstance = this.getEntityAttribute(Attributes.MOVEMENT_SPEED); + AttributeInstance iattributeinstance = this.getEntityAttribute(Attribute.MOVEMENT_SPEED); - if (iattributeinstance.getModifier(Attributes.SPRINT_SPEED_ID) != null) + if (iattributeinstance.hasModifier(Attributes.SPRINT_SPEED_MOD)) { iattributeinstance.removeModifier(Attributes.SPRINT_SPEED_MOD); } @@ -2310,7 +2310,7 @@ public abstract class EntityLiving extends Entity */ protected void setBeenAttacked() { - this.veloChanged = this.rand.doublev() >= this.getEntityAttribute(Attributes.KNOCKBACK_RESISTANCE).getAttributeValue(); + this.veloChanged = this.rand.doublev() >= this.getEntityAttribute(Attribute.KNOCKBACK_RESISTANCE).getAttributeValue(); } public float getRotationYawHead() @@ -2443,11 +2443,11 @@ public abstract class EntityLiving extends Entity else if(this.isInLiquid()) { this.blockType = "aus dem Wasser"; } - CombatEntry entry = new CombatEntry(source, amount, this.blockType, this.fallDistance); + CombatEntry entry = new CombatEntry(source, amount, this.blockType, source == DamageSource.outOfWorld ? Float.MAX_VALUE : this.fallDistance); this.combat.add(entry); this.lastDamaged = this.ticksExisted; this.damaged = true; - if(entry.getSource().getEntity() instanceof EntityLiving && !this.attacked && this.isEntityAlive()) + if(entry.source().getEntity() instanceof EntityLiving && !this.attacked && this.isEntityAlive()) this.attacked = true; } @@ -2474,8 +2474,8 @@ public abstract class EntityLiving extends Entity CombatEntry entry = (CombatEntry)this.combat.get(z); CombatEntry last = z > 0 ? (CombatEntry)this.combat.get(z - 1) : null; - if((entry.getSource() == DamageSource.fall || entry.getSource() == DamageSource.outOfWorld) && - entry.getFallDistance() > 0.0F && (strong == null || entry.getFallDistance() > max)) { + if((entry.source() == DamageSource.fall || entry.source() == DamageSource.outOfWorld) && + entry.fallDistance() > 0.0F && (strong == null || entry.fallDistance() > max)) { if(z > 0) { strong = last; } @@ -2483,20 +2483,20 @@ public abstract class EntityLiving extends Entity strong = entry; } - max = entry.getFallDistance(); + max = entry.fallDistance(); } - if(entry.getBlockType() != null && (block == null || entry.getDamage() > min)) { + if(entry.blockType() != null && (block == null || entry.damage() > min)) { block = entry; } } CombatEntry fall = max > 5.0F && strong != null ? strong : (min > 5 && block != null ? block : null); CombatEntry last = (CombatEntry)this.combat.get(this.combat.size() - 1); - Entity lastEnt = last.getSource().getEntity(); + Entity lastEnt = last.source().getEntity(); - if(fall != null && last.getSource() == DamageSource.fall) { - if(fall.getSource() != DamageSource.fall && fall.getSource() != DamageSource.outOfWorld) { - Entity fallEnt = fall.getSource().getEntity(); + if(fall != null && last.source() == DamageSource.fall) { + if(fall.source() != DamageSource.fall && fall.source() != DamageSource.outOfWorld) { + Entity fallEnt = fall.source().getEntity(); if(fallEnt != null && (lastEnt == null || fallEnt != lastEnt)) { ItemStack fallItem = fallEnt instanceof EntityLiving ? ((EntityLiving)fallEnt).getHeldItem() : null; receiver = fallEnt.isPlayer() ? ((EntityNPC)fallEnt).connection : null; @@ -2534,14 +2534,14 @@ public abstract class EntityLiving extends Entity } } else { - msg = kill = natural ? String.format("%s fiel " + (fall.getBlockType() == null ? "aus zu großer Höhe" : fall.getBlockType()), + msg = kill = natural ? String.format("%s fiel " + (fall.blockType() == null ? "aus zu großer Höhe" : fall.blockType()), this.getColoredName(TextColor.NEON)) : null; } } else { - receiver = last.getSource().getEntity() != null && last.getSource().getEntity().isPlayer() ? ((EntityNPC)last.getSource().getEntity()).connection : null; - msg = natural || (last.getSource() instanceof EntityDamageSource ? last.getSource().getEntity() != null : this.getAttackingEntity() != null) ? last.getSource().getDeathMessage(this) : null; - kill = msg == null ? null : last.getSource().getKillMessage(this); + receiver = last.source().getEntity() != null && last.source().getEntity().isPlayer() ? ((EntityNPC)last.source().getEntity()).connection : null; + msg = natural || (last.source() instanceof EntityDamageSource ? last.source().getEntity() != null : this.getAttackingEntity() != null) ? last.source().getDeathMessage(this) : null; + kill = msg == null ? null : last.source().getKillMessage(this); } } if(msg == null) @@ -2561,13 +2561,13 @@ public abstract class EntityLiving extends Entity int edmg = 0; int pdmg = 0; for(CombatEntry entry : this.combat) { - if(entry.getSource().getEntity() != null && entry.getSource().getEntity().isPlayer() && (player == null || entry.getDamage() > pdmg)) { - pdmg = entry.getDamage(); - player = (EntityNPC)entry.getSource().getEntity(); + if(entry.source().getEntity() != null && entry.source().getEntity().isPlayer() && (player == null || entry.damage() > pdmg)) { + pdmg = entry.damage(); + player = (EntityNPC)entry.source().getEntity(); } - if(entry.getSource().getEntity() instanceof EntityLiving && (entity == null || entry.getDamage() > edmg)) { - edmg = entry.getDamage(); - entity = (EntityLiving)entry.getSource().getEntity(); + if(entry.source().getEntity() instanceof EntityLiving && (entity == null || entry.damage() > edmg)) { + edmg = entry.damage(); + entity = (EntityLiving)entry.source().getEntity(); } } return player != null && pdmg >= edmg / 3 ? player : entity; @@ -2713,7 +2713,7 @@ public abstract class EntityLiving extends Entity // } public Object onInitialSpawn(Object livingdata) { - this.getEntityAttribute(Attributes.FOLLOW_RANGE) + this.getEntityAttribute(Attribute.FOLLOW_RANGE) .applyModifier(new AttributeModifier("Random spawn bonus", this.rand.gaussian() * 0.05D, true)); return livingdata; } diff --git a/common/src/main/java/common/init/DispenserRegistry.java b/common/src/main/java/common/init/DispenserRegistry.java index dc3235e..5b35f79 100755 --- a/common/src/main/java/common/init/DispenserRegistry.java +++ b/common/src/main/java/common/init/DispenserRegistry.java @@ -149,8 +149,8 @@ public abstract class DispenserRegistry { return stack; } }; - for(EntityEggInfo egg : EntityRegistry.SPAWN_EGGS.values()) { - REGISTRY.putObject(ItemRegistry.getRegisteredItem(egg.id.toLowerCase() + "_spawner"), + for(EntityInfo egg : EntityRegistry.SPAWN_EGGS.values()) { + REGISTRY.putObject(ItemRegistry.getRegisteredItem(egg.id().toLowerCase() + "_spawner"), disp); } REGISTRY.putObject(Items.fireworks, new BehaviorDefaultDispenseItem() diff --git a/common/src/main/java/common/init/EntityEggInfo.java b/common/src/main/java/common/init/EntityEggInfo.java deleted file mode 100755 index 87351b9..0000000 --- a/common/src/main/java/common/init/EntityEggInfo.java +++ /dev/null @@ -1,15 +0,0 @@ -package common.init; - -public class EntityEggInfo { - public final String id; - public final String origin; - public final int color1; - public final int color2; - - public EntityEggInfo(String id, String origin, int color1, int color2) { - this.id = id; - this.origin = origin; - this.color1 = color1; - this.color2 = color2; - } -} diff --git a/common/src/main/java/common/init/EntityInfo.java b/common/src/main/java/common/init/EntityInfo.java new file mode 100755 index 0000000..6ea464e --- /dev/null +++ b/common/src/main/java/common/init/EntityInfo.java @@ -0,0 +1,4 @@ +package common.init; + +public record EntityInfo(String id, String origin, int color1, int color2) { +} diff --git a/common/src/main/java/common/init/EntityRegistry.java b/common/src/main/java/common/init/EntityRegistry.java index 1213843..6fe113e 100755 --- a/common/src/main/java/common/init/EntityRegistry.java +++ b/common/src/main/java/common/init/EntityRegistry.java @@ -58,7 +58,7 @@ public abstract class EntityRegistry { private static final Map> ID_TO_CLASS = Maps.>newHashMap(); private static final Map, Integer> CLASS_TO_ID = Maps., Integer>newHashMap(); // private static final Map STRING_TO_ID = Maps.newHashMap(); - public static final Map SPAWN_EGGS = Maps.newLinkedHashMap(); + public static final Map SPAWN_EGGS = Maps.newLinkedHashMap(); private static final Map STRING_TO_NAME = Maps.newHashMap(); private static boolean register; @@ -89,7 +89,7 @@ public abstract class EntityRegistry { } else { // String name = clazz.getSimpleName().substring(6); - SPAWN_EGGS.put(name, new EntityEggInfo(name, origin, eggColor, spotColor)); + SPAWN_EGGS.put(name, new EntityInfo(name, origin, eggColor, spotColor)); } } diff --git a/common/src/main/java/common/init/ItemRegistry.java b/common/src/main/java/common/init/ItemRegistry.java index 5c0a660..e0f0d44 100755 --- a/common/src/main/java/common/init/ItemRegistry.java +++ b/common/src/main/java/common/init/ItemRegistry.java @@ -371,8 +371,8 @@ public abstract class ItemRegistry { registerItem("hopper_minecart", (new ItemMinecart(EntityCart.EnumMinecartType.HOPPER)).setDisplay("Trichterlore")); registerItem("tnt_minecart", (new ItemMinecart(EntityCart.EnumMinecartType.TNT)).setDisplay("TNT-Lore") .setColor(TextColor.RED)); - for(EntityEggInfo egg : EntityRegistry.SPAWN_EGGS.values()) { - registerItem(egg.id.toLowerCase() + "_spawner", (new ItemMonsterPlacer(egg.id)) + for(EntityInfo egg : EntityRegistry.SPAWN_EGGS.values()) { + registerItem(egg.id().toLowerCase() + "_spawner", (new ItemMonsterPlacer(egg.id())) .setDisplay("Spawner").setMaxStackSize(ItemStack.MAX_SIZE)); } for(SpeciesInfo species : SpeciesRegistry.SPECIMEN) { diff --git a/common/src/main/java/common/inventory/ContainerLocalMenu.java b/common/src/main/java/common/inventory/ContainerLocalMenu.java index c8f636e..8c80f37 100755 --- a/common/src/main/java/common/inventory/ContainerLocalMenu.java +++ b/common/src/main/java/common/inventory/ContainerLocalMenu.java @@ -5,7 +5,7 @@ import java.util.Map; import common.collect.Maps; import common.entity.npc.EntityNPC; import common.tileentity.ILockableContainer; -import common.tileentity.LockCode; +import common.tileentity.Passcode; public class ContainerLocalMenu extends InventoryBasic implements ILockableContainer { @@ -38,13 +38,13 @@ public class ContainerLocalMenu extends InventoryBasic implements ILockableConta return false; } - public void setLockCode(LockCode code) + public void setLockCode(Passcode code) { } - public LockCode getLockCode() + public Passcode getLockCode() { - return LockCode.EMPTY_CODE; + return Passcode.EMPTY_CODE; } public String getGuiID() diff --git a/common/src/main/java/common/inventory/InventoryLargeChest.java b/common/src/main/java/common/inventory/InventoryLargeChest.java index 85d9844..7021e91 100755 --- a/common/src/main/java/common/inventory/InventoryLargeChest.java +++ b/common/src/main/java/common/inventory/InventoryLargeChest.java @@ -3,7 +3,7 @@ package common.inventory; import common.entity.npc.EntityNPC; import common.item.ItemStack; import common.tileentity.ILockableContainer; -import common.tileentity.LockCode; +import common.tileentity.Passcode; import common.tileentity.TileEntityChest; public class InventoryLargeChest implements ILockableContainer @@ -188,13 +188,13 @@ public class InventoryLargeChest implements ILockableContainer return this.upperChest.isLocked() || this.lowerChest.isLocked(); } - public void setLockCode(LockCode code) + public void setLockCode(Passcode code) { this.upperChest.setLockCode(code); this.lowerChest.setLockCode(code); } - public LockCode getLockCode() + public Passcode getLockCode() { return this.upperChest.getLockCode(); } diff --git a/common/src/main/java/common/inventory/InventoryMerchant.java b/common/src/main/java/common/inventory/InventoryMerchant.java index 5bed206..b6f4baf 100755 --- a/common/src/main/java/common/inventory/InventoryMerchant.java +++ b/common/src/main/java/common/inventory/InventoryMerchant.java @@ -229,7 +229,7 @@ public class InventoryMerchant implements IInventory if (merchantrecipe != null) // && !merchantrecipe.isRecipeDisabled()) { this.currentRecipe = merchantrecipe; - this.setInventorySlotContents(2, merchantrecipe.getSelling().copy()); + this.setInventorySlotContents(2, merchantrecipe.result().copy()); } else if (itemstack1 != null) { @@ -238,7 +238,7 @@ public class InventoryMerchant implements IInventory if (merchantrecipe != null) // && !merchantrecipe.isRecipeDisabled()) { this.currentRecipe = merchantrecipe; - this.setInventorySlotContents(2, merchantrecipe.getSelling().copy()); + this.setInventorySlotContents(2, merchantrecipe.result().copy()); } else { diff --git a/common/src/main/java/common/inventory/SlotMerchantResult.java b/common/src/main/java/common/inventory/SlotMerchantResult.java index 3fb685b..05172d5 100755 --- a/common/src/main/java/common/inventory/SlotMerchantResult.java +++ b/common/src/main/java/common/inventory/SlotMerchantResult.java @@ -94,8 +94,8 @@ public class SlotMerchantResult extends Slot private boolean doTrade(MerchantRecipe trade, ItemStack firstItem, ItemStack secondItem) { - ItemStack itemstack = trade.getBuying(); - ItemStack itemstack1 = trade.getSecondBuy(); + ItemStack itemstack = trade.first(); + ItemStack itemstack1 = trade.second(); if (firstItem != null && firstItem.getItem() == itemstack.getItem()) { diff --git a/common/src/main/java/common/item/ItemArmor.java b/common/src/main/java/common/item/ItemArmor.java index e0f928f..a0b2eae 100755 --- a/common/src/main/java/common/item/ItemArmor.java +++ b/common/src/main/java/common/item/ItemArmor.java @@ -260,11 +260,11 @@ public class ItemArmor extends Item { Map> multimap = super.getItemAttributeModifiers(); if(this.material.getRadiationReduction(this.armorType) > 0.0f) - multimap.put(Attributes.RADIATION_RESISTANCE, + multimap.put(Attribute.RADIATION_RESISTANCE, Sets.newHashSet(new AttributeModifier(Attributes.ITEM_VAL_ID + (long)this.armorType + 1L, "Armor modifier " + (this.armorType + 1), (double)this.material.getRadiationReduction(this.armorType), false))); if(this.material.getMagicReduction(this.armorType) > 0.0f) - multimap.put(Attributes.MAGIC_RESISTANCE, + multimap.put(Attribute.MAGIC_RESISTANCE, Sets.newHashSet(new AttributeModifier(Attributes.ITEM_VAL_ID + (long)this.armorType + 1L, "Armor modifier " + (this.armorType + 1), (double)this.material.getMagicReduction(this.armorType), false))); return multimap; diff --git a/common/src/main/java/common/item/ItemBucketMilk.java b/common/src/main/java/common/item/ItemBucketMilk.java index 849163b..97e9cb6 100755 --- a/common/src/main/java/common/item/ItemBucketMilk.java +++ b/common/src/main/java/common/item/ItemBucketMilk.java @@ -67,7 +67,7 @@ public class ItemBucketMilk extends Item public Map> getItemInventoryModifiers() { Map> multimap = super.getItemInventoryModifiers(); - multimap.put(Attributes.RADIATION, Sets.newHashSet(new AttributeModifier(Attributes.ITEM_VAL_ID, "Milk modifier", -5.0, false, true, true))); + multimap.put(Attribute.RADIATION, Sets.newHashSet(new AttributeModifier(Attributes.ITEM_VAL_ID, "Milk modifier", -5.0, false, true, true))); return multimap; } diff --git a/common/src/main/java/common/item/ItemMetal.java b/common/src/main/java/common/item/ItemMetal.java index c4b3df6..92cb480 100755 --- a/common/src/main/java/common/item/ItemMetal.java +++ b/common/src/main/java/common/item/ItemMetal.java @@ -39,7 +39,7 @@ public class ItemMetal extends Item { { Map> multimap = super.getItemInventoryModifiers(); if(this.metal.radioactivity > 0.0f) - multimap.put(Attributes.RADIATION, Sets.newHashSet(new AttributeModifier(Attributes.ITEM_VAL_ID, "Metal modifier", (double)this.metal.radioactivity * 4.0, false, true, true))); + multimap.put(Attribute.RADIATION, Sets.newHashSet(new AttributeModifier(Attributes.ITEM_VAL_ID, "Metal modifier", (double)this.metal.radioactivity * 4.0, false, true, true))); return multimap; } diff --git a/common/src/main/java/common/item/ItemMetalBlock.java b/common/src/main/java/common/item/ItemMetalBlock.java index 112005e..89f45cd 100755 --- a/common/src/main/java/common/item/ItemMetalBlock.java +++ b/common/src/main/java/common/item/ItemMetalBlock.java @@ -43,7 +43,7 @@ public class ItemMetalBlock extends ItemBlock { { Map> multimap = super.getItemInventoryModifiers(); if(this.metal.radioactivity > 0.0f) - multimap.put(Attributes.RADIATION, Sets.newHashSet(new AttributeModifier(Attributes.ITEM_VAL_ID, "Metal modifier", (double)this.metal.radioactivity * 4.0 * (this.ore ? 2.0 : 9.0), false, true, true))); + multimap.put(Attribute.RADIATION, Sets.newHashSet(new AttributeModifier(Attributes.ITEM_VAL_ID, "Metal modifier", (double)this.metal.radioactivity * 4.0 * (this.ore ? 2.0 : 9.0), false, true, true))); return multimap; } diff --git a/common/src/main/java/common/item/ItemMonsterPlacer.java b/common/src/main/java/common/item/ItemMonsterPlacer.java index 0174fa6..9747a18 100755 --- a/common/src/main/java/common/item/ItemMonsterPlacer.java +++ b/common/src/main/java/common/item/ItemMonsterPlacer.java @@ -10,7 +10,7 @@ import common.entity.Entity; import common.entity.npc.EntityNPC; import common.entity.types.EntityLiving; import common.init.Blocks; -import common.init.EntityEggInfo; +import common.init.EntityInfo; import common.init.EntityRegistry; import common.init.UniverseRegistry; import common.model.Model; @@ -54,14 +54,14 @@ public class ItemMonsterPlacer extends Item public int getColorFromItemStack(ItemStack stack, int renderPass) { - EntityEggInfo egg = EntityRegistry.SPAWN_EGGS.get(this.entityId); - return egg != null ? (renderPass == 0 ? egg.color1 : egg.color2) : 16777215; + EntityInfo egg = EntityRegistry.SPAWN_EGGS.get(this.entityId); + return egg != null ? (renderPass == 0 ? egg.color1() : egg.color2()) : 16777215; } public void addInformation(ItemStack stack, EntityNPC player, List tooltip) { - EntityEggInfo egg = EntityRegistry.SPAWN_EGGS.get(this.entityId); + EntityInfo egg = EntityRegistry.SPAWN_EGGS.get(this.entityId); if(egg != null) { - Dimension dim = egg.origin == null ? null : UniverseRegistry.getDimension(egg.origin); + Dimension dim = egg.origin() == null ? null : UniverseRegistry.getDimension(egg.origin()); tooltip.add(TextColor.ORANGE + "Herkunft: " + (dim == null ? "???" : dim.getFormattedName(false))); } } diff --git a/common/src/main/java/common/item/ItemPotion.java b/common/src/main/java/common/item/ItemPotion.java index ed6ad8b..12690e7 100755 --- a/common/src/main/java/common/item/ItemPotion.java +++ b/common/src/main/java/common/item/ItemPotion.java @@ -324,12 +324,12 @@ public class ItemPotion extends Item if (d0 > 0.0D) { - tooltip.add(TextColor.BLUE + String.format("+%s" + (attributemodifier2.isMultiplied() ? "%%" : "") + " %s", ItemStack.DECIMALFORMAT.format(d1), entry1.getKey().getDisplayName())); + tooltip.add(TextColor.BLUE + String.format("+%s" + (attributemodifier2.isMultiplied() ? "%%" : "") + " %s", ItemStack.DECIMALFORMAT.format(d1), entry1.getKey().getDisplay())); } else if (d0 < 0.0D) { d1 = d1 * -1.0D; - tooltip.add(TextColor.RED + String.format("-%s" + (attributemodifier2.isMultiplied() ? "%%" : "") + " %s", ItemStack.DECIMALFORMAT.format(d1), entry1.getKey().getDisplayName())); + tooltip.add(TextColor.RED + String.format("-%s" + (attributemodifier2.isMultiplied() ? "%%" : "") + " %s", ItemStack.DECIMALFORMAT.format(d1), entry1.getKey().getDisplay())); } } } diff --git a/common/src/main/java/common/item/ItemStack.java b/common/src/main/java/common/item/ItemStack.java index 65d20aa..11bb2da 100755 --- a/common/src/main/java/common/item/ItemStack.java +++ b/common/src/main/java/common/item/ItemStack.java @@ -882,7 +882,7 @@ public final class ItemStack for(AttributeModifier mod : entry.getValue()) { double amt = mod.getAmount(); - if (mod.getID() == Attributes.ITEM_VAL_ID) + if (mod.getID() == Attributes.ITEM_DMG_ID) { amt += (double)EnchantmentHelper.getDamageModifier(this); } @@ -901,25 +901,20 @@ public final class ItemStack if(mod.isInventory() && this.size != 1) { double total = num * (double)this.size; if (amt > 0.0D) - list.add(TextColor.BLUE + String.format("+%s" + (mod.isMultiplied() ? "%%" : "") + " %s [%dx +%s" + (mod.isMultiplied() ? "%%" : "") + "]", DECIMALFORMAT.format(total), entry.getKey().getDisplayName(), this.size, DECIMALFORMAT.format(num))); + list.add(TextColor.BLUE + String.format("+%s" + (mod.isMultiplied() ? "%%" : "") + " %s [%dx +%s" + (mod.isMultiplied() ? "%%" : "") + "]", DECIMALFORMAT.format(total), entry.getKey().getDisplay(), this.size, DECIMALFORMAT.format(num))); else if (amt < 0.0D) - list.add(TextColor.RED + String.format("-%s" + (mod.isMultiplied() ? "%%" : "") + " %s [%dx -%s" + (mod.isMultiplied() ? "%%" : "") + "]", DECIMALFORMAT.format(total * -1.0), entry.getKey().getDisplayName(), this.size, DECIMALFORMAT.format(num * -1.0))); + list.add(TextColor.RED + String.format("-%s" + (mod.isMultiplied() ? "%%" : "") + " %s [%dx -%s" + (mod.isMultiplied() ? "%%" : "") + "]", DECIMALFORMAT.format(total * -1.0), entry.getKey().getDisplay(), this.size, DECIMALFORMAT.format(num * -1.0))); } else { if (amt > 0.0D) - list.add(TextColor.BLUE + String.format("+%s" + (mod.isMultiplied() ? "%%" : "") + " %s", DECIMALFORMAT.format(num), entry.getKey().getDisplayName())); + list.add(TextColor.BLUE + String.format("+%s" + (mod.isMultiplied() ? "%%" : "") + " %s", DECIMALFORMAT.format(num), entry.getKey().getDisplay())); else if (amt < 0.0D) - list.add(TextColor.RED + String.format("-%s" + (mod.isMultiplied() ? "%%" : "") + " %s", DECIMALFORMAT.format(num * -1.0), entry.getKey().getDisplayName())); + list.add(TextColor.RED + String.format("-%s" + (mod.isMultiplied() ? "%%" : "") + " %s", DECIMALFORMAT.format(num * -1.0), entry.getKey().getDisplay())); } } } } - if (this.hasTagCompound() && this.getTagCompound().getBool("Unbreakable")) // && (i1 & 4) == 0) - { - list.add(TextColor.BLUE + "Unzerstörbar"); - } - // if (this.hasTagCompound() && this.stackTagCompound.hasList("CanDestroy") && (i1 & 8) == 0) // { // NBTTagList nbttaglist2 = this.stackTagCompound.getTagList("CanDestroy", 8); diff --git a/common/src/main/java/common/item/ItemSword.java b/common/src/main/java/common/item/ItemSword.java index 43ce9a5..85d992b 100755 --- a/common/src/main/java/common/item/ItemSword.java +++ b/common/src/main/java/common/item/ItemSword.java @@ -148,7 +148,7 @@ public class ItemSword extends Item public Map> getItemAttributeModifiers() { Map> multimap = super.getItemAttributeModifiers(); - multimap.put(Attributes.ATTACK_DAMAGE, Sets.newHashSet(new AttributeModifier(Attributes.ITEM_VAL_ID, "Weapon modifier", this.attackDamage, false))); + multimap.put(Attribute.ATTACK_DAMAGE, Sets.newHashSet(new AttributeModifier(Attributes.ITEM_DMG_ID, "Weapon modifier", this.attackDamage, false))); return multimap; } diff --git a/common/src/main/java/common/item/ItemTool.java b/common/src/main/java/common/item/ItemTool.java index cd9f96a..89b658a 100755 --- a/common/src/main/java/common/item/ItemTool.java +++ b/common/src/main/java/common/item/ItemTool.java @@ -59,8 +59,8 @@ public abstract class ItemTool extends Item { public Map> getItemAttributeModifiers() { Map> mods = super.getItemAttributeModifiers(); - mods.put(Attributes.ATTACK_DAMAGE, - Sets.newHashSet(new AttributeModifier(Attributes.ITEM_VAL_ID, "Tool modifier", this.damage, false))); + mods.put(Attribute.ATTACK_DAMAGE, + Sets.newHashSet(new AttributeModifier(Attributes.ITEM_DMG_ID, "Tool modifier", this.damage, false))); return mods; } diff --git a/common/src/main/java/common/model/BlockLayer.java b/common/src/main/java/common/model/BlockLayer.java index ec9f03a..49d2d51 100755 --- a/common/src/main/java/common/model/BlockLayer.java +++ b/common/src/main/java/common/model/BlockLayer.java @@ -1,21 +1,18 @@ package common.model; -public enum BlockLayer -{ - SOLID("Solid"), - CUTOUT_MIPPED("Mipped Cutout"), - CUTOUT("Cutout"), - TRANSLUCENT("Translucent"); +public enum BlockLayer { + SOLID("Solid"), + CUTOUT_MIPPED("Mipped Cutout"), + CUTOUT("Cutout"), + TRANSLUCENT("Translucent"); - private final String layerName; + private final String name; - private BlockLayer(String layerNameIn) - { - this.layerName = layerNameIn; - } + private BlockLayer(String name) { + this.name = name; + } - public String toString() - { - return this.layerName; - } + public String toString() { + return this.name; + } } diff --git a/common/src/main/java/common/model/ItemMeshDefinition.java b/common/src/main/java/common/model/ItemMeshDefinition.java index cd7942e..354f27f 100755 --- a/common/src/main/java/common/model/ItemMeshDefinition.java +++ b/common/src/main/java/common/model/ItemMeshDefinition.java @@ -2,7 +2,6 @@ package common.model; import common.item.ItemStack; -public interface ItemMeshDefinition -{ +public interface ItemMeshDefinition { String getModelLocation(ItemStack stack); } diff --git a/common/src/main/java/common/model/Transform.java b/common/src/main/java/common/model/Transform.java index 4bb0994..7451efd 100755 --- a/common/src/main/java/common/model/Transform.java +++ b/common/src/main/java/common/model/Transform.java @@ -1,37 +1,5 @@ package common.model; -import common.util.Vector3f; - -public class Transform { - public static final Transform IDENTITY = new Transform(0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f); - - public final Vector3f rotation; - public final Vector3f translation; - public final Vector3f scale; - - public Transform(float rx, float ry, float rz, float tx, float ty, float tz, float sx, float sy, float sz) { - this.rotation = new Vector3f(rx, ry, rz); - this.translation = (Vector3f)new Vector3f(tx, ty, tz).scale(0.0625F); - this.scale = new Vector3f(sx, sy, sz); - } - - public boolean equals(Object obj) { - if(this == obj) { - return true; - } - else if(this.getClass() != obj.getClass()) { - return false; - } - else { - Transform other = (Transform)obj; - return this.rotation.equals(other.rotation) && this.scale.equals(other.scale) && this.translation.equals(other.translation); - } - } - - public int hashCode() { - int i = this.rotation.hashCode(); - i = 31 * i + this.translation.hashCode(); - i = 31 * i + this.scale.hashCode(); - return i; - } +public record Transform(float rotationX, float rotationY, float rotationZ, float translationX, float translationY, float translationZ, float scale) { + public static final Transform IDENTITY = new Transform(0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f); } diff --git a/common/src/main/java/common/model/Transforms.java b/common/src/main/java/common/model/Transforms.java index 6333c89..4ca6fee 100755 --- a/common/src/main/java/common/model/Transforms.java +++ b/common/src/main/java/common/model/Transforms.java @@ -8,122 +8,122 @@ public enum Transforms { Transform.IDENTITY ), ANVIL( - new Transform(10.0f, -45.0f, 170.0f, 0.25f, 1.5f, -2.5f, 0.375f, 0.375f, 0.375f), + transform(10.0f, -45.0f, 170.0f, 0.25f, 1.5f, -2.5f, 0.375f), Transform.IDENTITY, Transform.IDENTITY, Transform.IDENTITY ), BLOCK( - new Transform(10.0f, -45.0f, 170.0f, 0.0f, 1.5f, -2.75f, 0.375f, 0.375f, 0.375f), + transform(10.0f, -45.0f, 170.0f, 0.0f, 1.5f, -2.75f, 0.375f), Transform.IDENTITY, Transform.IDENTITY, Transform.IDENTITY ), ITEM( - new Transform(-90.0f, 0.0f, 0.0f, 0.0f, 1.0f, -3.0f, 0.55f, 0.55f, 0.55f), - new Transform(0.0f, -135.0f, 25.0f, 0.0f, 4.0f, 2.0f, 1.7f, 1.7f, 1.7f), + transform(-90.0f, 0.0f, 0.0f, 0.0f, 1.0f, -3.0f, 0.55f), + transform(0.0f, -135.0f, 25.0f, 0.0f, 4.0f, 2.0f, 1.7f), Transform.IDENTITY, Transform.IDENTITY ), TOOL_FLIP( - new Transform(180.0f, 90.0f, -35.0f, 0.0f, 0.0f, -3.5f, 0.85f, 0.85f, 0.85f), - new Transform(0.0f, 45.0f, 25.0f, 0.0f, 4.0f, 2.0f, 1.7f, 1.7f, 1.7f), + transform(180.0f, 90.0f, -35.0f, 0.0f, 0.0f, -3.5f, 0.85f), + transform(0.0f, 45.0f, 25.0f, 0.0f, 4.0f, 2.0f, 1.7f), Transform.IDENTITY, Transform.IDENTITY ), TOOL( - new Transform(0.0f, 90.0f, -35.0f, 0.0f, 1.25f, -3.5f, 0.85f, 0.85f, 0.85f), - new Transform(0.0f, -135.0f, 25.0f, 0.0f, 4.0f, 2.0f, 1.7f, 1.7f, 1.7f), + transform(0.0f, 90.0f, -35.0f, 0.0f, 1.25f, -3.5f, 0.85f), + transform(0.0f, -135.0f, 25.0f, 0.0f, 4.0f, 2.0f, 1.7f), Transform.IDENTITY, Transform.IDENTITY ), OFFSET2( - new Transform(-90.0f, 0.0f, 0.0f, 0.0f, 1.0f, -2.25f, 0.55f, 0.55f, 0.55f), - new Transform(0.0f, -135.0f, 25.0f, 0.0f, 4.0f, 2.0f, 1.7f, 1.7f, 1.7f), + transform(-90.0f, 0.0f, 0.0f, 0.0f, 1.0f, -2.25f, 0.55f), + transform(0.0f, -135.0f, 25.0f, 0.0f, 4.0f, 2.0f, 1.7f), Transform.IDENTITY, Transform.IDENTITY ), LAYER( - new Transform(10.0f, -45.0f, 170.0f, 0.0f, 0.25f, -2.75f, 0.375f, 0.375f, 0.375f), - new Transform(0.0f, 0.0f, 0.0f, 0.0f, 5.25f, 0.0f, 1.0f, 1.0f, 1.0f), + transform(10.0f, -45.0f, 170.0f, 0.0f, 0.25f, -2.75f, 0.375f), + transform(0.0f, 0.0f, 0.0f, 0.0f, 5.25f, 0.0f, 1.0f), Transform.IDENTITY, Transform.IDENTITY ), DICE( - new Transform(10.0f, -45.0f, 170.0f, 0.0f, 1.5f, -1.75f, 0.15f, 0.15f, 0.15f), - new Transform(0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.4f, 0.4f, 0.4f), - new Transform(135.0f, -55.0f, 180.0f, 0.0f, 0.0f, 0.0f, 1.1f, 1.1f, 1.1f), - new Transform(0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.4f, 0.4f, 0.4f) + transform(10.0f, -45.0f, 170.0f, 0.0f, 1.5f, -1.75f, 0.15f), + transform(0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.4f), + transform(135.0f, -55.0f, 180.0f, 0.0f, 0.0f, 0.0f, 1.1f), + transform(0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.4f) ), STAIRS( - new Transform(10.0f, -45.0f, 170.0f, 0.0f, 1.5f, -2.75f, 0.375f, 0.375f, 0.375f), + transform(10.0f, -45.0f, 170.0f, 0.0f, 1.5f, -2.75f, 0.375f), Transform.IDENTITY, - new Transform(0.0f, 180.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f), + transform(0.0f, 180.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f), Transform.IDENTITY ), OFFSET1( - new Transform(-90.0f, 0.0f, 0.0f, 0.0f, 1.0f, -2.5f, 0.55f, 0.55f, 0.55f), - new Transform(0.0f, -135.0f, 25.0f, 0.0f, 4.0f, 2.0f, 1.7f, 1.7f, 1.7f), + transform(-90.0f, 0.0f, 0.0f, 0.0f, 1.0f, -2.5f, 0.55f), + transform(0.0f, -135.0f, 25.0f, 0.0f, 4.0f, 2.0f, 1.7f), Transform.IDENTITY, Transform.IDENTITY ), GATE( - new Transform(0.0f, -90.0f, 170.0f, 0.0f, 1.5f, -2.75f, 0.375f, 0.375f, 0.375f), - new Transform(0.0f, 90.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f), + transform(0.0f, -90.0f, 170.0f, 0.0f, 1.5f, -2.75f, 0.375f), + transform(0.0f, 90.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f), Transform.IDENTITY, Transform.IDENTITY ), NUGGET( - new Transform(-90.0f, 0.0f, 0.0f, 0.0f, 1.0f, -2.0f, 0.55f, 0.55f, 0.55f), - new Transform(0.0f, -135.0f, 25.0f, 0.0f, 4.0f, 2.0f, 1.7f, 1.7f, 1.7f), + transform(-90.0f, 0.0f, 0.0f, 0.0f, 1.0f, -2.0f, 0.55f), + transform(0.0f, -135.0f, 25.0f, 0.0f, 4.0f, 2.0f, 1.7f), Transform.IDENTITY, Transform.IDENTITY ), SKULL( - new Transform(180.0f, -45.0f, 0.0f, 0.0f, 1.0f, -2.5f, 0.25f, 0.25f, 0.25f), - new Transform(0.0f, -180.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.55f, 0.55f, 0.55f), - new Transform(0.0f, 180.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.7f, 0.7f, 0.7f), + transform(180.0f, -45.0f, 0.0f, 0.0f, 1.0f, -2.5f, 0.25f), + transform(0.0f, -180.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.55f), + transform(0.0f, 180.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.7f), Transform.IDENTITY ), BUTTON( - new Transform(10.0f, -45.0f, 170.0f, 0.0f, 1.0f, -1.75f, 0.375f, 0.375f, 0.375f), + transform(10.0f, -45.0f, 170.0f, 0.0f, 1.0f, -1.75f, 0.375f), Transform.IDENTITY, Transform.IDENTITY, Transform.IDENTITY ), RANGED( - new Transform(5.0f, 80.0f, -45.0f, 0.75f, 0.0f, 0.25f, 1.0f, 1.0f, 1.0f), - new Transform(0.0f, -135.0f, 25.0f, 0.0f, 4.0f, 2.0f, 1.7f, 1.7f, 1.7f), + transform(5.0f, 80.0f, -45.0f, 0.75f, 0.0f, 0.25f, 1.0f), + transform(0.0f, -135.0f, 25.0f, 0.0f, 4.0f, 2.0f, 1.7f), Transform.IDENTITY, Transform.IDENTITY ), BANNER( - new Transform(0.0f, 90.0f, -90.0f, 0.0f, 0.0f, -4.0f, 0.5f, 0.5f, 0.5f), - new Transform(0.0f, 225.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f), - new Transform(0.0f, -65.0f, 0.0f, 0.0f, -3.0f, 0.0f, 0.85f, 0.85f, 0.85f), + transform(0.0f, 90.0f, -90.0f, 0.0f, 0.0f, -4.0f, 0.5f), + transform(0.0f, 225.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f), + transform(0.0f, -65.0f, 0.0f, 0.0f, -3.0f, 0.0f, 0.85f), Transform.IDENTITY ), FENCE( - new Transform(0.0f, 0.0f, 180.0f, 0.0f, 1.5f, -2.75f, 0.375f, 0.375f, 0.375f), + transform(0.0f, 0.0f, 180.0f, 0.0f, 1.5f, -2.75f, 0.375f), Transform.IDENTITY, - new Transform(0.0f, 90.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f), + transform(0.0f, 90.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f), Transform.IDENTITY ), FLAT( - new Transform(10.0f, -45.0f, 170.0f, 0.0f, 0.25f, -2.75f, 0.375f, 0.375f, 0.375f), - new Transform(0.0f, 0.0f, 0.0f, 0.0f, 5.0f, 0.0f, 1.0f, 1.0f, 1.0f), + transform(10.0f, -45.0f, 170.0f, 0.0f, 0.25f, -2.75f, 0.375f), + transform(0.0f, 0.0f, 0.0f, 0.0f, 5.0f, 0.0f, 1.0f), Transform.IDENTITY, Transform.IDENTITY ), ROD( - new Transform(0.0f, 90.0f, -35.0f, 0.0f, 0.75f, -3.5f, 0.85f, 0.85f, 0.85f), - new Transform(0.0f, -135.0f, 25.0f, 0.0f, 4.0f, 2.0f, 1.7f, 1.7f, 1.7f), + transform(0.0f, 90.0f, -35.0f, 0.0f, 0.75f, -3.5f, 0.85f), + transform(0.0f, -135.0f, 25.0f, 0.0f, 4.0f, 2.0f, 1.7f), Transform.IDENTITY, Transform.IDENTITY ), KEY( - new Transform(0.0f, 270.0f, -35.0f, 0.0f, 1.25f, -3.5f, 0.85f, 0.85f, 0.85f), - new Transform(180.0f, -135.0f, 25.0f, 0.0f, 4.0f, 2.0f, 1.7f, 1.7f, 1.7f), + transform(0.0f, 270.0f, -35.0f, 0.0f, 1.25f, -3.5f, 0.85f), + transform(180.0f, -135.0f, 25.0f, 0.0f, 4.0f, 2.0f, 1.7f), Transform.IDENTITY, Transform.IDENTITY ); @@ -135,6 +135,10 @@ public enum Transforms { GUI, GROUND; } + + private static Transform transform(float rx, float ry, float rz, float tx, float ty, float tz, float scale) { + return new Transform(rx, ry, rz, tx * 0.0625f, ty * 0.0625f, tz * 0.0625f, scale); + } public final Transform third; public final Transform first; diff --git a/common/src/main/java/common/packet/SPacketCharacterList.java b/common/src/main/java/common/packet/SPacketCharacterList.java index c27e226..88777b8 100644 --- a/common/src/main/java/common/packet/SPacketCharacterList.java +++ b/common/src/main/java/common/packet/SPacketCharacterList.java @@ -69,13 +69,13 @@ public class SPacketCharacterList implements Packet { buf.writeString(""); continue; } - buf.writeString(chr.name); - buf.writeString(chr.info == null ? "" : chr.info); - buf.writeEnumValue(chr.align); - buf.writeString(chr.dim); - buf.writeBlockPos(chr.pos); - buf.writeString(chr.type); - buf.writeVarInt(chr.level); + buf.writeString(chr.name()); + buf.writeString(chr.info() == null ? "" : chr.info()); + buf.writeEnumValue(chr.align()); + buf.writeString(chr.dim()); + buf.writeBlockPos(chr.pos()); + buf.writeString(chr.type()); + buf.writeVarInt(chr.level()); } buf.writeVarInt(this.selected); } diff --git a/common/src/main/java/common/packet/SPacketDisplayForm.java b/common/src/main/java/common/packet/SPacketDisplayForm.java index 5128331..7532ab5 100644 --- a/common/src/main/java/common/packet/SPacketDisplayForm.java +++ b/common/src/main/java/common/packet/SPacketDisplayForm.java @@ -62,8 +62,8 @@ public class SPacketDisplayForm implements Packet buf.writeString(this.title); buf.writeVarInt(this.data.length); for(int z = 0; z < this.data.length; z++) { - buf.writeString(this.data[z].first); - Object obj = this.data[z].second; + buf.writeString(this.data[z].first()); + Object obj = this.data[z].second(); if(obj instanceof Boolean) { buf.writeByte(0); buf.writeBoolean((Boolean)obj); @@ -80,7 +80,7 @@ public class SPacketDisplayForm implements Packet buf.writeByte(2); buf.writeString((String)obj); } - buf.writeVarInt(this.data[z].third); + buf.writeVarInt(this.data[z].third()); } } diff --git a/common/src/main/java/common/packet/SPacketEntityProperties.java b/common/src/main/java/common/packet/SPacketEntityProperties.java index 2c6c11f..cb10fa6 100755 --- a/common/src/main/java/common/packet/SPacketEntityProperties.java +++ b/common/src/main/java/common/packet/SPacketEntityProperties.java @@ -26,7 +26,7 @@ public class SPacketEntityProperties implements Packet for (AttributeInstance iattributeinstance : p_i45236_2_) { - this.field_149444_b.add(new SPacketEntityProperties.Snapshot(iattributeinstance.getAttribute().getUnlocalizedName(), iattributeinstance.getBaseValue(), iattributeinstance.getModifiers())); + this.field_149444_b.add(new SPacketEntityProperties.Snapshot(iattributeinstance.getAttribute().getName(), iattributeinstance.getBaseValue(), iattributeinstance.getModifiers())); } } diff --git a/common/src/main/java/common/packet/SPacketTrades.java b/common/src/main/java/common/packet/SPacketTrades.java index a867576..1ef9a4c 100755 --- a/common/src/main/java/common/packet/SPacketTrades.java +++ b/common/src/main/java/common/packet/SPacketTrades.java @@ -69,9 +69,9 @@ public class SPacketTrades implements Packet for (int i = 0; i < this.recipes.size(); ++i) { MerchantRecipe merchantrecipe = (MerchantRecipe)this.recipes.get(i); - buf.writeItemStack(merchantrecipe.getBuying()); - buf.writeItemStack(merchantrecipe.getSelling()); - ItemStack itemstack = merchantrecipe.getSecondBuy(); + buf.writeItemStack(merchantrecipe.first()); + buf.writeItemStack(merchantrecipe.result()); + ItemStack itemstack = merchantrecipe.second(); buf.writeBoolean(itemstack != null); if (itemstack != null) diff --git a/common/src/main/java/common/pathfinding/PathNavigate.java b/common/src/main/java/common/pathfinding/PathNavigate.java index 0d8fb09..98f9d0b 100755 --- a/common/src/main/java/common/pathfinding/PathNavigate.java +++ b/common/src/main/java/common/pathfinding/PathNavigate.java @@ -2,8 +2,8 @@ package common.pathfinding; import java.util.List; +import common.attributes.Attribute; import common.attributes.AttributeInstance; -import common.attributes.Attributes; import common.entity.Entity; import common.entity.types.EntityLiving; import common.util.BlockPos; @@ -45,7 +45,7 @@ public abstract class PathNavigate { this.theEntity = entitylivingIn; this.worldObj = worldIn; - this.pathSearchRange = entitylivingIn.getEntityAttribute(Attributes.FOLLOW_RANGE); + this.pathSearchRange = entitylivingIn.getEntityAttribute(Attribute.FOLLOW_RANGE); this.pathFinder = this.getPathFinder(); } diff --git a/common/src/main/java/common/potion/Potion.java b/common/src/main/java/common/potion/Potion.java index 68850f0..a82419a 100755 --- a/common/src/main/java/common/potion/Potion.java +++ b/common/src/main/java/common/potion/Potion.java @@ -7,7 +7,6 @@ import common.attributes.Attribute; import common.attributes.AttributeInstance; import common.attributes.AttributeMap; import common.attributes.AttributeModifier; -import common.attributes.Attributes; import common.collect.Maps; import common.entity.DamageSource; import common.entity.projectile.EntityPotion; @@ -15,15 +14,15 @@ import common.entity.types.EntityLiving; import common.init.Config; public enum Potion { - SPEED("speed", "Schnelligkeit", "Trank der Schnelligkeit", false, 8171462, new PotionModifier(Attributes.MOVEMENT_SPEED, "PotSpd", 0.2, true)), - SLOWNESS("slowness", "Langsamkeit", "Trank der Langsamkeit", true, 5926017, new PotionModifier(Attributes.MOVEMENT_SPEED, "PotSlow", -0.15, true)), + SPEED("speed", "Schnelligkeit", "Trank der Schnelligkeit", false, 8171462, new PotionModifier(Attribute.MOVEMENT_SPEED, "PotSpd", 0.2, true)), + SLOWNESS("slowness", "Langsamkeit", "Trank der Langsamkeit", true, 5926017, new PotionModifier(Attribute.MOVEMENT_SPEED, "PotSlow", -0.15, true)), HASTE("haste", "Eile", "Trank der Eile", false, 14270531) { public double getEffectiveness() { return 1.5; } }, FATIGUE("mining_fatigue", "Abbaulähmung", "Trank der Trägheit", true, 4866583), - STRENGTH("strength", "Stärke", "Trank der Stärke", false, 9643043, new PotionModifier(Attributes.ATTACK_DAMAGE, "PotDmg", 2.5, true)) { + STRENGTH("strength", "Stärke", "Trank der Stärke", false, 9643043, new PotionModifier(Attribute.ATTACK_DAMAGE, "PotDmg", 2.5, true)) { public double getAmount(int amp, AttributeModifier modifier) { return 1.3D * (double)(amp + 1); } @@ -109,8 +108,8 @@ public enum Potion { } }, NIGHT_VISION("night_vision", "Nachtsicht", "Trank der Nachtsicht", false, 2039713), - STABILITY("stability", "Stabilität", "Trank der Standfestigkeit", false, 5797459, new PotionModifier(Attributes.KNOCKBACK_RESISTANCE, "PotStbl", 1.0, false)), - WEAKNESS("weakness", "Schwäche", "Trank der Schwäche", true, 4738376, new PotionModifier(Attributes.ATTACK_DAMAGE, "PotWeak", 2.0, false)) { + STABILITY("stability", "Stabilität", "Trank der Standfestigkeit", false, 5797459, new PotionModifier(Attribute.KNOCKBACK_RESISTANCE, "PotStbl", 1.0, false)), + WEAKNESS("weakness", "Schwäche", "Trank der Schwäche", true, 4738376, new PotionModifier(Attribute.ATTACK_DAMAGE, "PotWeak", 2.0, false)) { public double getAmount(int amp, AttributeModifier modifier) { return (double)(-0.5F * (float)(amp + 1)); } @@ -126,7 +125,7 @@ public enum Potion { return 0.25; } }, - HEALTH("health_boost", "Extraenergie", "Trank der Extraenergie", false, 16284963, new PotionModifier(Attributes.MAX_HEALTH, "PotHp", 4.0, false)) { + HEALTH("health_boost", "Extraenergie", "Trank der Extraenergie", false, 16284963, new PotionModifier(Attribute.MAX_HEALTH, "PotHp", 4.0, false)) { public void removeModifiers(EntityLiving entity, AttributeMap map, int amp) { super.removeModifiers(entity, map, amp); if(entity.getHealth() > entity.getMaxHealth()) diff --git a/common/src/main/java/common/tileentity/ILockableContainer.java b/common/src/main/java/common/tileentity/ILockableContainer.java index df4cbca..f534a92 100755 --- a/common/src/main/java/common/tileentity/ILockableContainer.java +++ b/common/src/main/java/common/tileentity/ILockableContainer.java @@ -6,7 +6,7 @@ public interface ILockableContainer extends IInventory, IInteractionObject { boolean isLocked(); - void setLockCode(LockCode code); + void setLockCode(Passcode code); - LockCode getLockCode(); + Passcode getLockCode(); } diff --git a/common/src/main/java/common/tileentity/LocalBlockIntercommunication.java b/common/src/main/java/common/tileentity/LocalBlockIntercommunication.java deleted file mode 100755 index caa5a25..0000000 --- a/common/src/main/java/common/tileentity/LocalBlockIntercommunication.java +++ /dev/null @@ -1,51 +0,0 @@ -package common.tileentity; - -import common.entity.npc.EntityNPC; -import common.inventory.Container; -import common.inventory.InventoryPlayer; - -public class LocalBlockIntercommunication implements IInteractionObject -{ - private String guiID; - private String displayName; - - public LocalBlockIntercommunication(String guiIdIn, String displayNameIn) - { - this.guiID = guiIdIn; - this.displayName = displayNameIn; - } - - public Container createContainer(InventoryPlayer playerInventory, EntityNPC playerIn) - { - throw new UnsupportedOperationException(); - } - - /** - * Get the name of this object. For players this returns their username - */ - public String getName() - { - return this.displayName; - } - - /** - * Returns true if this thing is named - */ - public boolean hasCustomName() - { - return true; - } - - public String getGuiID() - { - return this.guiID; - } - - /** - * Get the formatted ChatComponent that will be used for the sender's username in chat - */ - public String getCommandName() - { - return this.displayName; - } -} diff --git a/common/src/main/java/common/tileentity/LockCode.java b/common/src/main/java/common/tileentity/LockCode.java deleted file mode 100755 index de216f4..0000000 --- a/common/src/main/java/common/tileentity/LockCode.java +++ /dev/null @@ -1,42 +0,0 @@ -package common.tileentity; - -import common.tags.TagObject; - -public class LockCode -{ - public static final LockCode EMPTY_CODE = new LockCode(""); - private final String lock; - - public LockCode(String code) - { - this.lock = code; - } - - public boolean isEmpty() - { - return this.lock == null || this.lock.isEmpty(); - } - - public String getLock() - { - return this.lock; - } - - public void toNBT(TagObject nbt) - { - nbt.setString("Lock", this.lock); - } - - public static LockCode fromNBT(TagObject nbt) - { - if (nbt.hasString("Lock")) - { - String s = nbt.getString("Lock"); - return new LockCode(s); - } - else - { - return EMPTY_CODE; - } - } -} diff --git a/common/src/main/java/common/tileentity/Passcode.java b/common/src/main/java/common/tileentity/Passcode.java new file mode 100755 index 0000000..1b3b45e --- /dev/null +++ b/common/src/main/java/common/tileentity/Passcode.java @@ -0,0 +1,19 @@ +package common.tileentity; + +import common.tags.TagObject; + +public record Passcode(String code) { + public static final Passcode EMPTY_CODE = new Passcode(""); + + public boolean empty() { + return this.code == null || this.code.isEmpty(); + } + + public void toNBT(TagObject tag) { + tag.setString("Lock", this.code); + } + + public static Passcode fromNBT(TagObject tag) { + return tag.hasString("Lock") ? new Passcode(tag.getString("Lock")) : EMPTY_CODE; + } +} diff --git a/common/src/main/java/common/tileentity/TileEntityLockable.java b/common/src/main/java/common/tileentity/TileEntityLockable.java index 2f96e8c..b6ad230 100755 --- a/common/src/main/java/common/tileentity/TileEntityLockable.java +++ b/common/src/main/java/common/tileentity/TileEntityLockable.java @@ -4,12 +4,12 @@ import common.tags.TagObject; public abstract class TileEntityLockable extends TileEntity implements IInteractionObject, ILockableContainer { - private LockCode code = LockCode.EMPTY_CODE; + private Passcode code = Passcode.EMPTY_CODE; public void readTags(TagObject compound) { super.readTags(compound); - this.code = LockCode.fromNBT(compound); + this.code = Passcode.fromNBT(compound); } public void writeTags(TagObject compound) @@ -24,15 +24,15 @@ public abstract class TileEntityLockable extends TileEntity implements IInteract public boolean isLocked() { - return this.code != null && !this.code.isEmpty(); + return this.code != null && !this.code.empty(); } - public LockCode getLockCode() + public Passcode getLockCode() { return this.code; } - public void setLockCode(LockCode code) + public void setLockCode(Passcode code) { this.code = code; } diff --git a/common/src/main/java/common/util/EncryptUtil.java b/common/src/main/java/common/util/EncryptUtil.java index 9d0e0d2..f721ebf 100644 --- a/common/src/main/java/common/util/EncryptUtil.java +++ b/common/src/main/java/common/util/EncryptUtil.java @@ -148,7 +148,7 @@ public class EncryptUtil { return cn == null || cn.isEmpty() ? sb.toString() : sb.append(' ').append(Util.sanitizeCommonName(cn)).toString(); } - public static Tuple parseArmoredPubkey(String armor) throws IllegalArgumentException { + public static Pair parseArmoredPubkey(String armor) throws IllegalArgumentException { String[] tok = armor.trim().split(" "); if(tok.length != 3 && tok.length != 4) throw new IllegalArgumentException("Key muss aus 3 oder 4 Segmenten bestehen"); @@ -184,7 +184,7 @@ public class EncryptUtil { } if(tok.length == 4 && !Util.isValidCommonName(tok[3])) throw new IllegalArgumentException("Name muss aus 'a-z' '0-9' und '-' bestehen, kann keine aufeinander folgenden Bindestriche haben und darf nicht damit beginnen oder darin enden"); - return new Tuple(pubkey, tok.length == 4 ? tok[3] : null); + return new Pair(pubkey, tok.length == 4 ? tok[3] : null); } private static final long CRC24_INIT = 0xB704CEL; diff --git a/common/src/main/java/common/util/Pair.java b/common/src/main/java/common/util/Pair.java new file mode 100644 index 0000000..3ac253e --- /dev/null +++ b/common/src/main/java/common/util/Pair.java @@ -0,0 +1,4 @@ +package common.util; + +public record Pair(A first, B second) { +} diff --git a/common/src/main/java/common/util/Position.java b/common/src/main/java/common/util/Position.java index 8d7aa6c..ac29267 100755 --- a/common/src/main/java/common/util/Position.java +++ b/common/src/main/java/common/util/Position.java @@ -1,19 +1,4 @@ package common.util; -public class Position { - public final double x; - public final double y; - public final double z; - public final float yaw; - public final float pitch; - public final int dim; - - public Position(double x, double y, double z, float yaw, float pitch, int dim) { - this.x = x; - this.y = y; - this.z = z; - this.yaw = yaw; - this.pitch = pitch; - this.dim = dim; - } +public record Position(double x, double y, double z, float yaw, float pitch, int dim) { } diff --git a/common/src/main/java/common/util/Triplet.java b/common/src/main/java/common/util/Triplet.java index 6029985..ded6065 100644 --- a/common/src/main/java/common/util/Triplet.java +++ b/common/src/main/java/common/util/Triplet.java @@ -1,10 +1,4 @@ package common.util; -public class Triplet extends Tuple { - public final U third; - - public Triplet(S first, T second, U third) { - super(first, second); - this.third = third; - } +public record Triplet(A first, B second, C third) { } diff --git a/common/src/main/java/common/util/Tuple.java b/common/src/main/java/common/util/Tuple.java deleted file mode 100644 index 20a5a73..0000000 --- a/common/src/main/java/common/util/Tuple.java +++ /dev/null @@ -1,11 +0,0 @@ -package common.util; - -public class Tuple { - public final S first; - public final T second; - - public Tuple(S first, T second) { - this.first = first; - this.second = second; - } -} diff --git a/common/src/main/java/common/util/Util.java b/common/src/main/java/common/util/Util.java index 1c7920d..47501f7 100644 --- a/common/src/main/java/common/util/Util.java +++ b/common/src/main/java/common/util/Util.java @@ -338,14 +338,14 @@ int utf_len(const char *str) { } } - public static Tuple getKeyValue(String text, char separator) { + public static Pair getKeyValue(String text, char separator) { int index = text.indexOf(separator); if(index == -1) - return new Tuple(text, null); - return new Tuple(text.substring(0, index), text.substring(index + 1)); + return new Pair(text, null); + return new Pair(text.substring(0, index), text.substring(index + 1)); } - public static Tuple getKeyValue(String text) { + public static Pair getKeyValue(String text) { return getKeyValue(text, ' '); } diff --git a/common/src/main/java/common/util/Vector3f.java b/common/src/main/java/common/util/Vector3f.java index cab132d..5416ce5 100644 --- a/common/src/main/java/common/util/Vector3f.java +++ b/common/src/main/java/common/util/Vector3f.java @@ -252,7 +252,7 @@ public class Vector3f extends Vector implements Serializable { /* (non-Javadoc) * @see org.lwjgl.vector.Vector#load(FloatBuffer) */ - public Vector load(FloatBuffer buf) { + public Vector3f load(FloatBuffer buf) { x = buf.get(); y = buf.get(); z = buf.get(); @@ -262,7 +262,7 @@ public class Vector3f extends Vector implements Serializable { /* (non-Javadoc) * @see org.lwjgl.vector.Vector#scale(float) */ - public Vector scale(float scale) { + public Vector3f scale(float scale) { x *= scale; y *= scale; @@ -275,7 +275,7 @@ public class Vector3f extends Vector implements Serializable { /* (non-Javadoc) * @see org.lwjgl.vector.Vector#store(FloatBuffer) */ - public Vector store(FloatBuffer buf) { + public Vector3f store(FloatBuffer buf) { buf.put(x); buf.put(y); diff --git a/common/src/main/java/common/village/MerchantRecipe.java b/common/src/main/java/common/village/MerchantRecipe.java index f94e631..f21db8e 100755 --- a/common/src/main/java/common/village/MerchantRecipe.java +++ b/common/src/main/java/common/village/MerchantRecipe.java @@ -4,21 +4,9 @@ import common.item.Item; import common.item.ItemStack; import common.tags.TagObject; -public class MerchantRecipe { - private final ItemStack buying; - private final ItemStack buySecond; - private final ItemStack selling; - +public record MerchantRecipe(ItemStack first, ItemStack second, ItemStack result) { public MerchantRecipe(TagObject tag) { - this.buying = ItemStack.readFromTag(tag.getObject("buy")); - this.selling = ItemStack.readFromTag(tag.getObject("sell")); - this.buySecond = tag.hasObject("buyB") ? ItemStack.readFromTag(tag.getObject("buyB")) : null; - } - - public MerchantRecipe(ItemStack buy1, ItemStack buy2, ItemStack sell) { - this.buying = buy1; - this.buySecond = buy2; - this.selling = sell; + this(ItemStack.readFromTag(tag.getObject("buy")), tag.hasObject("buyB") ? ItemStack.readFromTag(tag.getObject("buyB")) : null, ItemStack.readFromTag(tag.getObject("sell"))); } public MerchantRecipe(ItemStack buy, ItemStack sell) { @@ -29,28 +17,16 @@ public class MerchantRecipe { this(buy, new ItemStack(sell)); } - public ItemStack getBuying() { - return this.buying; - } - - public ItemStack getSecondBuy() { - return this.buySecond; - } - - public boolean hasSecondBuy() { - return this.buySecond != null; - } - - public ItemStack getSelling() { - return this.selling; + public boolean both() { + return this.second != null; } public TagObject toTags() { TagObject tag = new TagObject(); - tag.setObject("buy", this.buying.writeTags(new TagObject())); - tag.setObject("sell", this.selling.writeTags(new TagObject())); - if(this.buySecond != null) - tag.setObject("buyB", this.buySecond.writeTags(new TagObject())); + tag.setObject("buy", this.first.writeTags(new TagObject())); + tag.setObject("sell", this.result.writeTags(new TagObject())); + if(this.second != null) + tag.setObject("buyB", this.second.writeTags(new TagObject())); return tag; } } diff --git a/common/src/main/java/common/village/MerchantRecipeList.java b/common/src/main/java/common/village/MerchantRecipeList.java index 4cd0bc4..f430552 100755 --- a/common/src/main/java/common/village/MerchantRecipeList.java +++ b/common/src/main/java/common/village/MerchantRecipeList.java @@ -11,19 +11,19 @@ public class MerchantRecipeList extends ArrayList { public MerchantRecipe canUse(ItemStack stack1, ItemStack stack2, int index) { if(index > 0 && index < this.size()) { MerchantRecipe recipe = this.get(index); - return !areItemsSimilar(stack1, recipe.getBuying()) - || (stack2 != null || recipe.hasSecondBuy()) - && (!recipe.hasSecondBuy() || !areItemsSimilar(stack2, recipe.getSecondBuy())) - || stack1.size < recipe.getBuying().size - || recipe.hasSecondBuy() && stack2.size < recipe.getSecondBuy().size ? null : recipe; + return !areItemsSimilar(stack1, recipe.first()) + || (stack2 != null || recipe.both()) + && (!recipe.both() || !areItemsSimilar(stack2, recipe.second())) + || stack1.size < recipe.first().size + || recipe.both() && stack2.size < recipe.second().size ? null : recipe; } else { for(int z = 0; z < this.size(); z++) { MerchantRecipe recipe = this.get(z); - if(areItemsSimilar(stack1, recipe.getBuying()) && stack1.size >= recipe.getBuying().size - && (!recipe.hasSecondBuy() && stack2 == null - || recipe.hasSecondBuy() && areItemsSimilar(stack2, recipe.getSecondBuy()) - && stack2.size >= recipe.getSecondBuy().size)) { + if(areItemsSimilar(stack1, recipe.first()) && stack1.size >= recipe.first().size + && (!recipe.both() && stack2 == null + || recipe.both() && areItemsSimilar(stack2, recipe.second()) + && stack2.size >= recipe.second().size)) { return recipe; } } diff --git a/server/src/main/java/server/Server.java b/server/src/main/java/server/Server.java index 2779040..4e719f1 100755 --- a/server/src/main/java/server/Server.java +++ b/server/src/main/java/server/Server.java @@ -1043,7 +1043,7 @@ public final class Server implements IThreadListener { } else { Position rpos = this.getRandomSpawnPosition(origin); - nplayer.setLocationAndAngles(rpos.x, rpos.y, rpos.z, rpos.yaw, rpos.pitch); + nplayer.setLocationAndAngles(rpos.x(), rpos.y(), rpos.z(), rpos.yaw(), rpos.pitch()); // this.movePlayerToSpawn(nplayer); } world.loadChunk((int)nplayer.posX >> 4, (int)nplayer.posZ >> 4); diff --git a/server/src/main/java/server/command/Argument.java b/server/src/main/java/server/command/Argument.java index 9863e7c..d933fd0 100644 --- a/server/src/main/java/server/command/Argument.java +++ b/server/src/main/java/server/command/Argument.java @@ -2,32 +2,5 @@ package server.command; import java.util.Map; -public class Argument { - private final Parameter parameter; - private final int position; - private final String[] inputs; - private final Map values; - - public Argument(Parameter parameter, int position, String[] inputs, Map values) { - this.parameter = parameter; - this.position = position; - this.inputs = inputs; - this.values = values; - } - - public Parameter getParameter() { - return this.parameter; - } - - public int getPosition() { - return this.position; - } - - public String[] getInputs() { - return this.inputs; - } - - public Map getValues() { - return this.values; - } +public record Argument(Parameter parameter, int position, String[] inputs, Map values) { } diff --git a/server/src/main/java/server/command/ArgumentSplitter.java b/server/src/main/java/server/command/ArgumentSplitter.java index 9d12adc..1028b29 100644 --- a/server/src/main/java/server/command/ArgumentSplitter.java +++ b/server/src/main/java/server/command/ArgumentSplitter.java @@ -30,8 +30,8 @@ public class ArgumentSplitter { } public static ArgumentSplitter parseArgs(CommandEnvironment env, String str, String[] argv, CachedExecutable cached) { - Map parameters = cached.getParameters(); - List positionals = Lists.newArrayList(cached.getPositionals()); + Map parameters = cached.parameters(); + List positionals = Lists.newArrayList(cached.positionals()); // String[] argv = ArgumentParser.splitString(str); Map args = Maps.newHashMap(); int ppos = 0; @@ -46,7 +46,7 @@ public class ArgumentSplitter { } else if(parse && (arg.startsWith("--") || (arg.startsWith("-") && arg.length() == 2))) { param = parameters.get(arg.substring(arg.startsWith("--") ? 2 : 1)); - if(param != null && param.isPositional() && !args.containsKey(param.getName())) { + if(param != null && param.positional() && !args.containsKey(param.name())) { for(int n = 0; n < positionals.size(); n++) { if(param == positionals.get(n)) { positionals.remove(n); @@ -64,71 +64,71 @@ public class ArgumentSplitter { } if(param == null) throw new RunException("Position %d: Argument '%s' ist unbekannt", z, arg); - if(args.containsKey(param.getName())) - throw new RunException("Position %d: Parameter '%s' mehrfach angegeben", z, param.getName()); - int nargs = param.getParsers().size(); + if(args.containsKey(param.name())) + throw new RunException("Position %d: Parameter '%s' mehrfach angegeben", z, param.name()); + int nargs = param.parsers().size(); // if(!pos) // z += 1; if(z + (pos ? 0 : 1) + nargs > argv.length) - if(nargs == 1 && param.getName().equals(param.getParsers().get(0).getName())) - throw new RunException("Position %d: Argument '%s' benötigt einen Parameter", z, param.getName()); + if(nargs == 1 && param.name().equals(param.parsers().get(0).getName())) + throw new RunException("Position %d: Argument '%s' benötigt einen Parameter", z, param.name()); else - throw new RunException("Position %d: Argument '%s' benötigt %d Parameter (%s)", z, param.getName(), nargs, - joinArgs(param.getParsers())); + throw new RunException("Position %d: Argument '%s' benötigt %d Parameter (%s)", z, param.name(), nargs, + joinArgs(param.parsers())); Map params = Maps.newHashMapWithExpectedSize(nargs); String[] inputs = new String[nargs + (pos ? 0 : 1)]; int apos = 0; for(int n = pos ? 0 : 1; n < nargs + (pos ? 0 : 1); n++) { String par = inputs[n] = argv[z + n]; - ArgumentParser parser = param.getParsers().get(apos); + ArgumentParser parser = param.parsers().get(apos); if(parse && (par.startsWith("--") || (par.startsWith("-") && par.length() == 2))) - if(nargs == 1 && param.getName().equals(parser.getName())) - throw new RunException("Position %d: Argument '%s': '%s' als Parameter verwendet", z + n, param.getName(), par); + if(nargs == 1 && param.name().equals(parser.getName())) + throw new RunException("Position %d: Argument '%s': '%s' als Parameter verwendet", z + n, param.name(), par); else throw new RunException("Position %d: Argument '%s': '%s' als Parameter '%s' (#%d) verwendet", z + n, - param.getName(), par, parser.getName(), apos + 1); + param.name(), par, parser.getName(), apos + 1); try { params.put(parser.getName(), parser.parse(env, par)); } catch(Throwable e) { - if(nargs == 1 && param.getName().equals(parser.getName())) + if(nargs == 1 && param.name().equals(parser.getName())) throw new RunException(e, "Position %d: Argument '%s': Parameter konnte nicht interpretiert werden", z + n, - param.getName()); + param.name()); else throw new RunException(e, "Position %d: Argument '%s': Parameter '%s' (#%d) konnte nicht interpretiert werden", z + n, - param.getName(), parser.getName(), apos + 1); + param.name(), parser.getName(), apos + 1); } apos += 1; } if(!pos) inputs[0] = arg; - args.put(param.getName(), new Argument(param, z, inputs, params)); + args.put(param.name(), new Argument(param, z, inputs, params)); z += nargs - (pos ? 1 : 0); } for(Parameter param : parameters.values()) { - if(!args.containsKey(param.getName())) { - if(param.isRequired()) { - for(ArgumentParser parser : param.getParsers()) { + if(!args.containsKey(param.name())) { + if(param.required()) { + for(ArgumentParser parser : param.parsers()) { if(parser.getDefault(env) == null) - throw new RunException("Argument '%s' muss angegeben werden", param.getName()); + throw new RunException("Argument '%s' muss angegeben werden", param.name()); } } - else if(param.getParsers().isEmpty()) { + else if(param.parsers().isEmpty()) { continue; } - Map params = Maps.newHashMapWithExpectedSize(param.getParsers().size()); - for(ArgumentParser parser : param.getParsers()) { + Map params = Maps.newHashMapWithExpectedSize(param.parsers().size()); + for(ArgumentParser parser : param.parsers()) { params.put(parser.getName(), parser.getDefault(env)); } - args.put(param.getName(), new Argument(param, -1, null, params)); + args.put(param.name(), new Argument(param, -1, null, params)); } } return new ArgumentSplitter(args, str, env); } private static Iterable getParam(CommandEnvironment env, String[] argv, CachedExecutable cached) { - Map parameters = cached.getParameters(); - List positionals = Lists.newArrayList(cached.getPositionals()); + Map parameters = cached.parameters(); + List positionals = Lists.newArrayList(cached.positionals()); Set args = Sets.newHashSet(); int ppos = 0; boolean parse = true; @@ -139,9 +139,9 @@ public class ArgumentSplitter { if(z == argv.length - 1) { if(ppos < positionals.size()) { param = positionals.get(ppos); - if(param.getParsers().isEmpty()) // np + if(param.parsers().isEmpty()) // np return null; - return param.getParsers().get(0).getCompletions(env); + return param.parsers().get(0).getCompletions(env); } else { return null; @@ -153,7 +153,7 @@ public class ArgumentSplitter { } else if(parse && (arg.startsWith("--") || (arg.startsWith("-") && arg.length() == 2))) { param = parameters.get(arg.substring(arg.startsWith("--") ? 2 : 1)); - if(param != null && param.isPositional() && !args.contains(param.getName())) { + if(param != null && param.positional() && !args.contains(param.name())) { for(int n = 0; n < positionals.size(); n++) { if(param == positionals.get(n)) { positionals.remove(n); @@ -169,22 +169,22 @@ public class ArgumentSplitter { else { return null; } - if(param == null || args.contains(param.getName())) + if(param == null || args.contains(param.name())) return null; - int nargs = param.getParsers().size(); + int nargs = param.parsers().size(); // if(z + (pos ? 0 : 1) + nargs > argv.length - 1) { // return param.getParsers().get(argv.length - z).getCompletions(env); // } int apos = 0; for(int n = pos ? 0 : 1; n < nargs + (pos ? 0 : 1); n++) { if(z + n == argv.length - 1) - return param.getParsers().get(apos).getCompletions(env); + return param.parsers().get(apos).getCompletions(env); String par = argv[z + n]; if(parse && (par.startsWith("--") || (par.startsWith("-") && par.length() == 2))) return null; apos += 1; } - args.add(param.getName()); + args.add(param.name()); z += nargs - (pos ? 1 : 0); } return null; @@ -195,7 +195,7 @@ public class ArgumentSplitter { if(comp == null /* || comp.length == 0 */ ) { Set params = Sets.newTreeSet(); boolean all = last.startsWith("--"); - for(String param : cached.getParameters().keySet()) { + for(String param : cached.parameters().keySet()) { if(all || param.length() == 1) params.add(param.length() == 1 ? "-" + param : ("--" + param)); } @@ -204,43 +204,15 @@ public class ArgumentSplitter { return comp; } -// public ScriptArg getArg(String name) { -// return this.arguments.get(name); -// } - - public boolean hasArg(String name) { + public boolean has(String name) { return this.arguments.containsKey(name); } -// public boolean has(String name, String par) { -// return this.arguments.containsKey(name) && this.arguments.get(name).getValues().containsKey(par); -// } - -// public boolean has(String name) { -// return this.has(name, name); -// } - -// public T getDefault(String name, String par, T def) { -// ScriptArg arg = this.arguments.get(name); -// if(arg == null) -// return def; -// Object value = arg.getValues().get(par); -// return value == null ? def : (T)value; -// } -// -// public T getDefault(String name, T def) { -// return this.getDefault(name, name, def); -// } -// -// public T getUnchecked(String name, String par) { -// return this.getDefault(name, par, null); -// } - - public T getUnchecked(String name, String par) { + public T get(String name, String par) { Argument arg = this.arguments.get(name); if(arg == null) return null; - Object value = arg.getValues().get(par); + Object value = arg.values().get(par); return value == null ? null : (T)value; } } diff --git a/server/src/main/java/server/command/CachedExecutable.java b/server/src/main/java/server/command/CachedExecutable.java index 97344af..031ecfe 100644 --- a/server/src/main/java/server/command/CachedExecutable.java +++ b/server/src/main/java/server/command/CachedExecutable.java @@ -7,21 +7,7 @@ import java.util.Map; import common.collect.Lists; import common.collect.Maps; -public class CachedExecutable { - private final Executable executable; - private final String name; - private final Map parameters; - private final List positionals; - private final Method method; - - protected CachedExecutable(Executable executable, Map parameters, List positionals, Method method) { - this.executable = executable; - this.parameters = parameters; - this.positionals = positionals; - this.name = executable.getName(); - this.method = method; - } - +public record CachedExecutable(Executable executable, Map parameters, List positionals, Method method) { public static CachedExecutable cacheExecutable(Executable executable) { Map parameters = Maps.newTreeMap(); Map params = executable.getParameters(); @@ -29,12 +15,12 @@ public class CachedExecutable { Parameter[] positions = new Parameter[parameters.size()]; int pos = -1; for(Parameter param : params.values()) { - if(param.isPositional()) { - positions[param.getPosition()] = param; - pos = param.getPosition() > pos ? param.getPosition() : pos; + if(param.positional()) { + positions[param.position()] = param; + pos = param.position() > pos ? param.position() : pos; } - if(param.hasShortName()) - parameters.put("" + param.getShortName(), param); + if(param.shorthand()) + parameters.put("" + param.shortName(), param); } List positionals = Lists.newArrayList(); for(int z = 0; z <= pos; z++) { @@ -44,17 +30,17 @@ public class CachedExecutable { } List> classes = Lists.newArrayList(CommandEnvironment.class, Executor.class); for(Parameter param : executable.getParamList()) { - ArgCombiner combiner = param.getCombiner(); + ArgCombiner combiner = param.combiner(); if(combiner != null) { classes.add(combiner.getTypeClass()); continue; } - if(param.getParsers().isEmpty()) { + if(param.parsers().isEmpty()) { classes.add(boolean.class); continue; } - for(ArgumentParser parser : param.getParsers()) { - classes.add(parser.getTypeClass(param.isRequired())); + for(ArgumentParser parser : param.parsers()) { + classes.add(parser.getTypeClass(param.required())); } } Method method; @@ -67,27 +53,11 @@ public class CachedExecutable { return new CachedExecutable(executable, parameters, positionals, method); } - public Executable getExecutable() { - return this.executable; - } - - public Method getMethod() { - return this.method; - } - - public Map getParameters() { - return this.parameters; - } - - public List getPositionals() { - return this.positionals; - } - - public String getName() { - return this.name; + public String name() { + return this.executable.getName(); } public String toString() { - return this.name; + return this.executable.getName(); } } diff --git a/server/src/main/java/server/command/CommandEnvironment.java b/server/src/main/java/server/command/CommandEnvironment.java index 1d6fa90..dcb7faa 100644 --- a/server/src/main/java/server/command/CommandEnvironment.java +++ b/server/src/main/java/server/command/CommandEnvironment.java @@ -6,6 +6,7 @@ import java.util.List; import java.util.Map; import java.util.Set; import java.util.function.Function; +import java.util.regex.Pattern; import common.collect.Lists; import common.collect.Maps; @@ -55,10 +56,10 @@ public class CommandEnvironment { public void registerExecutable(Executable executable) { CachedExecutable cached = CachedExecutable.cacheExecutable(executable); - if(this.executables.containsKey(cached.getName())) - throw new IllegalStateException("Befehl " + cached.getName() + " ist bereits registriert"); - this.executables.put(cached.getName(), cached); - this.registerReplacer(cached.getName(), new Function() { + if(this.executables.containsKey(cached.name())) + throw new IllegalStateException("Befehl " + cached.name() + " ist bereits registriert"); + this.executables.put(cached.name(), cached); + this.registerReplacer(cached.name(), new Function() { public String apply(String str) { Object o; try { @@ -77,14 +78,14 @@ public class CommandEnvironment { public void registerReplacer(String var, Function function) { if(this.builtins.contains(var)) throw new IllegalStateException("Variable " + var + " ist bereits registriert"); - this.replacers.add(new PatternReplacer(var, true, function)); + this.replacers.add(new PatternReplacer(Pattern.compile("\\$\\((" + Pattern.quote(var) + "[^\\)]*)\\)"), function)); this.builtins.add(var); } public void registerVariable(String var, Variable variable) { if(this.builtins.contains(var)) throw new IllegalStateException("Variable " + var + " ist bereits registriert"); - this.replacers.add(new PatternReplacer(var, false, new Function() { + this.replacers.add(new PatternReplacer(Pattern.compile("\\$\\((" + Pattern.quote(var) + ")\\)"), new Function() { public String apply(String ign) { return variable.get(); } @@ -107,7 +108,7 @@ public class CommandEnvironment { private String substitute(String str) { StringBuffer sb = new StringBuffer(str); for(PatternReplacer replacer : this.replacers) { - replacer.replaceVar(sb); + replacer.replace(sb); } return sb.toString(); } @@ -137,12 +138,12 @@ public class CommandEnvironment { } ArgumentSplitter args = ArgumentSplitter.parseArgs(this, cmd, argv, cached); List params = Lists.newArrayList(this, this.currentExecutor); - for(Parameter param : cached.getExecutable().getParamList()) { - ArgCombiner combiner = param.getCombiner(); + for(Parameter param : cached.executable().getParamList()) { + ArgCombiner combiner = param.combiner(); if(combiner != null) { - Object[] data = (Object[])Array.newInstance(combiner.getInputClass(), param.getParsers().size()); + Object[] data = (Object[])Array.newInstance(combiner.getInputClass(), param.parsers().size()); for(int z = 0; z < data.length; z++) { - data[z] = args.getUnchecked(param.getName(), param.getParsers().get(z).getName()); + data[z] = args.get(param.name(), param.parsers().get(z).getName()); if(data[z] == null) { data = null; break; @@ -151,16 +152,16 @@ public class CommandEnvironment { params.add(data == null ? null : combiner.combine(data)); continue; } - if(param.getParsers().isEmpty()) { - params.add(args.hasArg(param.getName())); + if(param.parsers().isEmpty()) { + params.add(args.has(param.name())); continue; } - for(ArgumentParser parser : param.getParsers()) { - params.add(args.getUnchecked(param.getName(), parser.getName())); + for(ArgumentParser parser : param.parsers()) { + params.add(args.get(param.name(), parser.getName())); } } try { - o = cached.getMethod().invoke(cached.getExecutable(), params.toArray(new Object[params.size()])); + o = cached.method().invoke(cached.executable(), params.toArray(new Object[params.size()])); } catch(InvocationTargetException e) { if(e.getCause() instanceof RuntimeException) diff --git a/server/src/main/java/server/command/DimensionParser.java b/server/src/main/java/server/command/DimensionParser.java index 6263114..f941da9 100644 --- a/server/src/main/java/server/command/DimensionParser.java +++ b/server/src/main/java/server/command/DimensionParser.java @@ -34,7 +34,7 @@ public class DimensionParser extends CompletingParser { if(!this.useSender) return null; Position pos = env.getExecutor().getExecPos(); - return pos == null ? null : UniverseRegistry.getDimension(pos.dim); + return pos == null ? null : UniverseRegistry.getDimension(pos.dim()); // if(dim == null) // throw new ScriptException("Unbekannte Dimension '%s'"); } diff --git a/server/src/main/java/server/command/DoubleParser.java b/server/src/main/java/server/command/DoubleParser.java index 2256de2..93a5a5c 100644 --- a/server/src/main/java/server/command/DoubleParser.java +++ b/server/src/main/java/server/command/DoubleParser.java @@ -69,15 +69,15 @@ public class DoubleParser extends DefaultingParser { if(this.defType != null) switch(this.defType) { case X: - return pos == null ? null : pos.x; + return pos == null ? null : pos.x(); case Y: - return pos == null ? null : pos.y; + return pos == null ? null : pos.y(); case Z: - return pos == null ? null : pos.z; + return pos == null ? null : pos.z(); case YAW: - return pos == null ? null : (double)pos.yaw; + return pos == null ? null : (double)pos.yaw(); case PITCH: - return pos == null ? null : (double)pos.pitch; + return pos == null ? null : (double)pos.pitch(); } return (Double)super.getDefault(env); } diff --git a/server/src/main/java/server/command/Executable.java b/server/src/main/java/server/command/Executable.java index 1912915..ea60bdb 100644 --- a/server/src/main/java/server/command/Executable.java +++ b/server/src/main/java/server/command/Executable.java @@ -4,7 +4,6 @@ import java.util.List; import java.util.Map; public interface Executable { -// Object exec(ScriptEnvironment env, ScriptArgs args); Map getParameters(); List getParamList(); String getName(); diff --git a/server/src/main/java/server/command/FixedExecutor.java b/server/src/main/java/server/command/FixedExecutor.java index 54d8eb8..79a87da 100644 --- a/server/src/main/java/server/command/FixedExecutor.java +++ b/server/src/main/java/server/command/FixedExecutor.java @@ -5,44 +5,11 @@ import common.util.BlockPos; import common.util.Position; import server.Server; -public class FixedExecutor implements Executor { - private final Server server; - private final String id; - - private String name; - private Position position; - - public FixedExecutor(Server server, String id, String name, Position pos) { - this.server = server; - this.id = id; - this.name = name; - this.position = pos; - } - - public void setName(String name) { - this.name = name; - } - - public void setPosition(Position pos) { - this.position = pos; - } - +public record FixedExecutor(Server server, String getExecId, String getExecName, Position getExecPos) implements Executor { public void logConsole(String msg) { this.server.logConsole(msg); } - public String getExecId() { - return this.id; - } - - public String getExecName() { - return this.name; - } - - public Position getExecPos() { - return this.position; - } - public Entity getPointedEntity() { return null; } diff --git a/server/src/main/java/server/command/IntParser.java b/server/src/main/java/server/command/IntParser.java index 23da522..6db6b7e 100644 --- a/server/src/main/java/server/command/IntParser.java +++ b/server/src/main/java/server/command/IntParser.java @@ -68,11 +68,11 @@ public class IntParser extends DefaultingParser { if(this.defType != null) switch(this.defType) { case X: - return pos == null ? null : ExtMath.floord(pos.x); + return pos == null ? null : ExtMath.floord(pos.x()); case Y: - return pos == null ? null : ExtMath.floord(pos.y); + return pos == null ? null : ExtMath.floord(pos.y()); case Z: - return pos == null ? null : ExtMath.floord(pos.z); + return pos == null ? null : ExtMath.floord(pos.z()); } return (Integer)super.getDefault(env); } diff --git a/server/src/main/java/server/command/Parameter.java b/server/src/main/java/server/command/Parameter.java index a61a828..5302dc5 100644 --- a/server/src/main/java/server/command/Parameter.java +++ b/server/src/main/java/server/command/Parameter.java @@ -2,52 +2,12 @@ package server.command; import java.util.List; -public class Parameter { - private final String name; - private final char shortName; - private final boolean required; - private final int position; - private final List parsers; - private final ArgCombiner combiner; - - public Parameter(String name, char shortName, int position, boolean required, List parsers, ArgCombiner combiner) { - this.name = name; - this.shortName = shortName; - this.position = position; - this.required = required; - this.parsers = parsers; - this.combiner = combiner; - } - - public boolean isPositional() { +public record Parameter(String name, char shortName, int position, boolean required, List parsers, ArgCombiner combiner) { + public boolean positional() { return this.position >= 0; } - public int getPosition() { - return this.position; - } - - public List getParsers() { - return this.parsers; - } - - public ArgCombiner getCombiner() { - return this.combiner; - } - - public boolean isRequired() { - return this.required; - } - - public String getName() { - return this.name; - } - - public boolean hasShortName() { + public boolean shorthand() { return this.shortName != 0; - } - - public char getShortName() { - return this.shortName; - } + } } diff --git a/server/src/main/java/server/command/PatternReplacer.java b/server/src/main/java/server/command/PatternReplacer.java index 685c94f..d209177 100644 --- a/server/src/main/java/server/command/PatternReplacer.java +++ b/server/src/main/java/server/command/PatternReplacer.java @@ -4,20 +4,8 @@ import java.util.function.Function; import java.util.regex.Matcher; import java.util.regex.Pattern; -public class PatternReplacer { - private final String variable; - private final boolean matchAll; - private final Pattern pattern; - private final Function function; - - public PatternReplacer(String variable, boolean matchAll, Function function) { - this.variable = variable; - this.matchAll = matchAll; - this.pattern = Pattern.compile("\\$\\((" + Pattern.quote(variable) + (matchAll ? "[^\\)]*" : "") + ")\\)"); - this.function = function; - } - - public void replaceVar(StringBuffer sb) { +public record PatternReplacer(Pattern pattern, Function function) { + public void replace(StringBuffer sb) { String str = sb.toString(); sb.delete(0, sb.length()); Matcher matcher = this.pattern.matcher(str); @@ -30,20 +18,4 @@ public class PatternReplacer { } matcher.appendTail(sb); } - - public String getVariable() { - return this.variable; - } - - public boolean matchesAll() { - return this.matchAll; - } - - public Pattern getPattern() { - return this.pattern; - } - - public Function getFunction() { - return this.function; - } } diff --git a/server/src/main/java/server/command/commands/CommandHelp.java b/server/src/main/java/server/command/commands/CommandHelp.java index f5df1b8..21b9db6 100644 --- a/server/src/main/java/server/command/commands/CommandHelp.java +++ b/server/src/main/java/server/command/commands/CommandHelp.java @@ -29,27 +29,27 @@ public class CommandHelp extends Command { return; } List list = Lists.newArrayList(); - for(Entry entry : command.getParameters().entrySet()) { + for(Entry entry : command.parameters().entrySet()) { Parameter param = entry.getValue(); - if(entry.getKey().length() == 1 && !param.isPositional() && param.hasShortName()) { - list.add("-" + param.getShortName() + (param.getParsers().isEmpty() ? " (" + param.getName() + ")" : (param.getParsers().size() == 1 && - param.getParsers().get(0).getName().equals(param.getName()) ? " <" + param.getName() + ">" : - " (" + param.getName() + ")" + Util.buildLines(" ", new Function() { + if(entry.getKey().length() == 1 && !param.positional() && param.shorthand()) { + list.add("-" + param.shortName() + (param.parsers().isEmpty() ? " (" + param.name() + ")" : (param.parsers().size() == 1 && + param.parsers().get(0).getName().equals(param.name()) ? " <" + param.name() + ">" : + " (" + param.name() + ")" + Util.buildLines(" ", new Function() { public String apply(ArgumentParser parser) { return "<" + parser.getName() + ">"; } - }, param.getParsers())))); + }, param.parsers())))); } } - for(Parameter param : command.getPositionals()) { - list.add((param.isRequired() ? "<" : "[") + (param.getParsers().size() == 1 && - param.getParsers().get(0).getName().equals(param.getName()) ? param.getName() : - "(" + param.getName() + ") " + Util.buildLines(" ", new Function() { + for(Parameter param : command.positionals()) { + list.add((param.required() ? "<" : "[") + (param.parsers().size() == 1 && + param.parsers().get(0).getName().equals(param.name()) ? param.name() : + "(" + param.name() + ") " + Util.buildLines(" ", new Function() { public String apply(ArgumentParser parser) { return "<" + parser.getName() + ">"; } - }, param.getParsers())) + (param.isRequired() ? ">" : "]")); + }, param.parsers())) + (param.required() ? ">" : "]")); } - exec.logConsole("%s %s", command.getName(), Util.buildLines(" ", list)); + exec.logConsole("%s %s", command.name(), Util.buildLines(" ", list)); } } diff --git a/server/src/main/java/server/command/commands/CommandOfflinetp.java b/server/src/main/java/server/command/commands/CommandOfflinetp.java index 7d3e339..33d551b 100644 --- a/server/src/main/java/server/command/commands/CommandOfflinetp.java +++ b/server/src/main/java/server/command/commands/CommandOfflinetp.java @@ -34,7 +34,7 @@ public class CommandOfflinetp extends Command { throw new RunException("Spieler '%s' konnte nicht gefunden werden", user); for(Entity entity : entities) { entity.teleport(pos); - exec.logConsole("%s nach %d, %d, %d in %s teleportiert", entity.getCommandName(), (int)pos.x, (int)pos.y, (int)pos.z, UniverseRegistry.getDimension(pos.dim).getFormattedName(false)); + exec.logConsole("%s nach %d, %d, %d in %s teleportiert", entity.getCommandName(), (int)pos.x(), (int)pos.y(), (int)pos.z(), UniverseRegistry.getDimension(pos.dim()).getFormattedName(false)); } return entities.size(); } diff --git a/server/src/main/java/server/command/commands/CommandTime.java b/server/src/main/java/server/command/commands/CommandTime.java index 97f59d2..16fb4f9 100644 --- a/server/src/main/java/server/command/commands/CommandTime.java +++ b/server/src/main/java/server/command/commands/CommandTime.java @@ -69,7 +69,7 @@ public class CommandTime extends Command { public Object exec(CommandEnvironment env, Executor exec, String timeStr, boolean absolute) { Position pos = exec.getExecPos(); - WorldServer world = pos == null ? env.getServer().getSpace() : env.getServer().getWorld(pos.dim); + WorldServer world = pos == null ? env.getServer().getSpace() : env.getServer().getWorld(pos.dim()); long time = absolute ? 0L : world.getDayTime(); long fwd = parseDayTime(world.dimension, timeStr); if(fwd >= 0L) { diff --git a/server/src/main/java/server/command/commands/CommandTp.java b/server/src/main/java/server/command/commands/CommandTp.java index f6a09f6..bab2e39 100644 --- a/server/src/main/java/server/command/commands/CommandTp.java +++ b/server/src/main/java/server/command/commands/CommandTp.java @@ -22,7 +22,7 @@ public class CommandTp extends Command { Position pos = target.getPos(); for(Entity entity : entities) { entity.teleport(pos); - exec.logConsole("%s nach %d, %d, %d in %s teleportiert", entity.getCommandName(), (int)pos.x, (int)pos.y, (int)pos.z, UniverseRegistry.getDimension(pos.dim).getFormattedName(false)); + exec.logConsole("%s nach %d, %d, %d in %s teleportiert", entity.getCommandName(), (int)pos.x(), (int)pos.y(), (int)pos.z(), UniverseRegistry.getDimension(pos.dim()).getFormattedName(false)); } return entities.size(); } diff --git a/server/src/main/java/server/command/commands/CommandWarp.java b/server/src/main/java/server/command/commands/CommandWarp.java index e33dd3b..f0ef0b0 100644 --- a/server/src/main/java/server/command/commands/CommandWarp.java +++ b/server/src/main/java/server/command/commands/CommandWarp.java @@ -42,12 +42,12 @@ public class CommandWarp extends Command { pos = env.getServer().getWarps().get(warp); if(pos == null) throw new RunException("Warp '%s' existiert nicht", warp); - else if(env.getServer().getWorld(pos.dim) == null) - throw new RunException("Warp '%s' hat kein Level (%s)", warp, pos.dim); + else if(env.getServer().getWorld(pos.dim()) == null) + throw new RunException("Warp '%s' hat kein Level (%s)", warp, pos.dim()); // } for(Entity entity : entities) { entity.teleport(pos); - exec.logConsole("%s nach %d, %d, %d in %s teleportiert", entity.getCommandName(), (int)pos.x, (int)pos.y, (int)pos.z, UniverseRegistry.getDimension(pos.dim).getFormattedName(false)); + exec.logConsole("%s nach %d, %d, %d in %s teleportiert", entity.getCommandName(), (int)pos.x(), (int)pos.y(), (int)pos.z(), UniverseRegistry.getDimension(pos.dim()).getFormattedName(false)); } return entities.size(); } diff --git a/server/src/main/java/server/world/BlockEventData.java b/server/src/main/java/server/world/BlockEventData.java deleted file mode 100755 index 9ab6c8f..0000000 --- a/server/src/main/java/server/world/BlockEventData.java +++ /dev/null @@ -1,63 +0,0 @@ -package server.world; - -import common.block.Block; -import common.util.BlockPos; - -public class BlockEventData -{ - private BlockPos position; - private Block blockType; - - /** Different for each blockID */ - private int eventID; - private int eventParameter; - - public BlockEventData(BlockPos pos, Block blockType, int eventId, int p_i45756_4_) - { - this.position = pos; - this.eventID = eventId; - this.eventParameter = p_i45756_4_; - this.blockType = blockType; - } - - public BlockPos getPosition() - { - return this.position; - } - - /** - * Get the Event ID (different for each BlockID) - */ - public int getEventID() - { - return this.eventID; - } - - public int getEventParameter() - { - return this.eventParameter; - } - - public Block getBlock() - { - return this.blockType; - } - - public boolean equals(Object p_equals_1_) - { - if (!(p_equals_1_ instanceof BlockEventData)) - { - return false; - } - else - { - BlockEventData blockeventdata = (BlockEventData)p_equals_1_; - return this.position.equals(blockeventdata.position) && this.eventID == blockeventdata.eventID && this.eventParameter == blockeventdata.eventParameter && this.blockType == blockeventdata.blockType; - } - } - - public String toString() - { - return "TE(" + this.position + ")," + this.eventID + "," + this.eventParameter + "," + this.blockType; - } -} diff --git a/server/src/main/java/server/world/TickEvent.java b/server/src/main/java/server/world/TickEvent.java new file mode 100755 index 0000000..7759f94 --- /dev/null +++ b/server/src/main/java/server/world/TickEvent.java @@ -0,0 +1,13 @@ +package server.world; + +import common.block.Block; +import common.util.BlockPos; + +public record TickEvent(BlockPos position, Block block, int id, int parameter) { + public boolean equals(Object other) { + if(!(other instanceof TickEvent)) + return false; + TickEvent event = (TickEvent)other; + return this.position.equals(event.position) && this.id == event.id && this.parameter == event.parameter && this.block == event.block; + } +} diff --git a/server/src/main/java/server/world/WorldServer.java b/server/src/main/java/server/world/WorldServer.java index 5f0f106..95c33d2 100755 --- a/server/src/main/java/server/world/WorldServer.java +++ b/server/src/main/java/server/world/WorldServer.java @@ -257,7 +257,7 @@ public final class WorldServer extends AWorldServer { FeatureOres[] gens = new FeatureOres[this.dimension.getOres().size()]; for(int z = 0; z < gens.length; z++) { Ore gen = this.dimension.getOres().get(z); - gens[z] = new FeatureOres(gen.state, gen.count, gen.more, gen.size, gen.min, gen.max, gen.dist); + gens[z] = new FeatureOres(gen.state(), gen.count(), gen.more(), gen.size(), gen.min(), gen.max(), gen.dist()); } return gens; } @@ -268,7 +268,7 @@ public final class WorldServer extends AWorldServer { FeatureLakes[] gens = new FeatureLakes[this.dimension.getLakes().size()]; for(int z = 0; z < gens.length; z++) { Lake gen = this.dimension.getLakes().get(z); - gens[z] = new FeatureLakes(gen.state, gen.filler, gen.top, gen.chance, gen.minHeight, gen.maxHeight, gen.ratiod); + gens[z] = new FeatureLakes(gen.state(), gen.filler(), gen.top(), gen.chance(), gen.minHeight(), gen.maxHeight(), gen.ratiod()); } return gens; } @@ -279,7 +279,7 @@ public final class WorldServer extends AWorldServer { FeatureLiquids[] gens = new FeatureLiquids[this.dimension.getLiquids().size()]; for(int z = 0; z < gens.length; z++) { Liquid gen = this.dimension.getLiquids().get(z); - gens[z] = new FeatureLiquids(gen.state, gen.chance, gen.minHeight, gen.maxHeight, gen.lower); + gens[z] = new FeatureLiquids(gen.state(), gen.chance(), gen.minHeight(), gen.maxHeight(), gen.lower()); } return gens; } @@ -949,18 +949,18 @@ public final class WorldServer extends AWorldServer { public static void saveWarps(Map warps) { Map> map = Maps.newHashMap(); for(Entry pos : warps.entrySet()) { - Dimension dim = UniverseRegistry.getDimension(pos.getValue().dim); + Dimension dim = UniverseRegistry.getDimension(pos.getValue().dim()); if(dim != null) { - List list = map.get(pos.getValue().dim); + List list = map.get(pos.getValue().dim()); if(list == null) - map.put(pos.getValue().dim, list = Lists.newArrayList()); + map.put(pos.getValue().dim(), list = Lists.newArrayList()); TagObject warp = new TagObject(); warp.setString("Name", pos.getKey()); - warp.setDouble("X", pos.getValue().x); - warp.setDouble("Y", pos.getValue().y); - warp.setDouble("Z", pos.getValue().z); - warp.setFloat("Yaw", pos.getValue().yaw); - warp.setFloat("Pitch", pos.getValue().pitch); + warp.setDouble("X", pos.getValue().x()); + warp.setDouble("Y", pos.getValue().y()); + warp.setDouble("Z", pos.getValue().z()); + warp.setFloat("Yaw", pos.getValue().yaw()); + warp.setFloat("Pitch", pos.getValue().pitch()); list.add(warp); } } @@ -1158,9 +1158,9 @@ public final class WorldServer extends AWorldServer { } public void addBlockEvent(BlockPos pos, Block blockIn, int eventID, int eventParam) { - BlockEventData blockeventdata = new BlockEventData(pos, blockIn, eventID, eventParam); + TickEvent blockeventdata = new TickEvent(pos, blockIn, eventID, eventParam); - for(BlockEventData blockeventdata1 : this.queue[this.blockEvtIdx]) { + for(TickEvent blockeventdata1 : this.queue[this.blockEvtIdx]) { if(blockeventdata1.equals(blockeventdata)) { return; } @@ -1174,12 +1174,12 @@ public final class WorldServer extends AWorldServer { int i = this.blockEvtIdx; this.blockEvtIdx ^= 1; - for(BlockEventData blockeventdata : this.queue[i]) { + for(TickEvent blockeventdata : this.queue[i]) { if(this.fireBlockEvent(blockeventdata)) { - this.server.sendNear((double)blockeventdata.getPosition().getX(), (double)blockeventdata.getPosition().getY(), - (double)blockeventdata.getPosition().getZ(), 64.0D, this.dimension.getDimensionId(), - new SPacketBlockAction(blockeventdata.getPosition(), blockeventdata.getBlock(), blockeventdata.getEventID(), - blockeventdata.getEventParameter())); + this.server.sendNear((double)blockeventdata.position().getX(), (double)blockeventdata.position().getY(), + (double)blockeventdata.position().getZ(), 64.0D, this.dimension.getDimensionId(), + new SPacketBlockAction(blockeventdata.position(), blockeventdata.block(), blockeventdata.id(), + blockeventdata.parameter())); } } @@ -1187,10 +1187,10 @@ public final class WorldServer extends AWorldServer { } } - private boolean fireBlockEvent(BlockEventData event) { - State iblockstate = this.getState(event.getPosition()); - return iblockstate.getBlock() == event.getBlock() - ? iblockstate.getBlock().onBlockEventReceived(this, event.getPosition(), iblockstate, event.getEventID(), event.getEventParameter()) + private boolean fireBlockEvent(TickEvent event) { + State iblockstate = this.getState(event.position()); + return iblockstate.getBlock() == event.block() + ? iblockstate.getBlock().onBlockEventReceived(this, event.position(), iblockstate, event.id(), event.parameter()) : false; } @@ -1661,7 +1661,7 @@ public final class WorldServer extends AWorldServer { this.loaderList.clear(); for(Iterator> iter = this.server.getWarps().entrySet().iterator(); iter.hasNext();) { Entry pos = iter.next(); - if(pos.getValue().dim == this.dimension.getDimensionId()) + if(pos.getValue().dim() == this.dimension.getDimensionId()) iter.remove(); } Region.finishWrite(); @@ -2742,7 +2742,7 @@ public final class WorldServer extends AWorldServer { this.getChunk(pos).setModified(true); } - private static class EventList extends ArrayList { + private static class EventList extends ArrayList { private EventList() { } }