code cleanup: use records where possible

This commit is contained in:
Sen 2025-05-30 17:57:14 +02:00
parent f30141c8f3
commit 8e0bbd06c2
Signed by: sen
GPG key ID: 3AC50A6F47D1B722
139 changed files with 957 additions and 1777 deletions

View file

@ -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.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"), 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, (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.tpscode(), this.tickrate < 1.0f ? 1.0f / this.tickrate : this.tickrate,
this.tickrate < 1.0f ? "SPT" : "TPS", (float)this.tickTarget / 1000.0f, this.tickrate < 1.0f ? "SPT" : "TPS", (float)this.tickTarget / 1000.0f,
(float)this.tick_time / 1000.0f, this.tickTimeout, (float)this.tick_time / 1000.0f, this.tickTimeout,
@ -2089,40 +2089,40 @@ public class Client implements IThreadListener {
public void poll() { public void poll() {
for(WindowEvent event : Window.poll()) { for(WindowEvent event : Window.poll()) {
switch(event.action) { switch(event.action()) {
case BUTTON: case BUTTON:
if(event.param1 >= 0 && event.param1 < Button.values().length) if(event.param1() >= 0 && event.param1() < Button.values().length)
button(Button.values()[event.param1], event.param2 != 0); button(Button.values()[event.param1()], event.param2() != 0);
break; break;
case CHARACTER: case CHARACTER:
if(event.param1 >= (int)Log.CHR_SPC && event.param1 <= (int)Character.MAX_VALUE) if(event.param1() >= (int)Log.CHR_SPC && event.param1() <= (int)Character.MAX_VALUE)
character((char)event.param1); character((char)event.param1());
break; break;
case CLOSED: case CLOSED:
closed(); closed();
break; break;
case CURSOR: case CURSOR:
mouse(event.param1, event.param2); mouse(event.param1(), event.param2());
break; break;
case FOCUS: case FOCUS:
focus(event.param1 != 0); focus(event.param1() != 0);
break; break;
case KEY: case KEY:
if(event.param1 >= 0 && event.param1 < Keysym.values().length) if(event.param1() >= 0 && event.param1() < Keysym.values().length)
key(Keysym.values()[event.param1], KeyEvent.values()[event.param2 % KeyEvent.values().length]); key(Keysym.values()[event.param1()], KeyEvent.values()[event.param2() % KeyEvent.values().length]);
break; break;
case POSITION: case POSITION:
pos(event.param1, event.param2); pos(event.param1(), event.param2());
break; break;
case REDRAW: case REDRAW:
// redraw(); disable as it is pretty useless // redraw(); disable as it is pretty useless
break; break;
case RESIZE: case RESIZE:
fbsize(event.param1, event.param2); fbsize(event.param1(), event.param2());
break; break;
case SCROLL: case SCROLL:
if(event.param1 != 0 || event.param2 != 0) if(event.param1() != 0 || event.param2() != 0)
scroll(event.param1, event.param2); scroll(event.param1(), event.param2());
break; break;
} }
} }
@ -2138,7 +2138,7 @@ public class Client implements IThreadListener {
public void full(boolean full) { public void full(boolean full) {
if((full != fullscreen || full) && (!full || vidMode != null)) { if((full != fullscreen || full) && (!full || vidMode != null)) {
if(full) { if(full) {
Window.setFullscreen(vidMode.width, vidMode.height, vidMode.refresh); Window.setFullscreen(vidMode.width(), vidMode.height(), vidMode.refresh());
} }
else { else {
Window.setWindowed(saved_xpos, saved_ypos, xsize, ysize); Window.setWindowed(saved_xpos, saved_ypos, xsize, ysize);
@ -2156,7 +2156,7 @@ public class Client implements IThreadListener {
} }
else { else {
DisplayMode mode = Window.getDisplayMode(); DisplayMode mode = Window.getDisplayMode();
syncLimit = mode != null ? mode.refresh : 60; syncLimit = mode != null ? mode.refresh() : 60;
} }
Window.setVSync(vsync); Window.setVSync(vsync);
} }
@ -3113,13 +3113,13 @@ public class Client implements IThreadListener {
y = up ? y - Font.YGLYPH : y; y = up ? y - Font.YGLYPH : y;
for(Iterator<Message> iter = log.iterator(); iter.hasNext();) { for(Iterator<Message> iter = log.iterator(); iter.hasNext();) {
Message msg = iter.next(); 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) if(align > 0)
Drawing.drawTextbox(msg.message, x, y, bg); Drawing.drawTextbox(msg.message(), x, y, bg);
else if(align < 0) else if(align < 0)
Drawing.drawTextboxRight(msg.message, x, y, bg); Drawing.drawTextboxRight(msg.message(), x, y, bg);
else else
Drawing.drawTextboxCentered(msg.message, x, y, bg); Drawing.drawTextboxCentered(msg.message(), x, y, bg);
y += up ? -(Font.YGLYPH) : Font.YGLYPH; y += up ? -(Font.YGLYPH) : Font.YGLYPH;
} }
else { else {

View file

@ -20,7 +20,7 @@ import common.color.TextColor;
import common.log.Log; import common.log.Log;
import common.network.IPlayer; import common.network.IPlayer;
import common.util.EncryptUtil; import common.util.EncryptUtil;
import common.util.Tuple; import common.util.Pair;
import common.util.Util; import common.util.Util;
public class GuiConnect extends GuiList<GuiConnect.ServerInfo> implements ButtonCallback { public class GuiConnect extends GuiList<GuiConnect.ServerInfo> implements ButtonCallback {
@ -225,35 +225,35 @@ public class GuiConnect extends GuiList<GuiConnect.ServerInfo> implements Button
} }
} }
else { else {
Tuple<String, String> value = Util.getKeyValue(line); Pair<String, String> value = Util.getKeyValue(line);
if(value.first.equals("address")) if(value.first().equals("address"))
address = value.second; address = value.second();
else if(value.first.equals("port")) else if(value.first().equals("port"))
try { try {
port = Integer.parseInt(value.second); port = Integer.parseInt(value.second());
} }
catch(NumberFormatException e) { catch(NumberFormatException e) {
} }
else if(value.first.equals("user")) else if(value.first().equals("user"))
user = value.second; user = value.second();
else if(value.first.equals("password")) else if(value.first().equals("password"))
password = value.second; password = value.second();
else if(value.first.equals("access")) else if(value.first().equals("access"))
access = value.second; access = value.second();
else if(value.first.equals("connected")) else if(value.first().equals("connected"))
try { try {
time = Long.parseLong(value.second); time = Long.parseLong(value.second());
} }
catch(NumberFormatException e) { catch(NumberFormatException e) {
} }
else if(value.first.equals("encryption_enforced")) else if(value.first().equals("encryption_enforced"))
enforceEnc = true; enforceEnc = true;
else if(value.first.equals("serverkey")) else if(value.first().equals("serverkey"))
serverKey = Util.fromHexString(value.second); serverKey = Util.fromHexString(value.second());
else if(value.first.equals("key")) else if(value.first().equals("key"))
key = Util.fromHexString(value.second); key = Util.fromHexString(value.second());
else if(value.first.equals("pubkey")) else if(value.first().equals("pubkey"))
pubkey = Util.fromHexString(value.second); pubkey = Util.fromHexString(value.second());
} }
} }
Collections.sort(this.elements); Collections.sort(this.elements);

View file

@ -54,7 +54,7 @@ import common.entity.npc.EntityHuman;
import common.entity.npc.EntityNPC; import common.entity.npc.EntityNPC;
import common.entity.npc.SpeciesInfo; import common.entity.npc.SpeciesInfo;
import common.entity.types.EntityLiving; import common.entity.types.EntityLiving;
import common.init.EntityEggInfo; import common.init.EntityInfo;
import common.init.EntityRegistry; import common.init.EntityRegistry;
import common.init.SpeciesRegistry; import common.init.SpeciesRegistry;
import common.init.UniverseRegistry; import common.init.UniverseRegistry;
@ -399,9 +399,9 @@ public class GuiChar extends GuiList<GuiChar.SkinEntry>
}, IPlayer.VALID_NICK, this.gm.player == null ? "" : this.gm.player.getCustomNameTag())); }, IPlayer.VALID_NICK, this.gm.player == null ? "" : this.gm.player.getCustomNameTag()));
this.templateButton.enabled = false; this.templateButton.enabled = false;
this.dimension = new Random().zrange(UniverseRegistry.getBaseDimensions().size()); 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)); 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) { if(egg != null && egg.origin() != null) {
Dimension dim = UniverseRegistry.getDimension(egg.origin); Dimension dim = UniverseRegistry.getDimension(egg.origin());
if(dim != null) { if(dim != null) {
for(int z = 0; z < UniverseRegistry.getBaseDimensions().size(); z++) { for(int z = 0; z < UniverseRegistry.getBaseDimensions().size(); z++) {
if(UniverseRegistry.getBaseDimensions().get(z).getDimensionId() == dim.getDimensionId()) { if(UniverseRegistry.getBaseDimensions().get(z).getDimensionId() == dim.getDimensionId()) {

View file

@ -33,10 +33,10 @@ public class GuiCharacters extends GuiList<GuiCharacters.CharacterEntry> impleme
Drawing.drawRect(x, y, 1, 36, 0xffaf0000); Drawing.drawRect(x, y, 1, 36, 0xffaf0000);
String str = this.character == null ? TextColor.BLUE + "[" + TextColor.CYAN + "+" + TextColor.BLUE + "]" : 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 + "]", 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 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", 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(str, x + 3, y, 0xffffffff);
Drawing.drawText(pos, x + 3, y + 16, 0xffffffff); Drawing.drawText(pos, x + 3, y + 16, 0xffffffff);
} }
@ -60,7 +60,7 @@ public class GuiCharacters extends GuiList<GuiCharacters.CharacterEntry> impleme
private void updateButtons() { private void updateButtons() {
CharacterEntry entry = this.getSelected(); 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.setText(entry != null && entry.character == null ? "Charakter erstellen" : "Charakter spielen");
this.actionButtom.enabled = entry != null && !entry.initial; this.actionButtom.enabled = entry != null && !entry.initial;
this.deleteButtom.enabled = entry != null && entry.character != null && !entry.initial; this.deleteButtom.enabled = entry != null && entry.character != null && !entry.initial;
@ -74,7 +74,7 @@ public class GuiCharacters extends GuiList<GuiCharacters.CharacterEntry> impleme
if(this.gm.getNetHandler() != null) { if(this.gm.getNetHandler() != null) {
int initialSelection = this.gm.getNetHandler().getSelectedCharacter(); int initialSelection = this.gm.getNetHandler().getSelectedCharacter();
for(PlayerCharacter character : this.gm.getNetHandler().getCharacterList()) { 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.elements.add(new CharacterEntry(null, false));
this.setSelected(initialSelection); this.setSelected(initialSelection);
@ -116,7 +116,7 @@ public class GuiCharacters extends GuiList<GuiCharacters.CharacterEntry> impleme
GuiCharacters.this.gm.getNetHandler().addToSendQueue(new CPacketAction(CPacketAction.Action.DELETE_CHARACTER, GuiCharacters.this.selectedElement)); GuiCharacters.this.gm.getNetHandler().addToSendQueue(new CPacketAction(CPacketAction.Action.DELETE_CHARACTER, GuiCharacters.this.selectedElement));
GuiCharacters.this.gm.displayGuiScreen(GuiCharacters.this); 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"));
} }
} }
} }

View file

@ -81,9 +81,9 @@ public class GuiMerchant extends GuiContainer
if (merchantrecipelist != null && !merchantrecipelist.isEmpty()) { if (merchantrecipelist != null && !merchantrecipelist.isEmpty()) {
int k = this.selectedMerchantRecipe; int k = this.selectedMerchantRecipe;
MerchantRecipe merchantrecipe = (MerchantRecipe)merchantrecipelist.get(k); MerchantRecipe merchantrecipe = (MerchantRecipe)merchantrecipelist.get(k);
ItemStack itemstack = merchantrecipe.getBuying(); ItemStack itemstack = merchantrecipe.first();
ItemStack itemstack1 = merchantrecipe.getSecondBuy(); ItemStack itemstack1 = merchantrecipe.second();
ItemStack itemstack2 = merchantrecipe.getSelling(); ItemStack itemstack2 = merchantrecipe.result();
this.renderItemOverlayIntoGUI(itemstack, 36, 24, null); this.renderItemOverlayIntoGUI(itemstack, 36, 24, null);
if(itemstack1 != null) if(itemstack1 != null)
this.renderItemOverlayIntoGUI(itemstack1, 62, 24, null); this.renderItemOverlayIntoGUI(itemstack1, 62, 24, null);
@ -180,9 +180,9 @@ public class GuiMerchant extends GuiContainer
// int j = (this.height - this.ySize) / 2; // int j = (this.height - this.ySize) / 2;
int k = this.selectedMerchantRecipe; int k = this.selectedMerchantRecipe;
MerchantRecipe merchantrecipe = (MerchantRecipe)merchantrecipelist.get(k); MerchantRecipe merchantrecipe = (MerchantRecipe)merchantrecipelist.get(k);
ItemStack itemstack = merchantrecipe.getBuying(); ItemStack itemstack = merchantrecipe.first();
ItemStack itemstack1 = merchantrecipe.getSecondBuy(); ItemStack itemstack1 = merchantrecipe.second();
ItemStack itemstack2 = merchantrecipe.getSelling(); ItemStack itemstack2 = merchantrecipe.result();
GL11.glPushMatrix(); GL11.glPushMatrix();
ItemRenderer.enableGUIStandardItemLighting(); ItemRenderer.enableGUIStandardItemLighting();
GlState.disableLighting(); GlState.disableLighting();

View file

@ -35,9 +35,9 @@ public class GuiForm extends Gui implements ButtonCallback {
this.add(new Label(0, -100, 300, 20, this.title)); this.add(new Label(0, -100, 300, 20, this.title));
for(int z = 0; z < this.inputs.length; z++) { for(int z = 0; z < this.inputs.length; z++) {
final int index = z; final int index = z;
final String name = this.inputData[z].first; final String name = this.inputData[z].first();
Object obj = this.inputData[z].second; Object obj = this.inputData[z].second();
int param = this.inputData[z].third; int param = this.inputData[z].third();
if(obj instanceof Boolean) { if(obj instanceof Boolean) {
this.inputs[z] = this.add(new Toggle(0, 50 * z, 300, 24, (Boolean)obj, (Boolean)obj, new ToggleCallback() { 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) { public void use(Toggle elem, boolean value) {
@ -97,15 +97,15 @@ public class GuiForm extends Gui implements ButtonCallback {
this.inputData = data; this.inputData = data;
this.outputData = new Object[data.length]; this.outputData = new Object[data.length];
for(int z = 0; z < data.length; z++) { for(int z = 0; z < data.length; z++) {
Object obj = data[z].second; Object obj = data[z].second();
this.outputData[z] = obj instanceof String[] ? data[z].third : obj; this.outputData[z] = obj instanceof String[] ? data[z].third() : obj;
} }
} }
public void use(ActButton elem, PressType action) { public void use(ActButton elem, PressType action) {
for(int z = 0; z < this.inputs.length; z++) { for(int z = 0; z < this.inputs.length; z++) {
if(this.inputs[z] instanceof Field) { 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(); String text = this.inputs[z].getText();
if(text.length() < min) { if(text.length() < min) {
if(!GuiForm.this.labels[z].getText().startsWith("" + TextColor.RED)) if(!GuiForm.this.labels[z].getText().startsWith("" + TextColor.RED))

View file

@ -135,7 +135,6 @@ import common.potion.PotionEffect;
import common.rng.Random; import common.rng.Random;
import common.sound.Sound; import common.sound.Sound;
import common.tileentity.IInteractionObject; import common.tileentity.IInteractionObject;
import common.tileentity.LocalBlockIntercommunication;
import common.tileentity.TileEntity; import common.tileentity.TileEntity;
import common.tileentity.TileEntityMachine; import common.tileentity.TileEntityMachine;
import common.tileentity.TileEntitySign; import common.tileentity.TileEntitySign;
@ -1171,7 +1170,7 @@ public class ClientPlayer extends NetHandler implements IClientPlayer
} }
else if (!packetIn.hasSlots()) 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(); entityplayersp.openContainer.windowId = packetIn.getWindowId();
} }
else else

View file

@ -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();
}
}

View file

@ -189,7 +189,7 @@ public class BlockRenderer
for (Facing enumfacing : Facing.values()) for (Facing enumfacing : Facing.values())
{ {
List<BakedQuad> list = modelIn.getFaceQuads(enumfacing); List<BakedQuad> list = modelIn.getFace(enumfacing);
if (!list.isEmpty()) if (!list.isEmpty())
{ {
@ -204,7 +204,7 @@ public class BlockRenderer
} }
} }
List<BakedQuad> list1 = modelIn.getGeneralQuads(); List<BakedQuad> list1 = modelIn.getQuads();
if (list1.size() > 0) if (list1.size() > 0)
{ {
@ -348,10 +348,10 @@ public class BlockRenderer
{ {
for (Facing enumfacing : Facing.values()) 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_) private void renderModelBrightness(IBakedModel model, State p_178266_2_, float brightness, boolean p_178266_4_)

View file

@ -37,7 +37,7 @@ public class ItemModelMesher
public TextureAtlasSprite getParticleIcon(Item item, int meta) 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) public IBakedModel getItemModel(ItemStack stack)

View file

@ -196,7 +196,7 @@ public class RenderBuffer
{ {
int i = this.vertexCount * this.vertexFormat.getNextOffset() + this.vertexFormat.getOffset(this.vertexFormatIndex); int i = this.vertexCount * this.vertexFormat.getNextOffset() + this.vertexFormat.getOffset(this.vertexFormatIndex);
switch (this.vertexFormatElement.getType()) switch (this.vertexFormatElement.type())
{ {
case FLOAT: case FLOAT:
this.byteBuffer.putFloat(i, (float)u); 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); int i = this.vertexCount * this.vertexFormat.getNextOffset() + this.vertexFormat.getOffset(this.vertexFormatIndex);
switch (this.vertexFormatElement.getType()) switch (this.vertexFormatElement.type())
{ {
case FLOAT: case FLOAT:
this.byteBuffer.putFloat(i, (float)p_181671_1_); 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); int i = this.vertexCount * this.vertexFormat.getNextOffset() + this.vertexFormat.getOffset(this.vertexFormatIndex);
switch (this.vertexFormatElement.getType()) switch (this.vertexFormatElement.type())
{ {
case FLOAT: case FLOAT:
this.byteBuffer.putFloat(i, (float)red / 255.0F); 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); int i = this.vertexCount * this.vertexFormat.getNextOffset() + this.vertexFormat.getOffset(this.vertexFormatIndex);
switch (this.vertexFormatElement.getType()) switch (this.vertexFormatElement.type())
{ {
case FLOAT: case FLOAT:
this.byteBuffer.putFloat(i, (float)(x + this.xOffset)); this.byteBuffer.putFloat(i, (float)(x + this.xOffset));
@ -500,7 +500,7 @@ public class RenderBuffer
this.vertexFormatIndex %= this.vertexFormat.getElementCount(); this.vertexFormatIndex %= this.vertexFormat.getElementCount();
this.vertexFormatElement = this.vertexFormat.getElement(this.vertexFormatIndex); this.vertexFormatElement = this.vertexFormat.getElement(this.vertexFormatIndex);
if (this.vertexFormatElement.getUsage() == VertexFormatElement.EnumUsage.PADDING) if (this.vertexFormatElement.usage() == VertexFormatElement.EnumUsage.PADDING)
{ {
this.nextVertexFormatIndex(); this.nextVertexFormatIndex();
} }
@ -510,7 +510,7 @@ public class RenderBuffer
{ {
int i = this.vertexCount * this.vertexFormat.getNextOffset() + this.vertexFormat.getOffset(this.vertexFormatIndex); int i = this.vertexCount * this.vertexFormat.getNextOffset() + this.vertexFormat.getOffset(this.vertexFormatIndex);
switch (this.vertexFormatElement.getType()) switch (this.vertexFormatElement.type())
{ {
case FLOAT: case FLOAT:
this.byteBuffer.putFloat(i, p_181663_1_); this.byteBuffer.putFloat(i, p_181663_1_);

View file

@ -1042,8 +1042,8 @@ public class RenderGlobal
// { // {
for (VertexFormatElement vertexformatelement : DefaultVertexFormats.BLOCK.getElements()) for (VertexFormatElement vertexformatelement : DefaultVertexFormats.BLOCK.getElements())
{ {
VertexFormatElement.EnumUsage vertexformatelement$enumusage = vertexformatelement.getUsage(); VertexFormatElement.EnumUsage vertexformatelement$enumusage = vertexformatelement.usage();
int i = vertexformatelement.getIndex(); int i = vertexformatelement.index();
switch (vertexformatelement$enumusage) switch (vertexformatelement$enumusage)
{ {

View file

@ -28,27 +28,27 @@ public abstract class Tessellator
for (int j = 0; j < list.size(); ++j) for (int j = 0; j < list.size(); ++j)
{ {
VertexFormatElement vertexformatelement = (VertexFormatElement)list.get(j); VertexFormatElement vertexformatelement = (VertexFormatElement)list.get(j);
VertexFormatElement.EnumUsage vertexformatelement$enumusage = vertexformatelement.getUsage(); VertexFormatElement.EnumUsage vertexformatelement$enumusage = vertexformatelement.usage();
int k = vertexformatelement.getType().getGlConstant(); int k = vertexformatelement.type().getGlConstant();
int l = vertexformatelement.getIndex(); int l = vertexformatelement.index();
bytebuffer.position(vertexformat.getOffset(j)); bytebuffer.position(vertexformat.getOffset(j));
switch (vertexformatelement$enumusage) switch (vertexformatelement$enumusage)
{ {
case POSITION: case POSITION:
GL11.glVertexPointer(vertexformatelement.getElementCount(), k, i, bytebuffer); GL11.glVertexPointer(vertexformatelement.count(), k, i, bytebuffer);
GL11.glEnableClientState(GL11.GL_VERTEX_ARRAY); GL11.glEnableClientState(GL11.GL_VERTEX_ARRAY);
break; break;
case UV: case UV:
GL13.glClientActiveTexture(GL13.GL_TEXTURE0 + l); 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); GL11.glEnableClientState(GL11.GL_TEXTURE_COORD_ARRAY);
GL13.glClientActiveTexture(GL13.GL_TEXTURE0); GL13.glClientActiveTexture(GL13.GL_TEXTURE0);
break; break;
case COLOR: case COLOR:
GL11.glColorPointer(vertexformatelement.getElementCount(), k, i, bytebuffer); GL11.glColorPointer(vertexformatelement.count(), k, i, bytebuffer);
GL11.glEnableClientState(GL11.GL_COLOR_ARRAY); GL11.glEnableClientState(GL11.GL_COLOR_ARRAY);
break; break;
@ -64,8 +64,8 @@ public abstract class Tessellator
for (int j1 = list.size(); i1 < j1; ++i1) for (int j1 = list.size(); i1 < j1; ++i1)
{ {
VertexFormatElement vertexformatelement1 = (VertexFormatElement)list.get(i1); VertexFormatElement vertexformatelement1 = (VertexFormatElement)list.get(i1);
VertexFormatElement.EnumUsage vertexformatelement$enumusage1 = vertexformatelement1.getUsage(); VertexFormatElement.EnumUsage vertexformatelement$enumusage1 = vertexformatelement1.usage();
int k1 = vertexformatelement1.getIndex(); int k1 = vertexformatelement1.index();
switch (vertexformatelement$enumusage1) switch (vertexformatelement$enumusage1)
{ {

View file

@ -51,7 +51,7 @@ public class VertexFormat
public VertexFormat addElement(VertexFormatElement element) 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."); Log.RENDER.warn("VertexFormat-Fehler: Versuche eine Position vom Typ VertexFormatElement hinzuzufügen, während eine bereits existiert, ignoriere.");
return this; return this;
@ -61,7 +61,7 @@ public class VertexFormat
this.elements.add(element); this.elements.add(element);
this.offsets.add(Integer.valueOf(this.nextOffset)); this.offsets.add(Integer.valueOf(this.nextOffset));
switch (element.getUsage()) switch (element.usage())
{ {
case NORMAL: case NORMAL:
this.normalElementOffset = this.nextOffset; this.normalElementOffset = this.nextOffset;
@ -72,10 +72,10 @@ public class VertexFormat
break; break;
case UV: 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; return this;
} }
} }
@ -135,7 +135,7 @@ public class VertexFormat
{ {
VertexFormatElement vertexformatelement = (VertexFormatElement)this.elements.get(i); VertexFormatElement vertexformatelement = (VertexFormatElement)this.elements.get(i);
if (vertexformatelement.isPositionElement()) if (vertexformatelement.isPosition())
{ {
return true; return true;
} }

View file

@ -2,100 +2,37 @@ package client.renderer;
import org.lwjgl.opengl.GL11; 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() {
public class VertexFormatElement return this.count + "," + this.usage.getName() + "," + this.type.getName();
{
private final VertexFormatElement.EnumType type;
private final VertexFormatElement.EnumUsage usage;
private int index;
private int elementCount;
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;
} }
this.type = typeIn; public int size() {
this.index = indexIn; return this.type.getSize() * this.count;
this.elementCount = count;
} }
private final boolean isValid(int index, VertexFormatElement.EnumUsage usage) public boolean isPosition() {
{
return index == 0 || usage == VertexFormatElement.EnumUsage.UV;
}
public final VertexFormatElement.EnumType getType()
{
return this.type;
}
public final VertexFormatElement.EnumUsage getUsage()
{
return this.usage;
}
public final int getElementCount()
{
return this.elementCount;
}
public final int getIndex()
{
return this.index;
}
public String toString()
{
return this.elementCount + "," + this.usage.getDisplayName() + "," + this.type.getDisplayName();
}
public final int getSize()
{
return this.type.getSize() * this.elementCount;
}
public final boolean isPositionElement()
{
return this.usage == VertexFormatElement.EnumUsage.POSITION; return this.usage == VertexFormatElement.EnumUsage.POSITION;
} }
public boolean equals(Object p_equals_1_) public boolean equals(Object other) {
{ if(this == other)
if (this == p_equals_1_)
{
return true; return true;
} if(!(other instanceof VertexFormatElement))
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; return false;
} VertexFormatElement elem = (VertexFormatElement)other;
return this.count == elem.count && this.index == elem.index && this.type == elem.type && this.usage == elem.usage;
} }
public int hashCode() public int hashCode() {
{
int i = this.type.hashCode(); int i = this.type.hashCode();
i = 31 * i + this.usage.hashCode(); i = 31 * i + this.usage.hashCode();
i = 31 * i + this.index; i = 31 * i + this.index;
i = 31 * i + this.elementCount; i = 31 * i + this.count;
return i; return i;
} }
public static enum EnumType public static enum EnumType {
{
FLOAT(4, "Float", GL11.GL_FLOAT), FLOAT(4, "Float", GL11.GL_FLOAT),
UBYTE(1, "Unsigned Byte", GL11.GL_UNSIGNED_BYTE), UBYTE(1, "Unsigned Byte", GL11.GL_UNSIGNED_BYTE),
BYTE(1, "Byte", GL11.GL_BYTE), BYTE(1, "Byte", GL11.GL_BYTE),
@ -105,52 +42,43 @@ public class VertexFormatElement
INT(4, "Int", GL11.GL_INT); INT(4, "Int", GL11.GL_INT);
private final int size; private final int size;
private final String displayName; private final String name;
private final int glConstant; private final int glConstant;
private EnumType(int sizeIn, String displayNameIn, int glConstantIn) private EnumType(int size, String name, int glConstant) {
{ this.size = size;
this.size = sizeIn; this.name = name;
this.displayName = displayNameIn; this.glConstant = glConstant;
this.glConstant = glConstantIn;
} }
public int getSize() public int getSize() {
{
return this.size; return this.size;
} }
public String getDisplayName() public String getName() {
{ return this.name;
return this.displayName;
} }
public int getGlConstant() public int getGlConstant() {
{
return this.glConstant; return this.glConstant;
} }
} }
public static enum EnumUsage public static enum EnumUsage {
{
POSITION("Position"), POSITION("Position"),
NORMAL("Normal"), NORMAL("Normal"),
COLOR("Vertex Color"), COLOR("Vertex Color"),
UV("UV"), UV("UV"),
// MATRIX("Bone Matrix"),
// BLEND_WEIGHT("Blend Weight"),
PADDING("Padding"); PADDING("Padding");
private final String displayName; private final String name;
private EnumUsage(String displayNameIn) private EnumUsage(String name) {
{ this.name = name;
this.displayName = displayNameIn;
} }
public String getDisplayName() public String getName() {
{ return this.name;
return this.displayName;
} }
} }
} }

View file

@ -8,146 +8,80 @@ import common.collect.Lists;
import common.model.Transforms; import common.model.Transforms;
import common.util.Facing; import common.util.Facing;
public class BakedModel implements IBakedModel public record BakedModel(List<BakedQuad> getQuads, List<List<BakedQuad>> getFace, boolean isGui3d, TextureAtlasSprite getBaseTexture, Transforms getTransforms) implements IBakedModel {
{ public List<BakedQuad> getFace(Facing face) {
protected final List<BakedQuad> generalQuads; return this.getFace.get(face.ordinal());
protected final List<List<BakedQuad>> faceQuads;
protected final boolean ambientOcclusion;
protected final boolean gui3d;
protected final TextureAtlasSprite texture;
protected final Transforms cameraTransforms;
public BakedModel(List<BakedQuad> generalQuadsIn, List<List<BakedQuad>> 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 List<BakedQuad> getFaceQuads(Facing facing) public boolean isBuiltin() {
{
return this.faceQuads.get(facing.ordinal());
}
public List<BakedQuad> getGeneralQuads()
{
return this.generalQuads;
}
public boolean isAmbientOcclusion()
{
return this.ambientOcclusion;
}
public boolean isGui3d()
{
return this.gui3d;
}
public boolean isBuiltInRenderer()
{
return false; return false;
} }
public TextureAtlasSprite getParticleTexture() public static class Builder {
{ private final List<BakedQuad> quads;
return this.texture; private final List<List<BakedQuad>> faces;
private TextureAtlasSprite texture;
private boolean gui3d;
private Transforms transforms;
public Builder(ModelBlock model) {
this(model.isGui3d(), model.getTransform());
} }
public Transforms getItemCameraTransforms() public Builder(IBakedModel model, TextureAtlasSprite texture) {
{ this(model.isGui3d(), model.getTransforms());
return this.cameraTransforms; this.texture = model.getBaseTexture();
for(Facing face : Facing.values()) {
this.addFaceBreakingFours(model, texture, face);
} }
public static class Builder this.addGeneralBreakingFours(model, texture);
{
private final List<BakedQuad> builderGeneralQuads;
private final List<List<BakedQuad>> builderFaceQuads;
private final boolean builderAmbientOcclusion;
private TextureAtlasSprite builderTexture;
private boolean builderGui3d;
private Transforms builderCameraTransforms;
public Builder(ModelBlock model)
{
this(model.isAmbientOcclusion(), model.isGui3d(), model.getTransform());
} }
public Builder(IBakedModel bakedModel, TextureAtlasSprite texture) private void addFaceBreakingFours(IBakedModel model, TextureAtlasSprite texture, Facing facing) {
{ for(BakedQuad quad : model.getFace(facing)) {
this(bakedModel.isAmbientOcclusion(), bakedModel.isGui3d(), bakedModel.getItemCameraTransforms()); this.addFaceQuad(facing, new BreakingFour(quad, texture));
this.builderTexture = bakedModel.getParticleTexture();
for (Facing enumfacing : Facing.values())
{
this.addFaceBreakingFours(bakedModel, texture, enumfacing);
}
this.addGeneralBreakingFours(bakedModel, texture);
}
private void addFaceBreakingFours(IBakedModel bakedModel, TextureAtlasSprite texture, Facing facing)
{
for (BakedQuad bakedquad : bakedModel.getFaceQuads(facing))
{
this.addFaceQuad(facing, new BreakingFour(bakedquad, texture));
} }
} }
private void addGeneralBreakingFours(IBakedModel p_177647_1_, TextureAtlasSprite texture) private void addGeneralBreakingFours(IBakedModel model, TextureAtlasSprite texture) {
{ for(BakedQuad quad : model.getQuads()) {
for (BakedQuad bakedquad : p_177647_1_.getGeneralQuads()) this.addGeneralQuad(new BreakingFour(quad, texture));
{
this.addGeneralQuad(new BreakingFour(bakedquad, texture));
} }
} }
private Builder(boolean ambientOcclusion, boolean gui3d, Transforms cameraTransforms) private Builder(boolean gui3d, Transforms transforms) {
{ this.quads = Lists.<BakedQuad>newArrayList();
this.builderGeneralQuads = Lists.<BakedQuad>newArrayList(); this.faces = new ArrayList<List<BakedQuad>>(6);
this.builderFaceQuads = new ArrayList<List<BakedQuad>>(6);
for (Facing enumfacing : Facing.values()) for(Facing face : Facing.values()) {
{ this.faces.add(Lists.<BakedQuad>newArrayList());
this.builderFaceQuads.add(Lists.<BakedQuad>newArrayList());
} }
this.builderAmbientOcclusion = ambientOcclusion; this.gui3d = gui3d;
this.builderGui3d = gui3d; this.transforms = transforms;
this.builderCameraTransforms = cameraTransforms;
} }
public BakedModel.Builder addFaceQuad(Facing facing, BakedQuad quad) public BakedModel.Builder addFaceQuad(Facing face, BakedQuad quad) {
{ this.faces.get(face.ordinal()).add(quad);
((List)this.builderFaceQuads.get(facing.ordinal())).add(quad);
return this; return this;
} }
public BakedModel.Builder addGeneralQuad(BakedQuad quad) public BakedModel.Builder addGeneralQuad(BakedQuad quad) {
{ this.quads.add(quad);
this.builderGeneralQuads.add(quad);
return this; return this;
} }
public BakedModel.Builder setTexture(TextureAtlasSprite texture) public BakedModel.Builder setTexture(TextureAtlasSprite texture) {
{ this.texture = texture;
this.builderTexture = texture;
return this; return this;
} }
public BakedModel makeBakedModel() public BakedModel makeBakedModel() {
{ if(this.texture == null)
if (this.builderTexture == null) throw new RuntimeException("Fehlende Basistextur");
{ return new BakedModel(this.quads, this.faces, this.gui3d, this.texture, this.transforms);
throw new RuntimeException("Missing particle!");
}
else
{
return new BakedModel(this.builderGeneralQuads, this.builderFaceQuads, this.builderAmbientOcclusion, this.builderGui3d, this.builderTexture, this.builderCameraTransforms);
}
} }
} }
} }

View file

@ -6,47 +6,24 @@ import client.renderer.texture.TextureAtlasSprite;
import common.model.Transforms; import common.model.Transforms;
import common.util.Facing; import common.util.Facing;
public class BuiltInModel implements IBakedModel public record BuiltInModel(Transforms getTransforms) implements IBakedModel {
{ public List<BakedQuad> getFace(Facing face) {
private Transforms cameraTransforms;
public BuiltInModel(Transforms p_i46086_1_)
{
this.cameraTransforms = p_i46086_1_;
}
public List<BakedQuad> getFaceQuads(Facing facing)
{
return null; return null;
} }
public List<BakedQuad> getGeneralQuads() public List<BakedQuad> getQuads() {
{
return null; return null;
} }
public boolean isAmbientOcclusion() public boolean isGui3d() {
{
return false;
}
public boolean isGui3d()
{
return true; return true;
} }
public boolean isBuiltInRenderer() public boolean isBuiltin() {
{
return true; return true;
} }
public TextureAtlasSprite getParticleTexture() public TextureAtlasSprite getBaseTexture() {
{
return null; return null;
} }
public Transforms getItemCameraTransforms()
{
return this.cameraTransforms;
}
} }

View file

@ -8,17 +8,15 @@ import common.util.Facing;
public interface IBakedModel public interface IBakedModel
{ {
List<BakedQuad> getFaceQuads(Facing facing); List<BakedQuad> getFace(Facing facing);
List<BakedQuad> getGeneralQuads(); List<BakedQuad> getQuads();
boolean isAmbientOcclusion();
boolean isGui3d(); boolean isGui3d();
boolean isBuiltInRenderer(); boolean isBuiltin();
TextureAtlasSprite getParticleTexture(); TextureAtlasSprite getBaseTexture();
Transforms getItemCameraTransforms(); Transforms getTransforms();
} }

View file

@ -124,7 +124,7 @@ public class ModelManager
ibakedmodel = this.defaultModel; ibakedmodel = this.defaultModel;
} }
return ibakedmodel.getParticleTexture(); return ibakedmodel.getBaseTexture();
} }
public IBakedModel getModelForState(State state) public IBakedModel getModelForState(State state)

View file

@ -40,7 +40,7 @@ public class RenderEntityItem extends Render<EntityItem>
int i = this.func_177078_a(itemstack); int i = this.func_177078_a(itemstack);
float f = 0.25F; float f = 0.25F;
float f1 = ExtMath.sin(((float)itemIn.getAge() + p_177077_8_) / 10.0F + itemIn.hoverStart) * 0.1F + 0.1F; 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_); GL11.glTranslatef((float)p_177077_2_, (float)p_177077_4_ + f1 + 0.25F * f2, (float)p_177077_6_);
if (flag || this.renderManager.gm != null) if (flag || this.renderManager.gm != null)
@ -126,20 +126,18 @@ public class RenderEntityItem extends Render<EntityItem>
} }
GL11.glScalef(0.5F, 0.5F, 0.5F); 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); this.itemRenderer.renderItem(itemstack, ibakedmodel);
GL11.glPopMatrix(); GL11.glPopMatrix();
} }
else else
{ {
GL11.glPushMatrix(); GL11.glPushMatrix();
RenderItem.apply(ibakedmodel.getItemCameraTransforms(), Transforms.Camera.GROUND); RenderItem.apply(ibakedmodel.getTransforms(), Transforms.Camera.GROUND);
this.itemRenderer.renderItem(itemstack, ibakedmodel); this.itemRenderer.renderItem(itemstack, ibakedmodel);
GL11.glPopMatrix(); GL11.glPopMatrix();
float f3 = ibakedmodel.getItemCameraTransforms().ground.scale.x; float f3 = ibakedmodel.getTransforms().ground.scale();
float f4 = ibakedmodel.getItemCameraTransforms().ground.scale.y; GL11.glTranslatef(0.0F, 0.0F, 0.046875F * f3);
float f5 = ibakedmodel.getItemCameraTransforms().ground.scale.z;
GL11.glTranslatef(0.0F * f3, 0.0F * f4, 0.046875F * f5);
} }
} }

View file

@ -77,10 +77,10 @@ public class RenderItem
for (Facing enumfacing : Facing.values()) 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(); Tessellator.draw();
} }
@ -91,7 +91,7 @@ public class RenderItem
GL11.glPushMatrix(); GL11.glPushMatrix();
GL11.glScalef(0.5F, 0.5F, 0.5F); 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.glRotatef(180.0F, 0.0F, 1.0F, 0.0F);
GL11.glTranslatef(-0.5F, -0.5F, -0.5F); GL11.glTranslatef(-0.5F, -0.5F, -0.5F);
@ -270,14 +270,9 @@ public class RenderItem
GlState.enableBlend(); GlState.enableBlend();
GlState.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ZERO); GlState.tryBlendFuncSeparate(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ZERO);
GL11.glPushMatrix(); GL11.glPushMatrix();
Transforms itemcameratransforms = model.getItemCameraTransforms(); Transforms itemcameratransforms = model.getTransforms();
RenderItem.apply(itemcameratransforms, cameraTransformType); RenderItem.apply(itemcameratransforms, cameraTransformType);
if (this.isThereOneNegativeScale(itemcameratransforms.get(cameraTransformType)))
{
GlState.cullFace(GL11.GL_FRONT);
}
this.renderItem(stack, model); this.renderItem(stack, model);
GlState.cullFace(GL11.GL_BACK); GlState.cullFace(GL11.GL_BACK);
GL11.glPopMatrix(); GL11.glPopMatrix();
@ -287,16 +282,6 @@ public class RenderItem
// this.textureManager.getTexture(TextureMap.locationBlocksTexture).restoreLastMipmap(); // 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) private void renderItemIntoGUI(ItemStack stack, int x, int y)
{ {
IBakedModel ibakedmodel = this.itemModelMesher.getItemModel(stack); 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.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
GlState.color(1.0F, 1.0F, 1.0F, 1.0F); GlState.color(1.0F, 1.0F, 1.0F, 1.0F);
this.setupGuiTransform(x, y, ibakedmodel.isGui3d()); this.setupGuiTransform(x, y, ibakedmodel.isGui3d());
RenderItem.apply(ibakedmodel.getItemCameraTransforms(), Transforms.Camera.GUI); RenderItem.apply(ibakedmodel.getTransforms(), Transforms.Camera.GUI);
this.renderItem(stack, ibakedmodel); this.renderItem(stack, ibakedmodel);
GlState.disableAlpha(); GlState.disableAlpha();
GlState.disableRescaleNormal(); GlState.disableRescaleNormal();
@ -362,11 +347,11 @@ public class RenderItem
public static void apply(Transforms trans, Transforms.Camera type) { public static void apply(Transforms trans, Transforms.Camera type) {
Transform vec = trans.get(type); Transform vec = trans.get(type);
if(vec != Transform.IDENTITY) { if(vec != Transform.IDENTITY) {
GL11.glTranslatef(vec.translation.x, vec.translation.y, vec.translation.z); GL11.glTranslatef(vec.translationX(), vec.translationY(), vec.translationZ());
GL11.glRotatef(vec.rotation.y, 0.0F, 1.0F, 0.0F); GL11.glRotatef(vec.rotationY(), 0.0F, 1.0F, 0.0F);
GL11.glRotatef(vec.rotation.x, 1.0F, 0.0F, 0.0F); GL11.glRotatef(vec.rotationX(), 1.0F, 0.0F, 0.0F);
GL11.glRotatef(vec.rotation.z, 0.0F, 0.0F, 1.0F); GL11.glRotatef(vec.rotationZ(), 0.0F, 0.0F, 1.0F);
GL11.glScalef(vec.scale.x, vec.scale.y, vec.scale.z); GL11.glScalef(vec.scale(), vec.scale(), vec.scale());
} }
} }
} }

View file

@ -1,11 +1,4 @@
package client.util; package client.util;
public class Message { public record Message(String message, long time) {
public final String message;
public final long time;
public Message(String message, long time) {
this.message = message;
this.time = time;
}
} }

View file

@ -1,16 +1,6 @@
package client.window; package client.window;
public class DisplayMode { public record DisplayMode(int width, int height, int refresh) {
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 String toString() { public String toString() {
return String.format("%dx%d @ %d Hz", this.width, this.height, this.refresh); return String.format("%dx%d @ %d Hz", this.width, this.height, this.refresh);
} }

View file

@ -1,13 +1,4 @@
package client.window; package client.window;
public class WindowEvent { public record WindowEvent(WindowAction action, int param1, int param2) {
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;
}
} }

View file

@ -4,8 +4,8 @@ import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.function.Predicate; import java.util.function.Predicate;
import common.attributes.Attribute;
import common.attributes.AttributeInstance; import common.attributes.AttributeInstance;
import common.attributes.Attributes;
import common.entity.types.EntityLiving; import common.entity.types.EntityLiving;
public class EntityAIFindEntityNearest extends EntityAIBase public class EntityAIFindEntityNearest extends EntityAIBase
@ -105,7 +105,7 @@ public class EntityAIFindEntityNearest extends EntityAIBase
protected double getFollowRange() 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(); return iattributeinstance == null ? 16.0D : iattributeinstance.getAttributeValue();
} }
} }

View file

@ -1,7 +1,7 @@
package common.ai; package common.ai;
import common.attributes.Attribute;
import common.attributes.AttributeInstance; import common.attributes.AttributeInstance;
import common.attributes.Attributes;
import common.entity.types.EntityLiving; import common.entity.types.EntityLiving;
import common.entity.types.IEntityOwnable; import common.entity.types.IEntityOwnable;
import common.init.Config; import common.init.Config;
@ -107,7 +107,7 @@ public abstract class EntityAITarget extends EntityAIBase
protected double getTargetDistance() 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(); return iattributeinstance == null ? 16.0D : iattributeinstance.getAttributeValue();
} }

View file

@ -1,6 +1,6 @@
package common.ai; package common.ai;
import common.attributes.Attributes; import common.attributes.Attribute;
import common.entity.types.EntityLiving; import common.entity.types.EntityLiving;
import common.util.ExtMath; import common.util.ExtMath;
@ -63,7 +63,7 @@ public class EntityMoveHelper
{ {
float f = (float)(ExtMath.atan2(d1, d0) * 180.0D / Math.PI) - 90.0F; 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.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) if (d2 > 0.0D && d0 * d0 + d1 * d1 < 1.0D)
{ {

View file

@ -3,10 +3,23 @@ package common.attributes;
import java.util.Map; import java.util.Map;
import common.collect.Maps; import common.collect.Maps;
import common.util.Displayable;
import common.util.ExtMath; 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<String, Attribute> ATTRIBUTES = Maps.newHashMap(); private static final Map<String, Attribute> ATTRIBUTES = Maps.newHashMap();
private final String name; private final String name;
@ -14,71 +27,52 @@ public class Attribute
private final double defValue; private final double defValue;
private final double minValue; private final double minValue;
private final double maxValue; private final double maxValue;
private final boolean shouldWatch; private final boolean watch;
static {
for(Attribute attr : values()) {
ATTRIBUTES.put(attr.name, attr);
}
}
public static Attribute getAttribute(String name) { public static Attribute getAttribute(String name) {
return ATTRIBUTES.get(name); return ATTRIBUTES.get(name);
} }
public Attribute(String name, String display, double def, double min, double max, boolean watch) 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.name = name;
this.display = display; this.display = display;
this.defValue = def; this.defValue = def;
if(name == null)
throw new IllegalArgumentException("Name cannot be null!");
this.minValue = min; this.minValue = min;
this.maxValue = max; this.maxValue = max;
this.shouldWatch = watch; this.watch = 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); public String getName() {
}
public String getUnlocalizedName()
{
return this.name; return this.name;
} }
public String getDisplayName() public String getDisplay() {
{
return this.display; return this.display;
} }
public double getDefaultValue() public double getDefault() {
{
return this.defValue; return this.defValue;
} }
public boolean getShouldWatch() public boolean isWatched() {
{ return this.watch;
return this.shouldWatch;
} }
public double clampValue(double value) public double clamp(double value) {
{
return ExtMath.clampd(value, this.minValue, this.maxValue); return ExtMath.clampd(value, this.minValue, this.maxValue);
} }
public int hashCode()
{
return this.name.hashCode();
}
public boolean equals(Object obj)
{
return obj instanceof Attribute && this.name.equals(((Attribute)obj).getUnlocalizedName());
}
} }

View file

@ -24,7 +24,7 @@ public class AttributeInstance
{ {
this.attributeMap = attributeMapIn; this.attributeMap = attributeMapIn;
this.genericAttribute = genericAttributeIn; this.genericAttribute = genericAttributeIn;
this.baseValue = genericAttributeIn.getDefaultValue(); this.baseValue = genericAttributeIn.getDefault();
} }
public Attribute getAttribute() public Attribute getAttribute()
@ -168,7 +168,7 @@ public class AttributeInstance
base *= 1.0D + attributemodifier2.getAmount(); base *= 1.0D + attributemodifier2.getAmount();
} }
return this.genericAttribute.clampValue(base); return this.genericAttribute.clamp(base);
} }
// private Collection<AttributeModifier> getModifierList(AttributeOp operation) // private Collection<AttributeModifier> getModifierList(AttributeOp operation)

View file

@ -40,10 +40,10 @@ public class AttributeMap
public AttributeInstance registerAttribute(Attribute attribute) public AttributeInstance registerAttribute(Attribute attribute)
{ {
if(this.nameMap.containsKey(attribute.getUnlocalizedName())) if(this.nameMap.containsKey(attribute.getName()))
throw new IllegalArgumentException("Attribute is already registered!"); throw new IllegalArgumentException("Attribute is already registered!");
AttributeInstance inst = new AttributeInstance(this, attribute); AttributeInstance inst = new AttributeInstance(this, attribute);
this.nameMap.put(attribute.getUnlocalizedName(), inst); this.nameMap.put(attribute.getName(), inst);
this.attributes.put(attribute, inst); this.attributes.put(attribute, inst);
// for (BaseAttribute iattribute = attribute.func_180372_d(); iattribute != null; iattribute = iattribute.func_180372_d()) // 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) public void flagDirty(AttributeInstance instance)
{ {
if (this.dirtyAttributes != null && instance.getAttribute().getShouldWatch()) if (this.dirtyAttributes != null && instance.getAttribute().isWatched())
{ {
this.dirtyAttributes.add(instance); this.dirtyAttributes.add(instance);
} }
@ -88,7 +88,7 @@ public class AttributeMap
for (AttributeInstance iattributeinstance : this.getAllAttributes()) for (AttributeInstance iattributeinstance : this.getAllAttributes())
{ {
if (iattributeinstance.getAttribute().getShouldWatch()) if (iattributeinstance.getAttribute().isWatched())
{ {
set.add(iattributeinstance); set.add(iattributeinstance);
} }
@ -101,7 +101,7 @@ public class AttributeMap
{ {
for (Entry<Attribute, Set<AttributeModifier>> entry : modifiers.entrySet()) for (Entry<Attribute, Set<AttributeModifier>> entry : modifiers.entrySet())
{ {
AttributeInstance iattributeinstance = this.getAttributeInstanceByName(entry.getKey().getUnlocalizedName()); AttributeInstance iattributeinstance = this.getAttributeInstanceByName(entry.getKey().getName());
if (iattributeinstance != null) if (iattributeinstance != null)
{ {
@ -116,7 +116,7 @@ public class AttributeMap
{ {
for (Entry<Attribute, Set<AttributeModifier>> entry : modifiers.entrySet()) for (Entry<Attribute, Set<AttributeModifier>> entry : modifiers.entrySet())
{ {
AttributeInstance iattributeinstance = this.getAttributeInstanceByName(entry.getKey().getUnlocalizedName()); AttributeInstance iattributeinstance = this.getAttributeInstanceByName(entry.getKey().getName());
if (iattributeinstance != null) if (iattributeinstance != null)
{ {
@ -132,7 +132,7 @@ public class AttributeMap
{ {
for (Entry<Attribute, Set<AttributeModifier>> entry : modifiers.entrySet()) for (Entry<Attribute, Set<AttributeModifier>> entry : modifiers.entrySet())
{ {
AttributeInstance iattributeinstance = this.getAttributeInstanceByName(entry.getKey().getUnlocalizedName()); AttributeInstance iattributeinstance = this.getAttributeInstanceByName(entry.getKey().getName());
if (iattributeinstance != null) if (iattributeinstance != null)
{ {
@ -148,7 +148,7 @@ public class AttributeMap
{ {
for (Entry<Attribute, Set<AttributeModifier>> entry : modifiers.entrySet()) for (Entry<Attribute, Set<AttributeModifier>> entry : modifiers.entrySet())
{ {
AttributeInstance iattributeinstance = this.getAttributeInstanceByName(entry.getKey().getUnlocalizedName()); AttributeInstance iattributeinstance = this.getAttributeInstanceByName(entry.getKey().getName());
if (iattributeinstance != null) if (iattributeinstance != null)
{ {

View file

@ -7,155 +7,104 @@ import common.log.Log;
import common.tags.TagObject; import common.tags.TagObject;
import java.util.List; import java.util.List;
public class Attributes 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 Attribute MAX_HEALTH = (new Attribute("generic.maxHealth", "Maximale Gesundheit", 20.0D, 0.0D, 1024.0D, true)); public static final AttributeModifier MAGE_POTSPEED_MOD = new AttributeModifier(AttributeModifier.getModifierId("MagePot"), "Drinking speed penalty", -0.25, false, false);
public static final Attribute FOLLOW_RANGE = (new Attribute("generic.followRange", "Kreaturen-Folgedistanz", 32.0D, 0.0D, 2048.0D, false)); public static final AttributeModifier ZOMBIE_BABY_MOD = new AttributeModifier(AttributeModifier.getModifierId("ZombSpd"), "Baby speed boost", 0.5, true);
public static final Attribute KNOCKBACK_RESISTANCE = (new Attribute("generic.knockbackResistance", "Standfestigkeit", 0.0D, 0.0D, 1.0D, false)); public static final AttributeModifier FLEEING_SPEED_MOD = new AttributeModifier(AttributeModifier.getModifierId("FleeSpd"), "Fleeing speed bonus", 2.0, true, false);
public static final Attribute MOVEMENT_SPEED = (new Attribute("generic.movementSpeed", "Geschwindigkeit", 0.699999988079071D, 0.0D, 1024.0D, true)); public static final AttributeModifier SPRINT_SPEED_MOD = new AttributeModifier(AttributeModifier.getModifierId("Sprint"), "Sprinting speed boost", 0.3, true, false);
public static final Attribute ATTACK_DAMAGE = new Attribute("generic.attackDamage", "Angriffsschaden", 2.0D, 0.0D, 2048.0D, false); public static final AttributeModifier MOUSE_SPEEDY_MOD = new AttributeModifier(AttributeModifier.getModifierId("SpeedyG"), "Mouse speed boost", 1.0, true);
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 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 ITEM_VAL_ID = AttributeModifier.getModifierId("ItemVal");
public static final long RADIATION_BASE = AttributeModifier.getModifierId("NukeVal"); public static final long ITEM_DMG_ID = AttributeModifier.getModifierId("ItemDmg");
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 List<TagObject> writeBaseAttributeMapToNBT(AttributeMap map) {
* Creates an NBTTagList from a BaseAttributeMap, including all its AttributeInstances List<TagObject> attrs = Lists.newArrayList();
*/
public static List<TagObject> writeBaseAttributeMapToNBT(AttributeMap map)
{
List<TagObject> nbttaglist = Lists.newArrayList();
for (AttributeInstance iattributeinstance : map.getAllAttributes()) for(AttributeInstance instance : map.getAllAttributes()) {
{ attrs.add(writeAttributeInstanceToNBT(instance));
nbttaglist.add(writeAttributeInstanceToNBT(iattributeinstance));
} }
return nbttaglist; return attrs;
} }
/** private static TagObject writeAttributeInstanceToNBT(AttributeInstance instance) {
* Creates an NBTTagCompound from an AttributeInstance, including its AttributeModifiers TagObject tag = new TagObject();
*/ Attribute attr = instance.getAttribute();
private static TagObject writeAttributeInstanceToNBT(AttributeInstance instance) tag.setString("Name", attr.getName());
{ tag.setDouble("Base", instance.getBaseValue());
TagObject nbttagcompound = new TagObject(); Collection<AttributeModifier> modifiers = instance.getModifiers();
Attribute iattribute = instance.getAttribute();
nbttagcompound.setString("Name", iattribute.getUnlocalizedName());
nbttagcompound.setDouble("Base", instance.getBaseValue());
Collection<AttributeModifier> collection = instance.getModifiers();
if (collection != null && !collection.isEmpty()) if(modifiers != null && !modifiers.isEmpty()) {
{ List<TagObject> mods = Lists.newArrayList();
List<TagObject> nbttaglist = Lists.newArrayList();
for (AttributeModifier attributemodifier : collection) for(AttributeModifier mod : modifiers) {
{ if(mod.isSaved()) {
if (attributemodifier.isSaved()) mods.add(writeAttributeModifierToNBT(mod));
{
nbttaglist.add(writeAttributeModifierToNBT(attributemodifier));
} }
} }
nbttagcompound.setList("Modifiers", nbttaglist); tag.setList("Modifiers", mods);
} }
return nbttagcompound; return tag;
} }
/** private static TagObject writeAttributeModifierToNBT(AttributeModifier mod) {
* Creates an NBTTagCompound from an AttributeModifier TagObject tag = new TagObject();
*/ tag.setString("Name", mod.getName());
private static TagObject writeAttributeModifierToNBT(AttributeModifier modifier) tag.setDouble("Amount", mod.getAmount());
{ tag.setBool("Multiply", mod.isMultiplied());
TagObject nbttagcompound = new TagObject(); tag.setLong("AttrId", mod.getID());
nbttagcompound.setString("Name", modifier.getName()); return tag;
nbttagcompound.setDouble("Amount", modifier.getAmount());
nbttagcompound.setBool("Multiply", modifier.isMultiplied());
nbttagcompound.setLong("AttrId", modifier.getID());
return nbttagcompound;
} }
public static void setAttributeModifiers(AttributeMap map, List<TagObject> list) public static void setAttributeModifiers(AttributeMap map, List<TagObject> mods) {
{ for(int i = 0; i < mods.size(); ++i) {
for (int i = 0; i < list.size(); ++i) TagObject mod = mods.get(i);
{ AttributeInstance instance = map.getAttributeInstanceByName(mod.getString("Name"));
TagObject nbttagcompound = list.get(i);
AttributeInstance iattributeinstance = map.getAttributeInstanceByName(nbttagcompound.getString("Name"));
if (iattributeinstance != null) if(instance != null) {
{ applyModifiersToAttributeInstance(instance, mod);
applyModifiersToAttributeInstance(iattributeinstance, nbttagcompound);
} }
else else {
{ Log.TICK.warn("Ignoriere unbekannte Attribute \'" + mod.getString("Name") + "\'");
Log.TICK.warn("Ignoriere unbekannte Attribute \'" + nbttagcompound.getString("Name") + "\'");
} }
} }
} }
private static void applyModifiersToAttributeInstance(AttributeInstance instance, TagObject compound) private static void applyModifiersToAttributeInstance(AttributeInstance instance, TagObject tag) {
{ instance.setBaseValue(tag.getDouble("Base"));
instance.setBaseValue(compound.getDouble("Base"));
if (compound.hasList("Modifiers")) if(tag.hasList("Modifiers")) {
{ List<TagObject> mods = tag.getList("Modifiers");
List<TagObject> nbttaglist = compound.getList("Modifiers");
for (int i = 0; i < nbttaglist.size(); ++i) for(int i = 0; i < mods.size(); ++i) {
{ AttributeModifier mod = readAttributeModifierFromNBT(mods.get(i));
AttributeModifier attributemodifier = readAttributeModifierFromNBT(nbttaglist.get(i));
if (attributemodifier != null) if(mod != null) {
{ AttributeModifier old = instance.getModifier(mod.getID());
AttributeModifier attributemodifier1 = instance.getModifier(attributemodifier.getID());
if (attributemodifier1 != null) if(old != null) {
{ instance.removeModifier(old);
instance.removeModifier(attributemodifier1);
} }
instance.applyModifier(attributemodifier); instance.applyModifier(mod);
} }
} }
} }
} }
/** public static AttributeModifier readAttributeModifierFromNBT(TagObject tag) {
* Creates an AttributeModifier from an NBTTagCompound long id = tag.getLong("AttrId");
*/
public static AttributeModifier readAttributeModifierFromNBT(TagObject compound)
{
long id = compound.getLong("AttrId");
if(id == 0L) if(id == 0L)
return null; return null;
try try {
{ return new AttributeModifier(id, tag.getString("Name"), tag.getDouble("Amount"), tag.getBool("Multiply"));
return new AttributeModifier(id, compound.getString("Name"), compound.getDouble("Amount"), compound.getBool("Multiply"));
} }
catch (Exception exception) catch(Exception e) {
{ Log.TICK.warn("Konnte Attribute nicht erstellen: " + e.getMessage());
Log.TICK.warn("Konnte Attribute nicht erstellen: " + exception.getMessage());
return null; return null;
} }
} }

View file

@ -21,7 +21,7 @@ import common.packet.SPacketSoundEffect;
import common.properties.IProperty; import common.properties.IProperty;
import common.properties.PropertyDirection; import common.properties.PropertyDirection;
import common.tileentity.ILockableContainer; import common.tileentity.ILockableContainer;
import common.tileentity.LockCode; import common.tileentity.Passcode;
import common.tileentity.TileEntity; import common.tileentity.TileEntity;
import common.tileentity.TileEntityChest; import common.tileentity.TileEntityChest;
import common.util.BlockPos; import common.util.BlockPos;
@ -446,8 +446,8 @@ public class BlockChest extends BlockContainer
ItemStack stack = Config.locking ? playerIn.getHeldItem() : null; ItemStack stack = Config.locking ? playerIn.getHeldItem() : null;
if(stack != null && stack.getItem() == Items.key) { if(stack != null && stack.getItem() == Items.key) {
if(ilockablecontainer.isLocked()) { if(ilockablecontainer.isLocked()) {
if(stack.hasDisplayName() && stack.getDisplayName().equals(ilockablecontainer.getLockCode().getLock())) { if(stack.hasDisplayName() && stack.getDisplayName().equals(ilockablecontainer.getLockCode().code())) {
ilockablecontainer.setLockCode(LockCode.EMPTY_CODE); ilockablecontainer.setLockCode(Passcode.EMPTY_CODE);
// playerIn.triggerAchievement(StatRegistry.chestUnlockedStat); // playerIn.triggerAchievement(StatRegistry.chestUnlockedStat);
playerIn.connection.addHotbar(TextColor.BLUE + "%s wurde entriegelt", ilockablecontainer.getCommandName()); 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)); 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()) { else if(stack.hasDisplayName()) {
ilockablecontainer.setLockCode(new LockCode(stack.getDisplayName())); ilockablecontainer.setLockCode(new Passcode(stack.getDisplayName()));
// playerIn.triggerAchievement(StatRegistry.chestLockedStat); // playerIn.triggerAchievement(StatRegistry.chestLockedStat);
playerIn.connection.addHotbar(TextColor.ORANGE + "%s wurde verriegelt", ilockablecontainer.getCommandName()); 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)); playerIn.connection.sendPacket(new SPacketSoundEffect(SoundEvent.DOOR, playerIn.posX, playerIn.posY, playerIn.posZ, 1.0F));

View file

@ -7,7 +7,8 @@ import common.dispenser.BehaviorDefaultDispenseItem;
import common.dispenser.IBehaviorDispenseItem; import common.dispenser.IBehaviorDispenseItem;
import common.dispenser.IBlockSource; import common.dispenser.IBlockSource;
import common.dispenser.IPosition; import common.dispenser.IPosition;
import common.dispenser.PositionImpl; import common.dispenser.DispenserPos;
import common.dispenser.DispenserSource;
import common.entity.npc.EntityNPC; import common.entity.npc.EntityNPC;
import common.entity.types.EntityLiving; import common.entity.types.EntityLiving;
import common.init.DispenserRegistry; import common.init.DispenserRegistry;
@ -125,7 +126,7 @@ public class BlockDispenser extends BlockContainer
protected void dispense(World worldIn, BlockPos pos) protected void dispense(World worldIn, BlockPos pos)
{ {
BlockSourceImpl blocksourceimpl = new BlockSourceImpl(worldIn, pos); DispenserSource blocksourceimpl = new DispenserSource(worldIn, pos);
TileEntityDispenser tileentitydispenser = (TileEntityDispenser)blocksourceimpl.getBlockTileEntity(); TileEntityDispenser tileentitydispenser = (TileEntityDispenser)blocksourceimpl.getBlockTileEntity();
if (tileentitydispenser != null) if (tileentitydispenser != null)
@ -239,7 +240,7 @@ public class BlockDispenser extends BlockContainer
double d0 = coords.getX() + 0.7D * (double)enumfacing.getFrontOffsetX(); double d0 = coords.getX() + 0.7D * (double)enumfacing.getFrontOffsetX();
double d1 = coords.getY() + 0.7D * (double)enumfacing.getFrontOffsetY(); double d1 = coords.getY() + 0.7D * (double)enumfacing.getFrontOffsetY();
double d2 = coords.getZ() + 0.7D * (double)enumfacing.getFrontOffsetZ(); double d2 = coords.getZ() + 0.7D * (double)enumfacing.getFrontOffsetZ();
return new PositionImpl(d0, d1, d2); return new DispenserPos(d0, d1, d2);
} }
/** /**

View file

@ -1,6 +1,7 @@
package common.block.tech; package common.block.tech;
import common.dispenser.BehaviorDefaultDispenseItem; import common.dispenser.BehaviorDefaultDispenseItem;
import common.dispenser.DispenserSource;
import common.dispenser.IBehaviorDispenseItem; import common.dispenser.IBehaviorDispenseItem;
import common.inventory.IInventory; import common.inventory.IInventory;
import common.item.ItemStack; import common.item.ItemStack;
@ -31,7 +32,7 @@ public class BlockDropper extends BlockDispenser
protected void dispense(World worldIn, BlockPos pos) protected void dispense(World worldIn, BlockPos pos)
{ {
BlockSourceImpl blocksourceimpl = new BlockSourceImpl(worldIn, pos); DispenserSource blocksourceimpl = new DispenserSource(worldIn, pos);
TileEntityDispenser tileentitydispenser = (TileEntityDispenser)blocksourceimpl.getBlockTileEntity(); TileEntityDispenser tileentitydispenser = (TileEntityDispenser)blocksourceimpl.getBlockTileEntity();
if (tileentitydispenser != null) if (tileentitydispenser != null)

View file

@ -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 extends TileEntity> T getBlockTileEntity()
{
return (T)this.worldObj.getTileEntity(this.pos);
}
}

View file

@ -1204,13 +1204,13 @@ public abstract class Dimension extends Nameable implements Comparable<Dimension
List<TagObject> list = Lists.newArrayList(); List<TagObject> list = Lists.newArrayList();
for(Ore gen : this.ores) { for(Ore gen : this.ores) {
TagObject ore = new TagObject(); TagObject ore = new TagObject();
ore.setString("Block", BlockRegistry.toIdName(gen.state)); ore.setString("Block", BlockRegistry.toIdName(gen.state()));
ore.setBool("Distrib", gen.dist); ore.setBool("Distrib", gen.dist());
ore.setInt("Size", gen.size); ore.setInt("Size", gen.size());
ore.setInt("Count", gen.count); ore.setInt("Count", gen.count());
ore.setInt("Add", gen.more); ore.setInt("Add", gen.more());
ore.setInt("MinC", gen.min); ore.setInt("MinC", gen.min());
ore.setInt("MaxS", gen.max); ore.setInt("MaxS", gen.max());
list.add(ore); list.add(ore);
} }
tag.setList("Ores", list); tag.setList("Ores", list);
@ -1219,15 +1219,15 @@ public abstract class Dimension extends Nameable implements Comparable<Dimension
List<TagObject> list = Lists.newArrayList(); List<TagObject> list = Lists.newArrayList();
for(Lake gen : this.lakes) { for(Lake gen : this.lakes) {
TagObject lake = new TagObject(); TagObject lake = new TagObject();
lake.setString("Block", BlockRegistry.toIdName(gen.state)); lake.setString("Block", BlockRegistry.toIdName(gen.state()));
if(gen.filler != null) if(gen.filler() != null)
lake.setString("Filler", BlockRegistry.toIdName(gen.filler)); lake.setString("Filler", BlockRegistry.toIdName(gen.filler()));
if(gen.top != null) if(gen.top() != null)
lake.setString("Top", BlockRegistry.toIdName(gen.top)); lake.setString("Top", BlockRegistry.toIdName(gen.top()));
lake.setBool("Ratiod", gen.ratiod); lake.setBool("Ratiod", gen.ratiod());
lake.setInt("Chance", gen.chance); lake.setInt("Chance", gen.chance());
lake.setInt("Min", gen.minHeight); lake.setInt("Min", gen.minHeight());
lake.setInt("Max", gen.maxHeight); lake.setInt("Max", gen.maxHeight());
list.add(lake); list.add(lake);
} }
tag.setList("Lakes", list); tag.setList("Lakes", list);
@ -1236,11 +1236,11 @@ public abstract class Dimension extends Nameable implements Comparable<Dimension
List<TagObject> list = Lists.newArrayList(); List<TagObject> list = Lists.newArrayList();
for(Liquid gen : this.liquids) { for(Liquid gen : this.liquids) {
TagObject liquid = new TagObject(); TagObject liquid = new TagObject();
liquid.setString("Block", BlockRegistry.toIdName(gen.state)); liquid.setString("Block", BlockRegistry.toIdName(gen.state()));
liquid.setBool("Lower", gen.lower); liquid.setBool("Lower", gen.lower());
liquid.setInt("Chance", gen.chance); liquid.setInt("Chance", gen.chance());
liquid.setInt("Min", gen.minHeight); liquid.setInt("Min", gen.minHeight());
liquid.setInt("Max", gen.maxHeight); liquid.setInt("Max", gen.maxHeight());
list.add(liquid); list.add(liquid);
} }
tag.setList("Liquids", list); tag.setList("Liquids", list);

View file

@ -2,22 +2,5 @@ package common.dimension;
import common.world.State; import common.world.State;
public class Lake { public record Lake(State state, State filler, State top, int chance, int minHeight, int maxHeight, boolean ratiod) {
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;
}
} }

View file

@ -2,18 +2,5 @@ package common.dimension;
import common.world.State; import common.world.State;
public class Liquid { public record Liquid(State state, int chance, int minHeight, int maxHeight, boolean lower) {
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;
}
} }

View file

@ -2,22 +2,5 @@ package common.dimension;
import common.world.State; import common.world.State;
public class Ore { public record Ore(State state, int count, int more, int size, int min, int max, boolean dist) {
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;
}
} }

View file

@ -0,0 +1,4 @@
package common.dispenser;
public record DispenserPos(double getX, double getY, double getZ) implements IPosition {
}

View file

@ -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 extends TileEntity> T getBlockTileEntity() {
return (T)this.getWorld.getTileEntity(this.getBlockPos);
}
}

View file

@ -2,8 +2,9 @@ package common.dispenser;
import common.tileentity.TileEntity; import common.tileentity.TileEntity;
import common.util.BlockPos; import common.util.BlockPos;
import common.world.World;
public interface IBlockSource extends ILocatableSource public interface IBlockSource extends IPosition
{ {
double getX(); double getX();
@ -11,6 +12,8 @@ public interface IBlockSource extends ILocatableSource
double getZ(); double getZ();
World getWorld();
BlockPos getBlockPos(); BlockPos getBlockPos();
int getBlockMetadata(); int getBlockMetadata();

View file

@ -1,5 +0,0 @@
package common.dispenser;
public interface ILocatableSource extends ILocation
{
}

View file

@ -1,8 +0,0 @@
package common.dispenser;
import common.world.World;
public interface ILocation extends IPosition
{
World getWorld();
}

View file

@ -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;
}
}

View file

@ -1826,7 +1826,7 @@ public abstract class Entity
// } // }
public final void teleport(Position pos) { 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) { public final void teleport(BlockPos pos, int dim) {

View file

@ -8,7 +8,7 @@ import common.ai.EntityAISwimming;
import common.ai.EntityAITempt; import common.ai.EntityAITempt;
import common.ai.EntityAIWander; import common.ai.EntityAIWander;
import common.ai.EntityAIWatchClosest; import common.ai.EntityAIWatchClosest;
import common.attributes.Attributes; import common.attributes.Attribute;
import common.entity.npc.EntityNPC; import common.entity.npc.EntityNPC;
import common.entity.types.EntityAnimal; import common.entity.types.EntityAnimal;
import common.entity.types.EntityLiving; import common.entity.types.EntityLiving;
@ -57,7 +57,7 @@ public class EntityChicken extends EntityAnimal
{ {
super.applyEntityAttributes(); super.applyEntityAttributes();
this.setMaxHealth(4); this.setMaxHealth(4);
this.getEntityAttribute(Attributes.MOVEMENT_SPEED).setBaseValue(0.25D); this.getEntityAttribute(Attribute.MOVEMENT_SPEED).setBaseValue(0.25D);
} }
/** /**

View file

@ -8,7 +8,7 @@ import common.ai.EntityAISwimming;
import common.ai.EntityAITempt; import common.ai.EntityAITempt;
import common.ai.EntityAIWander; import common.ai.EntityAIWander;
import common.ai.EntityAIWatchClosest; import common.ai.EntityAIWatchClosest;
import common.attributes.Attributes; import common.attributes.Attribute;
import common.entity.npc.EntityNPC; import common.entity.npc.EntityNPC;
import common.entity.types.EntityAnimal; import common.entity.types.EntityAnimal;
import common.entity.types.EntityLiving; import common.entity.types.EntityLiving;
@ -40,7 +40,7 @@ public class EntityCow extends EntityAnimal
{ {
super.applyEntityAttributes(); super.applyEntityAttributes();
this.setMaxHealth(10); this.setMaxHealth(10);
this.getEntityAttribute(Attributes.MOVEMENT_SPEED).setBaseValue(0.20000000298023224D); this.getEntityAttribute(Attribute.MOVEMENT_SPEED).setBaseValue(0.20000000298023224D);
} }
/** /**

View file

@ -10,8 +10,8 @@ import common.ai.EntityAIRunAroundLikeCrazy;
import common.ai.EntityAISwimming; import common.ai.EntityAISwimming;
import common.ai.EntityAIWander; import common.ai.EntityAIWander;
import common.ai.EntityAIWatchClosest; import common.ai.EntityAIWatchClosest;
import common.attributes.Attribute;
import common.attributes.AttributeInstance; import common.attributes.AttributeInstance;
import common.attributes.Attributes;
import common.block.Block; import common.block.Block;
import common.block.SoundType; import common.block.SoundType;
import common.collect.Lists; import common.collect.Lists;
@ -553,7 +553,7 @@ public class EntityHorse extends EntityAnimal implements IInvBasic
public double getHorseJumpStrength() 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() protected void applyEntityAttributes()
{ {
super.applyEntityAttributes(); super.applyEntityAttributes();
this.getAttributeMap().registerAttribute(Attributes.HORSE_JUMP_STRENGTH); this.getAttributeMap().registerAttribute(Attribute.HORSE_JUMP_STRENGTH);
this.setMaxHealth(53); 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) 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); super.moveEntityWithHeading(strafe, forward);
} }
@ -1462,7 +1462,7 @@ public class EntityHorse extends EntityAnimal implements IInvBasic
if (iattributeinstance != null) 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()) if (this.isChested())
@ -1595,10 +1595,10 @@ public class EntityHorse extends EntityAnimal implements IInvBasic
entityhorse1.setHorseType(k); entityhorse1.setHorseType(k);
int d1 = this.getRawMaxHealth() + ageable.getRawMaxHealth() + this.getModifiedMaxHealth(); int d1 = this.getRawMaxHealth() + ageable.getRawMaxHealth() + this.getModifiedMaxHealth();
entityhorse1.setMaxHealth(d1 / 3); entityhorse1.setMaxHealth(d1 / 3);
double d2 = this.getEntityAttribute(Attributes.HORSE_JUMP_STRENGTH).getBaseValue() + ageable.getEntityAttribute(Attributes.HORSE_JUMP_STRENGTH).getBaseValue() + this.getModifiedJumpStrength(); double d2 = this.getEntityAttribute(Attribute.HORSE_JUMP_STRENGTH).getBaseValue() + ageable.getEntityAttribute(Attribute.HORSE_JUMP_STRENGTH).getBaseValue() + this.getModifiedJumpStrength();
entityhorse1.getEntityAttribute(Attributes.HORSE_JUMP_STRENGTH).setBaseValue(d2 / 3.0D); entityhorse1.getEntityAttribute(Attribute.HORSE_JUMP_STRENGTH).setBaseValue(d2 / 3.0D);
double d0 = this.getEntityAttribute(Attributes.MOVEMENT_SPEED).getBaseValue() + ageable.getEntityAttribute(Attributes.MOVEMENT_SPEED).getBaseValue() + this.getModifiedMovementSpeed(); double d0 = this.getEntityAttribute(Attribute.MOVEMENT_SPEED).getBaseValue() + ageable.getEntityAttribute(Attribute.MOVEMENT_SPEED).getBaseValue() + this.getModifiedMovementSpeed();
entityhorse1.getEntityAttribute(Attributes.MOVEMENT_SPEED).setBaseValue(d0 / 3.0D); entityhorse1.getEntityAttribute(Attribute.MOVEMENT_SPEED).setBaseValue(d0 / 3.0D);
return entityhorse1; return entityhorse1;
} }
@ -1648,26 +1648,26 @@ public class EntityHorse extends EntityAnimal implements IInvBasic
if (i == 0) if (i == 0)
{ {
this.getEntityAttribute(Attributes.MOVEMENT_SPEED).setBaseValue(this.getModifiedMovementSpeed()); this.getEntityAttribute(Attribute.MOVEMENT_SPEED).setBaseValue(this.getModifiedMovementSpeed());
} }
else else
{ {
this.getEntityAttribute(Attributes.MOVEMENT_SPEED).setBaseValue(0.17499999701976776D); this.getEntityAttribute(Attribute.MOVEMENT_SPEED).setBaseValue(0.17499999701976776D);
} }
} }
else else
{ {
this.setMaxHealth(15); this.setMaxHealth(15);
this.getEntityAttribute(Attributes.MOVEMENT_SPEED).setBaseValue(0.20000000298023224D); this.getEntityAttribute(Attribute.MOVEMENT_SPEED).setBaseValue(0.20000000298023224D);
} }
if (i != 2 && i != 1) if (i != 2 && i != 1)
{ {
this.getEntityAttribute(Attributes.HORSE_JUMP_STRENGTH).setBaseValue(this.getModifiedJumpStrength()); this.getEntityAttribute(Attribute.HORSE_JUMP_STRENGTH).setBaseValue(this.getModifiedJumpStrength());
} }
else else
{ {
this.getEntityAttribute(Attributes.HORSE_JUMP_STRENGTH).setBaseValue(0.5D); this.getEntityAttribute(Attribute.HORSE_JUMP_STRENGTH).setBaseValue(0.5D);
} }
this.setHealth(this.getMaxHealth()); this.setHealth(this.getMaxHealth());

View file

@ -10,6 +10,7 @@ import common.ai.EntityAISwimming;
import common.ai.EntityAITempt; import common.ai.EntityAITempt;
import common.ai.EntityAIWander; import common.ai.EntityAIWander;
import common.ai.EntityAIWatchClosest; import common.ai.EntityAIWatchClosest;
import common.attributes.Attribute;
import common.attributes.AttributeInstance; import common.attributes.AttributeInstance;
import common.attributes.Attributes; import common.attributes.Attributes;
import common.block.Block; import common.block.Block;
@ -46,7 +47,7 @@ public class EntityMouse extends EntityAnimal {
protected void applyEntityAttributes() { protected void applyEntityAttributes() {
super.applyEntityAttributes(); super.applyEntityAttributes();
this.setMaxHealth(1); this.setMaxHealth(1);
this.getEntityAttribute(Attributes.MOVEMENT_SPEED).setBaseValue(0.25D); this.getEntityAttribute(Attribute.MOVEMENT_SPEED).setBaseValue(0.25D);
} }
// protected String getLivingSound() { // protected String getLivingSound() {
@ -119,7 +120,7 @@ public class EntityMouse extends EntityAnimal {
public void setCustomNameTag(String name) { public void setCustomNameTag(String name) {
super.setCustomNameTag(name); super.setCustomNameTag(name);
if(this.worldObj != null && !this.worldObj.client) { 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); speed.removeModifier(Attributes.MOUSE_SPEEDY_MOD);
if(name.equals("Gonzales") || name.equals("Gonzalez")) if(name.equals("Gonzales") || name.equals("Gonzalez"))
speed.applyModifier(Attributes.MOUSE_SPEEDY_MOD); speed.applyModifier(Attributes.MOUSE_SPEEDY_MOD);

View file

@ -13,7 +13,7 @@ import common.ai.EntityAITargetNonTamed;
import common.ai.EntityAITempt; import common.ai.EntityAITempt;
import common.ai.EntityAIWander; import common.ai.EntityAIWander;
import common.ai.EntityAIWatchClosest; import common.ai.EntityAIWatchClosest;
import common.attributes.Attributes; import common.attributes.Attribute;
import common.entity.DamageSource; import common.entity.DamageSource;
import common.entity.Entity; import common.entity.Entity;
import common.entity.npc.Alignment; import common.entity.npc.Alignment;
@ -113,7 +113,7 @@ public class EntityOcelot extends EntityTameable
{ {
super.applyEntityAttributes(); super.applyEntityAttributes();
this.setMaxHealth(10); 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) public void fall(float distance, float damageMultiplier)

View file

@ -9,7 +9,7 @@ import common.ai.EntityAISwimming;
import common.ai.EntityAITempt; import common.ai.EntityAITempt;
import common.ai.EntityAIWander; import common.ai.EntityAIWander;
import common.ai.EntityAIWatchClosest; import common.ai.EntityAIWatchClosest;
import common.attributes.Attributes; import common.attributes.Attribute;
import common.entity.npc.EntityNPC; import common.entity.npc.EntityNPC;
import common.entity.types.EntityAnimal; import common.entity.types.EntityAnimal;
import common.entity.types.EntityLiving; import common.entity.types.EntityLiving;
@ -47,7 +47,7 @@ public class EntityPig extends EntityAnimal
{ {
super.applyEntityAttributes(); super.applyEntityAttributes();
this.setMaxHealth(10); this.setMaxHealth(10);
this.getEntityAttribute(Attributes.MOVEMENT_SPEED).setBaseValue(0.25D); this.getEntityAttribute(Attribute.MOVEMENT_SPEED).setBaseValue(0.25D);
} }
/** /**

View file

@ -15,7 +15,7 @@ import common.ai.EntityAIWander;
import common.ai.EntityAIWatchClosest; import common.ai.EntityAIWatchClosest;
import common.ai.EntityJumpHelper; import common.ai.EntityJumpHelper;
import common.ai.EntityMoveHelper; import common.ai.EntityMoveHelper;
import common.attributes.Attributes; import common.attributes.Attribute;
import common.block.Block; import common.block.Block;
import common.block.foliage.BlockTallGrass; import common.block.foliage.BlockTallGrass;
import common.entity.DamageSource; import common.entity.DamageSource;
@ -195,7 +195,7 @@ public class EntityRabbit extends EntityAnimal {
protected void applyEntityAttributes() { protected void applyEntityAttributes() {
super.applyEntityAttributes(); super.applyEntityAttributes();
this.setMaxHealth(5); this.setMaxHealth(5);
this.getEntityAttribute(Attributes.MOVEMENT_SPEED).setBaseValue(0.30000001192092896D); this.getEntityAttribute(Attribute.MOVEMENT_SPEED).setBaseValue(0.30000001192092896D);
} }
public void writeEntity(TagObject tagCompound) { public void writeEntity(TagObject tagCompound) {

View file

@ -11,7 +11,7 @@ import common.ai.EntityAISwimming;
import common.ai.EntityAITempt; import common.ai.EntityAITempt;
import common.ai.EntityAIWander; import common.ai.EntityAIWander;
import common.ai.EntityAIWatchClosest; import common.ai.EntityAIWatchClosest;
import common.attributes.Attributes; import common.attributes.Attribute;
import common.biome.Biome; import common.biome.Biome;
import common.collect.Maps; import common.collect.Maps;
import common.color.DyeColor; import common.color.DyeColor;
@ -104,7 +104,7 @@ public class EntitySheep extends EntityAnimal
{ {
super.applyEntityAttributes(); super.applyEntityAttributes();
this.setMaxHealth(8); this.setMaxHealth(8);
this.getEntityAttribute(Attributes.MOVEMENT_SPEED).setBaseValue(0.23000000417232513D); this.getEntityAttribute(Attribute.MOVEMENT_SPEED).setBaseValue(0.23000000417232513D);
} }
protected void entityInit() protected void entityInit()

View file

@ -15,7 +15,7 @@ import common.ai.EntityAISwimming;
import common.ai.EntityAITargetNonTamed; import common.ai.EntityAITargetNonTamed;
import common.ai.EntityAIWander; import common.ai.EntityAIWander;
import common.ai.EntityAIWatchClosest; import common.ai.EntityAIWatchClosest;
import common.attributes.Attributes; import common.attributes.Attribute;
import common.color.DyeColor; import common.color.DyeColor;
import common.entity.DamageSource; import common.entity.DamageSource;
import common.entity.Entity; import common.entity.Entity;
@ -86,7 +86,7 @@ public class EntityWolf extends EntityTameable
protected void applyEntityAttributes() protected void applyEntityAttributes()
{ {
super.applyEntityAttributes(); super.applyEntityAttributes();
this.getEntityAttribute(Attributes.MOVEMENT_SPEED).setBaseValue(0.30000001192092896D); this.getEntityAttribute(Attribute.MOVEMENT_SPEED).setBaseValue(0.30000001192092896D);
if (this.isTamed()) if (this.isTamed())
{ {
@ -97,8 +97,8 @@ public class EntityWolf extends EntityTameable
this.setMaxHealth(8); this.setMaxHealth(8);
} }
this.getAttributeMap().registerAttribute(Attributes.ATTACK_DAMAGE); this.getAttributeMap().registerAttribute(Attribute.ATTACK_DAMAGE);
this.getEntityAttribute(Attributes.ATTACK_DAMAGE).setBaseValue(2.0D); this.getEntityAttribute(Attribute.ATTACK_DAMAGE).setBaseValue(2.0D);
} }
/** /**
@ -350,7 +350,7 @@ public class EntityWolf extends EntityTameable
{ {
if(!this.worldObj.client && !Config.damageMobs) if(!this.worldObj.client && !Config.damageMobs)
return false; 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) if (flag)
{ {
@ -373,7 +373,7 @@ public class EntityWolf extends EntityTameable
this.setMaxHealth(8); this.setMaxHealth(8);
} }
this.getEntityAttribute(Attributes.ATTACK_DAMAGE).setBaseValue(4.0D); this.getEntityAttribute(Attribute.ATTACK_DAMAGE).setBaseValue(4.0D);
} }
/** /**

View file

@ -11,7 +11,7 @@ import common.item.ItemStack;
import common.tags.TagObject; import common.tags.TagObject;
import java.util.List; import java.util.List;
import common.tileentity.ILockableContainer; import common.tileentity.ILockableContainer;
import common.tileentity.LockCode; import common.tileentity.Passcode;
import common.util.BlockPos; import common.util.BlockPos;
import common.util.PortalType; import common.util.PortalType;
import common.world.World; import common.world.World;
@ -269,13 +269,13 @@ public abstract class EntityCartContainer extends EntityCart implements ILockabl
return false; 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() public void clear()

View file

@ -1,9 +0,0 @@
package common.entity.npc;
public class ClassInfo {
public final Enum type;
public ClassInfo(Enum type) {
this.type = type;
}
}

View file

@ -2,7 +2,7 @@ package common.entity.npc;
import java.util.List; import java.util.List;
import common.attributes.Attributes; import common.attributes.Attribute;
import common.collect.Lists; import common.collect.Lists;
import common.init.Items; import common.init.Items;
import common.init.SpeciesRegistry; import common.init.SpeciesRegistry;
@ -118,7 +118,7 @@ public class EntityChaosMarine extends EntityNPC {
protected void applyEntityAttributes() { protected void applyEntityAttributes() {
super.applyEntityAttributes(); super.applyEntityAttributes();
this.getEntityAttribute(Attributes.ATTACK_DAMAGE).setBaseValue(12.0D); this.getEntityAttribute(Attribute.ATTACK_DAMAGE).setBaseValue(12.0D);
} }
protected ItemStack pickItem() { protected ItemStack pickItem() {

View file

@ -2,7 +2,7 @@ package common.entity.npc;
import common.ai.EntityAIBase; import common.ai.EntityAIBase;
import common.ai.EntityMoveHelper; import common.ai.EntityMoveHelper;
import common.attributes.Attributes; import common.attributes.Attribute;
import common.block.Block; import common.block.Block;
import common.entity.types.EntityLiving; import common.entity.types.EntityLiving;
import common.potion.Potion; import common.potion.Potion;
@ -25,7 +25,7 @@ public abstract class EntityFlyingNPC extends EntityNPC
protected void applyEntityAttributes() protected void applyEntityAttributes()
{ {
super.applyEntityAttributes(); super.applyEntityAttributes();
this.getEntityAttribute(Attributes.FOLLOW_RANGE).setBaseValue(48.0D); this.getEntityAttribute(Attribute.FOLLOW_RANGE).setBaseValue(48.0D);
} }
public float getArmRotation() { public float getArmRotation() {

View file

@ -1,7 +1,7 @@
package common.entity.npc; package common.entity.npc;
import common.ai.AIFlyingBoxAttack; import common.ai.AIFlyingBoxAttack;
import common.attributes.Attributes; import common.attributes.Attribute;
import common.entity.DamageSource; import common.entity.DamageSource;
import common.init.Config; import common.init.Config;
import common.item.ItemStack; import common.item.ItemStack;
@ -165,8 +165,8 @@ public class EntityGargoyle extends EntityFlyingNPC
protected void applyEntityAttributes() protected void applyEntityAttributes()
{ {
super.applyEntityAttributes(); super.applyEntityAttributes();
this.getEntityAttribute(Attributes.MOVEMENT_SPEED).setBaseValue(0.6000000238418579D); this.getEntityAttribute(Attribute.MOVEMENT_SPEED).setBaseValue(0.6000000238418579D);
this.getEntityAttribute(Attributes.FOLLOW_RANGE).setBaseValue(40.0D); this.getEntityAttribute(Attribute.FOLLOW_RANGE).setBaseValue(40.0D);
} }
public int getInvulTime() public int getInvulTime()

View file

@ -1,6 +1,6 @@
package common.entity.npc; package common.entity.npc;
import common.attributes.Attributes; import common.attributes.Attribute;
import common.entity.types.EntityLiving; import common.entity.types.EntityLiving;
import common.rng.Random; import common.rng.Random;
import common.world.World; import common.world.World;
@ -44,7 +44,7 @@ public class EntityGoblin extends EntityNPC {
protected void applyEntityAttributes() { protected void applyEntityAttributes() {
super.applyEntityAttributes(); super.applyEntityAttributes();
this.getEntityAttribute(Attributes.ATTACK_DAMAGE).setBaseValue(1.0D); this.getEntityAttribute(Attribute.ATTACK_DAMAGE).setBaseValue(1.0D);
} }
public boolean canAmbush(EntityLiving entity) { public boolean canAmbush(EntityLiving entity) {

View file

@ -1,7 +1,7 @@
package common.entity.npc; package common.entity.npc;
import common.ai.EntityAIExplode; import common.ai.EntityAIExplode;
import common.attributes.Attributes; import common.attributes.Attribute;
import common.entity.Entity; import common.entity.Entity;
import common.entity.effect.EntityLightning; import common.entity.effect.EntityLightning;
import common.entity.types.EntityLiving; import common.entity.types.EntityLiving;
@ -28,7 +28,7 @@ public class EntityHaunter extends EntityNPC {
protected void applyEntityAttributes() protected void applyEntityAttributes()
{ {
super.applyEntityAttributes(); super.applyEntityAttributes();
this.getEntityAttribute(Attributes.MOVEMENT_SPEED).setBaseValue(0.25D); this.getEntityAttribute(Attribute.MOVEMENT_SPEED).setBaseValue(0.25D);
} }
public int getMaxFallHeight() public int getMaxFallHeight()

View file

@ -1,6 +1,6 @@
package common.entity.npc; package common.entity.npc;
import common.attributes.Attributes; import common.attributes.Attribute;
import common.entity.types.EntityLiving; import common.entity.types.EntityLiving;
import common.packet.CPacketAction; import common.packet.CPacketAction;
import common.world.World; import common.world.World;
@ -34,7 +34,7 @@ public abstract class EntityHoveringNPC extends EntityNPC
protected void applyEntityAttributes() protected void applyEntityAttributes()
{ {
super.applyEntityAttributes(); super.applyEntityAttributes();
this.getEntityAttribute(Attributes.FOLLOW_RANGE).setBaseValue(32.0D); this.getEntityAttribute(Attribute.FOLLOW_RANGE).setBaseValue(32.0D);
} }
public boolean isSneakingVisually() { public boolean isSneakingVisually() {

View file

@ -2,6 +2,7 @@ package common.entity.npc;
import java.util.List; import java.util.List;
import common.attributes.Attribute;
import common.attributes.AttributeInstance; import common.attributes.AttributeInstance;
import common.attributes.Attributes; import common.attributes.Attributes;
import common.entity.effect.EntityLightning; 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 else
@ -86,7 +87,7 @@ public class EntityMage extends EntityNPC
this.setItem(0, new ItemStack(Items.potion, 1, i)); this.setItem(0, new ItemStack(Items.potion, 1, i));
this.attackTimer = this.getHeldItem().getMaxItemUseDuration(); this.attackTimer = this.getHeldItem().getMaxItemUseDuration();
this.drinking = true; this.drinking = true;
AttributeInstance iattributeinstance = this.getEntityAttribute(Attributes.MOVEMENT_SPEED); AttributeInstance iattributeinstance = this.getEntityAttribute(Attribute.MOVEMENT_SPEED);
iattributeinstance.removeModifier(Attributes.MAGE_POTSPEED_MOD); iattributeinstance.removeModifier(Attributes.MAGE_POTSPEED_MOD);
iattributeinstance.applyModifier(Attributes.MAGE_POTSPEED_MOD); iattributeinstance.applyModifier(Attributes.MAGE_POTSPEED_MOD);
} }

View file

@ -1,6 +1,7 @@
package common.entity.npc; package common.entity.npc;
import common.ai.EntityAIHurtByTarget; import common.ai.EntityAIHurtByTarget;
import common.attributes.Attribute;
import common.attributes.AttributeInstance; import common.attributes.AttributeInstance;
import common.attributes.Attributes; import common.attributes.Attributes;
import common.entity.DamageSource; import common.entity.DamageSource;
@ -62,7 +63,7 @@ public abstract class EntityMobNPC extends EntityNPC
protected void updateAITasks() protected void updateAITasks()
{ {
AttributeInstance iattributeinstance = this.getEntityAttribute(Attributes.MOVEMENT_SPEED); AttributeInstance iattributeinstance = this.getEntityAttribute(Attribute.MOVEMENT_SPEED);
if (this.isAngry()) if (this.isAngry())
{ {

View file

@ -19,8 +19,8 @@ import common.ai.EntityAISwimming;
import common.ai.EntityAIWander; import common.ai.EntityAIWander;
import common.ai.EntityAIWatchClosest; import common.ai.EntityAIWatchClosest;
import common.ai.EntityAIWatchClosest2; import common.ai.EntityAIWatchClosest2;
import common.attributes.Attribute;
import common.attributes.AttributeInstance; import common.attributes.AttributeInstance;
import common.attributes.Attributes;
import common.block.Block; import common.block.Block;
import common.block.artificial.BlockBed; import common.block.artificial.BlockBed;
import common.collect.Lists; import common.collect.Lists;
@ -86,7 +86,7 @@ import common.rng.Random;
import common.sound.MovingSoundMinecartRiding; import common.sound.MovingSoundMinecartRiding;
import common.tags.TagObject; import common.tags.TagObject;
import common.tileentity.IInteractionObject; import common.tileentity.IInteractionObject;
import common.tileentity.LockCode; import common.tileentity.Passcode;
import common.tileentity.TileEntitySign; import common.tileentity.TileEntitySign;
import common.util.BlockPos; import common.util.BlockPos;
import common.util.BoundingBox; import common.util.BoundingBox;
@ -385,7 +385,7 @@ public abstract class EntityNPC extends EntityLiving
this.fireResistance = 20; this.fireResistance = 20;
this.noPickup = true; this.noPickup = true;
// this.getEntityAttribute(Attributes.ATTACK_DAMAGE).setBaseValue(1.0D); // 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) { public final void setServerPlayer(IPlayer connection) {
@ -545,12 +545,12 @@ public abstract class EntityNPC extends EntityLiving
protected void applyEntityAttributes() protected void applyEntityAttributes()
{ {
super.applyEntityAttributes(); super.applyEntityAttributes();
this.getEntityAttribute(Attributes.FOLLOW_RANGE).setBaseValue(20.0D); this.getEntityAttribute(Attribute.FOLLOW_RANGE).setBaseValue(20.0D);
this.getAttributeMap().registerAttribute(Attributes.ATTACK_DAMAGE).setBaseValue(2.0D); this.getAttributeMap().registerAttribute(Attribute.ATTACK_DAMAGE).setBaseValue(2.0D);
this.getEntityAttribute(Attributes.MOVEMENT_SPEED).setBaseValue(0.3D); this.getEntityAttribute(Attribute.MOVEMENT_SPEED).setBaseValue(0.3D);
this.setMaxHealth(this.getBaseHealth(this.rand)); this.setMaxHealth(this.getBaseHealth(this.rand));
this.getAttributeMap().registerAttribute(Attributes.MANA_CAPACITY); this.getAttributeMap().registerAttribute(Attribute.MANA_CAPACITY);
this.getEntityAttribute(Attributes.MANA_CAPACITY).setBaseValue(20.0D); this.getEntityAttribute(Attribute.MANA_CAPACITY).setBaseValue(20.0D);
} }
// protected int getExperiencePoints(EntityNPC player) // protected int getExperiencePoints(EntityNPC player)
@ -682,7 +682,7 @@ public abstract class EntityNPC extends EntityLiving
{ {
if(!this.worldObj.client && !Config.damageMobs) if(!this.worldObj.client && !Config.damageMobs)
return false; return false;
int f = (int)this.getEntityAttribute(Attributes.ATTACK_DAMAGE).getAttributeValue(); int f = (int)this.getEntityAttribute(Attribute.ATTACK_DAMAGE).getAttributeValue();
int i = 0; int i = 0;
if (entityIn instanceof EntityLiving) if (entityIn instanceof EntityLiving)
@ -1187,7 +1187,7 @@ public abstract class EntityNPC extends EntityLiving
// } // }
public int getMaxMana() { public int getMaxMana() {
return (int)this.getEntityAttribute(Attributes.MANA_CAPACITY).getAttributeValue(); return (int)this.getEntityAttribute(Attribute.MANA_CAPACITY).getAttributeValue();
} }
public MerchantRecipeList getTrades(EntityNPC player) { public MerchantRecipeList getTrades(EntityNPC player) {
@ -2553,7 +2553,7 @@ public abstract class EntityNPC extends EntityLiving
this.prevCameraYaw = this.cameraYaw; this.prevCameraYaw = this.cameraYaw;
// super.onLivingUpdate(); // super.onLivingUpdate();
this.onNpcUpdate(); this.onNpcUpdate();
AttributeInstance iattributeinstance = this.getEntityAttribute(Attributes.MOVEMENT_SPEED); AttributeInstance iattributeinstance = this.getEntityAttribute(Attribute.MOVEMENT_SPEED);
this.jumpMovement = this.speedInAir; this.jumpMovement = this.speedInAir;
@ -3748,7 +3748,7 @@ public abstract class EntityNPC extends EntityLiving
{ {
if (!targetEntity.hitByEntity(this)) 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 i = 0;
int f1 = // 0; int f1 = // 0;
@ -3978,7 +3978,7 @@ public abstract class EntityNPC extends EntityLiving
*/ */
public float getAIMoveSpeed() 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(); 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; return true;
ItemStack stack = this.getCurrentEquippedItem(); ItemStack stack = this.getCurrentEquippedItem();
return stack != null && stack.getItem() == Items.key && 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) // public boolean isWearing(ModelPart part)

View file

@ -1,6 +1,6 @@
package common.entity.npc; package common.entity.npc;
import common.attributes.Attributes; import common.attributes.Attribute;
import common.rng.Random; import common.rng.Random;
import common.world.World; import common.world.World;
@ -72,6 +72,6 @@ public class EntityOrc extends EntityNPC {
protected void applyEntityAttributes() { protected void applyEntityAttributes() {
super.applyEntityAttributes(); super.applyEntityAttributes();
this.getEntityAttribute(Attributes.ATTACK_DAMAGE).setBaseValue(4.0D); this.getEntityAttribute(Attribute.ATTACK_DAMAGE).setBaseValue(4.0D);
} }
} }

View file

@ -2,7 +2,7 @@ package common.entity.npc;
import java.util.List; import java.util.List;
import common.attributes.Attributes; import common.attributes.Attribute;
import common.collect.Lists; import common.collect.Lists;
import common.rng.Random; import common.rng.Random;
import common.util.Identifyable; import common.util.Identifyable;
@ -154,7 +154,7 @@ public class EntityPrimarch extends EntityMobNPC {
protected void applyEntityAttributes() { protected void applyEntityAttributes() {
super.applyEntityAttributes(); super.applyEntityAttributes();
this.getEntityAttribute(Attributes.ATTACK_DAMAGE).setBaseValue(20.0D); this.getEntityAttribute(Attribute.ATTACK_DAMAGE).setBaseValue(20.0D);
} }
// public TextComponent getPrefix() { // public TextComponent getPrefix() {

View file

@ -2,7 +2,7 @@ package common.entity.npc;
import common.ai.EntityAIBase; import common.ai.EntityAIBase;
import common.ai.EntityMoveHelper; import common.ai.EntityMoveHelper;
import common.attributes.Attributes; import common.attributes.Attribute;
import common.biome.Biome; import common.biome.Biome;
import common.entity.DamageSource; import common.entity.DamageSource;
import common.entity.Entity; import common.entity.Entity;
@ -661,7 +661,7 @@ public class EntitySlime extends EntityNPC
if (this.entity.onGround) 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) if (this.jumpDelay-- <= 0)
{ {
@ -688,7 +688,7 @@ public class EntitySlime extends EntityNPC
} }
else 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()));
} }
} }
} }

View file

@ -2,7 +2,7 @@ package common.entity.npc;
import java.util.List; import java.util.List;
import common.attributes.Attributes; import common.attributes.Attribute;
import common.collect.Lists; import common.collect.Lists;
import common.init.Items; import common.init.Items;
import common.init.SpeciesRegistry; import common.init.SpeciesRegistry;
@ -118,7 +118,7 @@ public class EntitySpaceMarine extends EntityNPC {
protected void applyEntityAttributes() { protected void applyEntityAttributes() {
super.applyEntityAttributes(); super.applyEntityAttributes();
this.getEntityAttribute(Attributes.ATTACK_DAMAGE).setBaseValue(12.0D); this.getEntityAttribute(Attribute.ATTACK_DAMAGE).setBaseValue(12.0D);
} }
protected ItemStack pickItem() { protected ItemStack pickItem() {

View file

@ -1,6 +1,6 @@
package common.entity.npc; package common.entity.npc;
import common.attributes.Attributes; import common.attributes.Attribute;
import common.rng.Random; import common.rng.Random;
import common.world.World; import common.world.World;
@ -80,6 +80,6 @@ public class EntityTiefling extends EntityMobNPC {
protected void applyEntityAttributes() { protected void applyEntityAttributes() {
super.applyEntityAttributes(); super.applyEntityAttributes();
this.getEntityAttribute(Attributes.ATTACK_DAMAGE).setBaseValue(3.0D); this.getEntityAttribute(Attribute.ATTACK_DAMAGE).setBaseValue(3.0D);
} }
} }

View file

@ -1,7 +1,7 @@
package common.entity.npc; package common.entity.npc;
import common.ai.EntityAIAvoidEntity; import common.ai.EntityAIAvoidEntity;
import common.attributes.Attributes; import common.attributes.Attribute;
import common.entity.animal.EntityWolf; import common.entity.animal.EntityWolf;
import common.entity.types.EntityLiving; import common.entity.types.EntityLiving;
import common.init.Items; import common.init.Items;
@ -21,7 +21,7 @@ public class EntityUndead extends EntityNPC
protected void applyEntityAttributes() protected void applyEntityAttributes()
{ {
super.applyEntityAttributes(); super.applyEntityAttributes();
this.getEntityAttribute(Attributes.MOVEMENT_SPEED).setBaseValue(0.25D); this.getEntityAttribute(Attribute.MOVEMENT_SPEED).setBaseValue(0.25D);
} }
// protected String getLivingSound() // protected String getLivingSound()

View file

@ -1,6 +1,6 @@
package common.entity.npc; package common.entity.npc;
import common.attributes.Attributes; import common.attributes.Attribute;
import common.entity.effect.EntityLightning; import common.entity.effect.EntityLightning;
import common.rng.Random; import common.rng.Random;
import common.world.World; import common.world.World;
@ -75,6 +75,6 @@ public class EntityVampire extends EntityNPC {
protected void applyEntityAttributes() { protected void applyEntityAttributes() {
super.applyEntityAttributes(); super.applyEntityAttributes();
this.getEntityAttribute(Attributes.ATTACK_DAMAGE).setBaseValue(5.0D); this.getEntityAttribute(Attribute.ATTACK_DAMAGE).setBaseValue(5.0D);
} }
} }

View file

@ -4,8 +4,8 @@ import java.util.List;
import java.util.function.Predicate; import java.util.function.Predicate;
import common.ai.EntityAIMoveThroughVillage; import common.ai.EntityAIMoveThroughVillage;
import common.attributes.Attribute;
import common.attributes.AttributeModifier; import common.attributes.AttributeModifier;
import common.attributes.Attributes;
import common.entity.DamageSource; import common.entity.DamageSource;
import common.entity.animal.EntityChicken; import common.entity.animal.EntityChicken;
import common.entity.types.EntityLiving; import common.entity.types.EntityLiving;
@ -27,10 +27,10 @@ public class EntityZombie extends EntityNPC
protected void applyEntityAttributes() protected void applyEntityAttributes()
{ {
super.applyEntityAttributes(); super.applyEntityAttributes();
this.getEntityAttribute(Attributes.FOLLOW_RANGE).setBaseValue(28.0D); this.getEntityAttribute(Attribute.FOLLOW_RANGE).setBaseValue(28.0D);
this.getEntityAttribute(Attributes.MOVEMENT_SPEED).setBaseValue(0.23000000417232513D); this.getEntityAttribute(Attribute.MOVEMENT_SPEED).setBaseValue(0.23000000417232513D);
this.getEntityAttribute(Attributes.ATTACK_DAMAGE).setBaseValue(3.0D); this.getEntityAttribute(Attribute.ATTACK_DAMAGE).setBaseValue(3.0D);
this.getAttributeMap().registerAttribute(Attributes.REINFORCEMENT_CHANCE).setBaseValue(this.rand.doublev() * 0.10000000149011612D); this.getAttributeMap().registerAttribute(Attribute.REINFORCEMENT_CHANCE).setBaseValue(this.rand.doublev() * 0.10000000149011612D);
} }
public void onLivingUpdate() public void onLivingUpdate()
@ -53,7 +53,7 @@ public class EntityZombie extends EntityNPC
entitylivingbase = (EntityLiving)source.getEntity(); 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 i = ExtMath.floord(this.posX);
int j = ExtMath.floord(this.posY); int j = ExtMath.floord(this.posY);
@ -75,8 +75,8 @@ public class EntityZombie extends EntityNPC
this.worldObj.spawnEntityInWorld(entityzombie); this.worldObj.spawnEntityInWorld(entityzombie);
entityzombie.setAttackTarget(entitylivingbase); entityzombie.setAttackTarget(entitylivingbase);
entityzombie.onInitialSpawn(null); entityzombie.onInitialSpawn(null);
this.getEntityAttribute(Attributes.REINFORCEMENT_CHANCE).applyModifier(new AttributeModifier("Zombie reinforcement caller charge", -0.05000000074505806D, false)); this.getEntityAttribute(Attribute.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)); entityzombie.getEntityAttribute(Attribute.REINFORCEMENT_CHANCE).applyModifier(new AttributeModifier("Zombie reinforcement callee charge", -0.05000000074505806D, false));
break; 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; double d0 = this.rand.doublev() * 15.0;
if (d0 > 1.0D) 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)) 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(Attribute.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.MAX_HEALTH).applyModifier(new AttributeModifier("Leader zombie bonus", this.rand.roll(4), true));
// this.setBreakDoorsAItask(true); // this.setBreakDoorsAItask(true);
} }

View file

@ -2,22 +2,5 @@ package common.entity.npc;
import common.util.BlockPos; import common.util.BlockPos;
public class PlayerCharacter { public record PlayerCharacter(String name, String info, Alignment align, String dim, BlockPos pos, String type, int level) {
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;
}
} }

View file

@ -2,32 +2,5 @@ package common.entity.types;
import common.entity.DamageSource; import common.entity.DamageSource;
public class CombatEntry { public record CombatEntry(DamageSource source, int damage, String blockType, float fallDistance) {
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;
}
} }

View file

@ -192,13 +192,13 @@ public abstract class EntityLiving extends Entity
protected void applyEntityAttributes() protected void applyEntityAttributes()
{ {
this.getAttributeMap().registerAttribute(Attributes.MAX_HEALTH); this.getAttributeMap().registerAttribute(Attribute.MAX_HEALTH);
this.getAttributeMap().registerAttribute(Attributes.KNOCKBACK_RESISTANCE); this.getAttributeMap().registerAttribute(Attribute.KNOCKBACK_RESISTANCE);
this.getAttributeMap().registerAttribute(Attributes.MOVEMENT_SPEED); this.getAttributeMap().registerAttribute(Attribute.MOVEMENT_SPEED);
this.getAttributeMap().registerAttribute(Attributes.RADIATION); this.getAttributeMap().registerAttribute(Attribute.RADIATION);
this.getAttributeMap().registerAttribute(Attributes.RADIATION_RESISTANCE); 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) 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.worldObj.client) {
if(!this.firstEffectUpdate && Config.radiation) { // && if(!this.firstEffectUpdate && Config.radiation) { // &&
// (!(this.isPlayer()) || !((EntityNPCMP)this).creative)) { // (!(this.isPlayer()) || !((EntityNPCMP)this).creative)) {
float radiation = this.radiation + (float)this.attributes.getAttributeInstance(Attributes.RADIATION).getAttributeValue(); float radiation = this.radiation + (float)this.attributes.getAttributeInstance(Attribute.RADIATION).getAttributeValue();
radiation -= (float)this.attributes.getAttributeInstance(Attributes.RADIATION_RESISTANCE).getAttributeValue(); radiation -= (float)this.attributes.getAttributeInstance(Attribute.RADIATION_RESISTANCE).getAttributeValue();
// if(this.isPlayer()) // if(this.isPlayer())
// Log.SERVER.info("rad:" + radiation); // Log.SERVER.info("rad:" + radiation);
if(radiation >= 0.0f) { 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) 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; this.isAirBorne = true;
float div = ExtMath.sqrtd(xfactor * xfactor + zfactor * zfactor); float div = ExtMath.sqrtd(xfactor * xfactor + zfactor * zfactor);
@ -1379,17 +1379,17 @@ public abstract class EntityLiving extends Entity
public final int getMaxHealth() public final int getMaxHealth()
{ {
return (int)this.getEntityAttribute(Attributes.MAX_HEALTH).getAttributeValue(); return (int)this.getEntityAttribute(Attribute.MAX_HEALTH).getAttributeValue();
} }
public final int getRawMaxHealth() 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) 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() { public int getMaxMana() {
@ -1550,9 +1550,9 @@ public abstract class EntityLiving extends Entity
public void setSprinting(boolean sprinting) public void setSprinting(boolean sprinting)
{ {
super.setSprinting(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); iattributeinstance.removeModifier(Attributes.SPRINT_SPEED_MOD);
} }
@ -2310,7 +2310,7 @@ public abstract class EntityLiving extends Entity
*/ */
protected void setBeenAttacked() 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() public float getRotationYawHead()
@ -2443,11 +2443,11 @@ public abstract class EntityLiving extends Entity
else if(this.isInLiquid()) { else if(this.isInLiquid()) {
this.blockType = "aus dem Wasser"; 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.combat.add(entry);
this.lastDamaged = this.ticksExisted; this.lastDamaged = this.ticksExisted;
this.damaged = true; 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; this.attacked = true;
} }
@ -2474,8 +2474,8 @@ public abstract class EntityLiving extends Entity
CombatEntry entry = (CombatEntry)this.combat.get(z); CombatEntry entry = (CombatEntry)this.combat.get(z);
CombatEntry last = z > 0 ? (CombatEntry)this.combat.get(z - 1) : null; CombatEntry last = z > 0 ? (CombatEntry)this.combat.get(z - 1) : null;
if((entry.getSource() == DamageSource.fall || entry.getSource() == DamageSource.outOfWorld) && if((entry.source() == DamageSource.fall || entry.source() == DamageSource.outOfWorld) &&
entry.getFallDistance() > 0.0F && (strong == null || entry.getFallDistance() > max)) { entry.fallDistance() > 0.0F && (strong == null || entry.fallDistance() > max)) {
if(z > 0) { if(z > 0) {
strong = last; strong = last;
} }
@ -2483,20 +2483,20 @@ public abstract class EntityLiving extends Entity
strong = entry; 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; block = entry;
} }
} }
CombatEntry fall = max > 5.0F && strong != null ? strong : (min > 5 && block != null ? block : null); CombatEntry fall = max > 5.0F && strong != null ? strong : (min > 5 && block != null ? block : null);
CombatEntry last = (CombatEntry)this.combat.get(this.combat.size() - 1); 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 != null && last.source() == DamageSource.fall) {
if(fall.getSource() != DamageSource.fall && fall.getSource() != DamageSource.outOfWorld) { if(fall.source() != DamageSource.fall && fall.source() != DamageSource.outOfWorld) {
Entity fallEnt = fall.getSource().getEntity(); Entity fallEnt = fall.source().getEntity();
if(fallEnt != null && (lastEnt == null || fallEnt != lastEnt)) { if(fallEnt != null && (lastEnt == null || fallEnt != lastEnt)) {
ItemStack fallItem = fallEnt instanceof EntityLiving ? ((EntityLiving)fallEnt).getHeldItem() : null; ItemStack fallItem = fallEnt instanceof EntityLiving ? ((EntityLiving)fallEnt).getHeldItem() : null;
receiver = fallEnt.isPlayer() ? ((EntityNPC)fallEnt).connection : null; receiver = fallEnt.isPlayer() ? ((EntityNPC)fallEnt).connection : null;
@ -2534,14 +2534,14 @@ public abstract class EntityLiving extends Entity
} }
} }
else { 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; this.getColoredName(TextColor.NEON)) : null;
} }
} }
else { else {
receiver = last.getSource().getEntity() != null && last.getSource().getEntity().isPlayer() ? ((EntityNPC)last.getSource().getEntity()).connection : null; receiver = last.source().getEntity() != null && last.source().getEntity().isPlayer() ? ((EntityNPC)last.source().getEntity()).connection : null;
msg = natural || (last.getSource() instanceof EntityDamageSource ? last.getSource().getEntity() != null : this.getAttackingEntity() != null) ? last.getSource().getDeathMessage(this) : null; msg = natural || (last.source() instanceof EntityDamageSource ? last.source().getEntity() != null : this.getAttackingEntity() != null) ? last.source().getDeathMessage(this) : null;
kill = msg == null ? null : last.getSource().getKillMessage(this); kill = msg == null ? null : last.source().getKillMessage(this);
} }
} }
if(msg == null) if(msg == null)
@ -2561,13 +2561,13 @@ public abstract class EntityLiving extends Entity
int edmg = 0; int edmg = 0;
int pdmg = 0; int pdmg = 0;
for(CombatEntry entry : this.combat) { for(CombatEntry entry : this.combat) {
if(entry.getSource().getEntity() != null && entry.getSource().getEntity().isPlayer() && (player == null || entry.getDamage() > pdmg)) { if(entry.source().getEntity() != null && entry.source().getEntity().isPlayer() && (player == null || entry.damage() > pdmg)) {
pdmg = entry.getDamage(); pdmg = entry.damage();
player = (EntityNPC)entry.getSource().getEntity(); player = (EntityNPC)entry.source().getEntity();
} }
if(entry.getSource().getEntity() instanceof EntityLiving && (entity == null || entry.getDamage() > edmg)) { if(entry.source().getEntity() instanceof EntityLiving && (entity == null || entry.damage() > edmg)) {
edmg = entry.getDamage(); edmg = entry.damage();
entity = (EntityLiving)entry.getSource().getEntity(); entity = (EntityLiving)entry.source().getEntity();
} }
} }
return player != null && pdmg >= edmg / 3 ? player : entity; return player != null && pdmg >= edmg / 3 ? player : entity;
@ -2713,7 +2713,7 @@ public abstract class EntityLiving extends Entity
// } // }
public Object onInitialSpawn(Object livingdata) { 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)); .applyModifier(new AttributeModifier("Random spawn bonus", this.rand.gaussian() * 0.05D, true));
return livingdata; return livingdata;
} }

View file

@ -149,8 +149,8 @@ public abstract class DispenserRegistry {
return stack; return stack;
} }
}; };
for(EntityEggInfo egg : EntityRegistry.SPAWN_EGGS.values()) { for(EntityInfo egg : EntityRegistry.SPAWN_EGGS.values()) {
REGISTRY.putObject(ItemRegistry.getRegisteredItem(egg.id.toLowerCase() + "_spawner"), REGISTRY.putObject(ItemRegistry.getRegisteredItem(egg.id().toLowerCase() + "_spawner"),
disp); disp);
} }
REGISTRY.putObject(Items.fireworks, new BehaviorDefaultDispenseItem() REGISTRY.putObject(Items.fireworks, new BehaviorDefaultDispenseItem()

View file

@ -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;
}
}

View file

@ -0,0 +1,4 @@
package common.init;
public record EntityInfo(String id, String origin, int color1, int color2) {
}

View file

@ -58,7 +58,7 @@ public abstract class EntityRegistry {
private static final Map<Integer, Class<? extends Entity>> ID_TO_CLASS = Maps.<Integer, Class<? extends Entity>>newHashMap(); private static final Map<Integer, Class<? extends Entity>> ID_TO_CLASS = Maps.<Integer, Class<? extends Entity>>newHashMap();
private static final Map<Class<? extends Entity>, Integer> CLASS_TO_ID = Maps.<Class<? extends Entity>, Integer>newHashMap(); private static final Map<Class<? extends Entity>, Integer> CLASS_TO_ID = Maps.<Class<? extends Entity>, Integer>newHashMap();
// private static final Map<String, Integer> STRING_TO_ID = Maps.<String, Integer>newHashMap(); // private static final Map<String, Integer> STRING_TO_ID = Maps.<String, Integer>newHashMap();
public static final Map<String, EntityEggInfo> SPAWN_EGGS = Maps.<String, EntityEggInfo>newLinkedHashMap(); public static final Map<String, EntityInfo> SPAWN_EGGS = Maps.<String, EntityInfo>newLinkedHashMap();
private static final Map<String, String> STRING_TO_NAME = Maps.<String, String>newHashMap(); private static final Map<String, String> STRING_TO_NAME = Maps.<String, String>newHashMap();
private static boolean register; private static boolean register;
@ -89,7 +89,7 @@ public abstract class EntityRegistry {
} }
else { else {
// String name = clazz.getSimpleName().substring(6); // 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));
} }
} }

View file

@ -371,8 +371,8 @@ public abstract class ItemRegistry {
registerItem("hopper_minecart", (new ItemMinecart(EntityCart.EnumMinecartType.HOPPER)).setDisplay("Trichterlore")); registerItem("hopper_minecart", (new ItemMinecart(EntityCart.EnumMinecartType.HOPPER)).setDisplay("Trichterlore"));
registerItem("tnt_minecart", (new ItemMinecart(EntityCart.EnumMinecartType.TNT)).setDisplay("TNT-Lore") registerItem("tnt_minecart", (new ItemMinecart(EntityCart.EnumMinecartType.TNT)).setDisplay("TNT-Lore")
.setColor(TextColor.RED)); .setColor(TextColor.RED));
for(EntityEggInfo egg : EntityRegistry.SPAWN_EGGS.values()) { for(EntityInfo egg : EntityRegistry.SPAWN_EGGS.values()) {
registerItem(egg.id.toLowerCase() + "_spawner", (new ItemMonsterPlacer(egg.id)) registerItem(egg.id().toLowerCase() + "_spawner", (new ItemMonsterPlacer(egg.id()))
.setDisplay("Spawner").setMaxStackSize(ItemStack.MAX_SIZE)); .setDisplay("Spawner").setMaxStackSize(ItemStack.MAX_SIZE));
} }
for(SpeciesInfo species : SpeciesRegistry.SPECIMEN) { for(SpeciesInfo species : SpeciesRegistry.SPECIMEN) {

View file

@ -5,7 +5,7 @@ import java.util.Map;
import common.collect.Maps; import common.collect.Maps;
import common.entity.npc.EntityNPC; import common.entity.npc.EntityNPC;
import common.tileentity.ILockableContainer; import common.tileentity.ILockableContainer;
import common.tileentity.LockCode; import common.tileentity.Passcode;
public class ContainerLocalMenu extends InventoryBasic implements ILockableContainer public class ContainerLocalMenu extends InventoryBasic implements ILockableContainer
{ {
@ -38,13 +38,13 @@ public class ContainerLocalMenu extends InventoryBasic implements ILockableConta
return false; 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() public String getGuiID()

View file

@ -3,7 +3,7 @@ package common.inventory;
import common.entity.npc.EntityNPC; import common.entity.npc.EntityNPC;
import common.item.ItemStack; import common.item.ItemStack;
import common.tileentity.ILockableContainer; import common.tileentity.ILockableContainer;
import common.tileentity.LockCode; import common.tileentity.Passcode;
import common.tileentity.TileEntityChest; import common.tileentity.TileEntityChest;
public class InventoryLargeChest implements ILockableContainer public class InventoryLargeChest implements ILockableContainer
@ -188,13 +188,13 @@ public class InventoryLargeChest implements ILockableContainer
return this.upperChest.isLocked() || this.lowerChest.isLocked(); return this.upperChest.isLocked() || this.lowerChest.isLocked();
} }
public void setLockCode(LockCode code) public void setLockCode(Passcode code)
{ {
this.upperChest.setLockCode(code); this.upperChest.setLockCode(code);
this.lowerChest.setLockCode(code); this.lowerChest.setLockCode(code);
} }
public LockCode getLockCode() public Passcode getLockCode()
{ {
return this.upperChest.getLockCode(); return this.upperChest.getLockCode();
} }

View file

@ -229,7 +229,7 @@ public class InventoryMerchant implements IInventory
if (merchantrecipe != null) // && !merchantrecipe.isRecipeDisabled()) if (merchantrecipe != null) // && !merchantrecipe.isRecipeDisabled())
{ {
this.currentRecipe = merchantrecipe; this.currentRecipe = merchantrecipe;
this.setInventorySlotContents(2, merchantrecipe.getSelling().copy()); this.setInventorySlotContents(2, merchantrecipe.result().copy());
} }
else if (itemstack1 != null) else if (itemstack1 != null)
{ {
@ -238,7 +238,7 @@ public class InventoryMerchant implements IInventory
if (merchantrecipe != null) // && !merchantrecipe.isRecipeDisabled()) if (merchantrecipe != null) // && !merchantrecipe.isRecipeDisabled())
{ {
this.currentRecipe = merchantrecipe; this.currentRecipe = merchantrecipe;
this.setInventorySlotContents(2, merchantrecipe.getSelling().copy()); this.setInventorySlotContents(2, merchantrecipe.result().copy());
} }
else else
{ {

View file

@ -94,8 +94,8 @@ public class SlotMerchantResult extends Slot
private boolean doTrade(MerchantRecipe trade, ItemStack firstItem, ItemStack secondItem) private boolean doTrade(MerchantRecipe trade, ItemStack firstItem, ItemStack secondItem)
{ {
ItemStack itemstack = trade.getBuying(); ItemStack itemstack = trade.first();
ItemStack itemstack1 = trade.getSecondBuy(); ItemStack itemstack1 = trade.second();
if (firstItem != null && firstItem.getItem() == itemstack.getItem()) if (firstItem != null && firstItem.getItem() == itemstack.getItem())
{ {

View file

@ -260,11 +260,11 @@ public class ItemArmor extends Item
{ {
Map<Attribute, Set<AttributeModifier>> multimap = super.getItemAttributeModifiers(); Map<Attribute, Set<AttributeModifier>> multimap = super.getItemAttributeModifiers();
if(this.material.getRadiationReduction(this.armorType) > 0.0f) 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), Sets.newHashSet(new AttributeModifier(Attributes.ITEM_VAL_ID + (long)this.armorType + 1L, "Armor modifier " + (this.armorType + 1),
(double)this.material.getRadiationReduction(this.armorType), false))); (double)this.material.getRadiationReduction(this.armorType), false)));
if(this.material.getMagicReduction(this.armorType) > 0.0f) 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), Sets.newHashSet(new AttributeModifier(Attributes.ITEM_VAL_ID + (long)this.armorType + 1L, "Armor modifier " + (this.armorType + 1),
(double)this.material.getMagicReduction(this.armorType), false))); (double)this.material.getMagicReduction(this.armorType), false)));
return multimap; return multimap;

View file

@ -67,7 +67,7 @@ public class ItemBucketMilk extends Item
public Map<Attribute, Set<AttributeModifier>> getItemInventoryModifiers() public Map<Attribute, Set<AttributeModifier>> getItemInventoryModifiers()
{ {
Map<Attribute, Set<AttributeModifier>> multimap = super.getItemInventoryModifiers(); Map<Attribute, Set<AttributeModifier>> 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; return multimap;
} }

View file

@ -39,7 +39,7 @@ public class ItemMetal extends Item {
{ {
Map<Attribute, Set<AttributeModifier>> multimap = super.getItemInventoryModifiers(); Map<Attribute, Set<AttributeModifier>> multimap = super.getItemInventoryModifiers();
if(this.metal.radioactivity > 0.0f) 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; return multimap;
} }

View file

@ -43,7 +43,7 @@ public class ItemMetalBlock extends ItemBlock {
{ {
Map<Attribute, Set<AttributeModifier>> multimap = super.getItemInventoryModifiers(); Map<Attribute, Set<AttributeModifier>> multimap = super.getItemInventoryModifiers();
if(this.metal.radioactivity > 0.0f) 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; return multimap;
} }

View file

@ -10,7 +10,7 @@ import common.entity.Entity;
import common.entity.npc.EntityNPC; import common.entity.npc.EntityNPC;
import common.entity.types.EntityLiving; import common.entity.types.EntityLiving;
import common.init.Blocks; import common.init.Blocks;
import common.init.EntityEggInfo; import common.init.EntityInfo;
import common.init.EntityRegistry; import common.init.EntityRegistry;
import common.init.UniverseRegistry; import common.init.UniverseRegistry;
import common.model.Model; import common.model.Model;
@ -54,14 +54,14 @@ public class ItemMonsterPlacer extends Item
public int getColorFromItemStack(ItemStack stack, int renderPass) public int getColorFromItemStack(ItemStack stack, int renderPass)
{ {
EntityEggInfo egg = EntityRegistry.SPAWN_EGGS.get(this.entityId); EntityInfo egg = EntityRegistry.SPAWN_EGGS.get(this.entityId);
return egg != null ? (renderPass == 0 ? egg.color1 : egg.color2) : 16777215; return egg != null ? (renderPass == 0 ? egg.color1() : egg.color2()) : 16777215;
} }
public void addInformation(ItemStack stack, EntityNPC player, List<String> tooltip) { public void addInformation(ItemStack stack, EntityNPC player, List<String> tooltip) {
EntityEggInfo egg = EntityRegistry.SPAWN_EGGS.get(this.entityId); EntityInfo egg = EntityRegistry.SPAWN_EGGS.get(this.entityId);
if(egg != null) { 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))); tooltip.add(TextColor.ORANGE + "Herkunft: " + (dim == null ? "???" : dim.getFormattedName(false)));
} }
} }

View file

@ -324,12 +324,12 @@ public class ItemPotion extends Item
if (d0 > 0.0D) 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) else if (d0 < 0.0D)
{ {
d1 = d1 * -1.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()));
} }
} }
} }

View file

@ -882,7 +882,7 @@ public final class ItemStack
for(AttributeModifier mod : entry.getValue()) { for(AttributeModifier mod : entry.getValue()) {
double amt = mod.getAmount(); double amt = mod.getAmount();
if (mod.getID() == Attributes.ITEM_VAL_ID) if (mod.getID() == Attributes.ITEM_DMG_ID)
{ {
amt += (double)EnchantmentHelper.getDamageModifier(this); amt += (double)EnchantmentHelper.getDamageModifier(this);
} }
@ -901,25 +901,20 @@ public final class ItemStack
if(mod.isInventory() && this.size != 1) { if(mod.isInventory() && this.size != 1) {
double total = num * (double)this.size; double total = num * (double)this.size;
if (amt > 0.0D) 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) 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 { else {
if (amt > 0.0D) 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) 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) // if (this.hasTagCompound() && this.stackTagCompound.hasList("CanDestroy") && (i1 & 8) == 0)
// { // {
// NBTTagList nbttaglist2 = this.stackTagCompound.getTagList("CanDestroy", 8); // NBTTagList nbttaglist2 = this.stackTagCompound.getTagList("CanDestroy", 8);

View file

@ -148,7 +148,7 @@ public class ItemSword extends Item
public Map<Attribute, Set<AttributeModifier>> getItemAttributeModifiers() public Map<Attribute, Set<AttributeModifier>> getItemAttributeModifiers()
{ {
Map<Attribute, Set<AttributeModifier>> multimap = super.getItemAttributeModifiers(); Map<Attribute, Set<AttributeModifier>> 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; return multimap;
} }

View file

@ -59,8 +59,8 @@ public abstract class ItemTool extends Item {
public Map<Attribute, Set<AttributeModifier>> getItemAttributeModifiers() { public Map<Attribute, Set<AttributeModifier>> getItemAttributeModifiers() {
Map<Attribute, Set<AttributeModifier>> mods = super.getItemAttributeModifiers(); Map<Attribute, Set<AttributeModifier>> mods = super.getItemAttributeModifiers();
mods.put(Attributes.ATTACK_DAMAGE, mods.put(Attribute.ATTACK_DAMAGE,
Sets.newHashSet(new AttributeModifier(Attributes.ITEM_VAL_ID, "Tool modifier", this.damage, false))); Sets.newHashSet(new AttributeModifier(Attributes.ITEM_DMG_ID, "Tool modifier", this.damage, false)));
return mods; return mods;
} }

View file

@ -1,21 +1,18 @@
package common.model; package common.model;
public enum BlockLayer public enum BlockLayer {
{
SOLID("Solid"), SOLID("Solid"),
CUTOUT_MIPPED("Mipped Cutout"), CUTOUT_MIPPED("Mipped Cutout"),
CUTOUT("Cutout"), CUTOUT("Cutout"),
TRANSLUCENT("Translucent"); TRANSLUCENT("Translucent");
private final String layerName; private final String name;
private BlockLayer(String layerNameIn) private BlockLayer(String name) {
{ this.name = name;
this.layerName = layerNameIn;
} }
public String toString() public String toString() {
{ return this.name;
return this.layerName;
} }
} }

View file

@ -2,7 +2,6 @@ package common.model;
import common.item.ItemStack; import common.item.ItemStack;
public interface ItemMeshDefinition public interface ItemMeshDefinition {
{
String getModelLocation(ItemStack stack); String getModelLocation(ItemStack stack);
} }

View file

@ -1,37 +1,5 @@
package common.model; package common.model;
import common.util.Vector3f; 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);
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;
}
} }

View file

@ -8,122 +8,122 @@ public enum Transforms {
Transform.IDENTITY Transform.IDENTITY
), ),
ANVIL( 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, Transform.IDENTITY,
Transform.IDENTITY Transform.IDENTITY
), ),
BLOCK( 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, Transform.IDENTITY,
Transform.IDENTITY Transform.IDENTITY
), ),
ITEM( ITEM(
new Transform(-90.0f, 0.0f, 0.0f, 0.0f, 1.0f, -3.0f, 0.55f, 0.55f, 0.55f), transform(-90.0f, 0.0f, 0.0f, 0.0f, 1.0f, -3.0f, 0.55f),
new Transform(0.0f, -135.0f, 25.0f, 0.0f, 4.0f, 2.0f, 1.7f, 1.7f, 1.7f), transform(0.0f, -135.0f, 25.0f, 0.0f, 4.0f, 2.0f, 1.7f),
Transform.IDENTITY, Transform.IDENTITY,
Transform.IDENTITY Transform.IDENTITY
), ),
TOOL_FLIP( TOOL_FLIP(
new Transform(180.0f, 90.0f, -35.0f, 0.0f, 0.0f, -3.5f, 0.85f, 0.85f, 0.85f), transform(180.0f, 90.0f, -35.0f, 0.0f, 0.0f, -3.5f, 0.85f),
new Transform(0.0f, 45.0f, 25.0f, 0.0f, 4.0f, 2.0f, 1.7f, 1.7f, 1.7f), transform(0.0f, 45.0f, 25.0f, 0.0f, 4.0f, 2.0f, 1.7f),
Transform.IDENTITY, Transform.IDENTITY,
Transform.IDENTITY Transform.IDENTITY
), ),
TOOL( TOOL(
new Transform(0.0f, 90.0f, -35.0f, 0.0f, 1.25f, -3.5f, 0.85f, 0.85f, 0.85f), transform(0.0f, 90.0f, -35.0f, 0.0f, 1.25f, -3.5f, 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, -135.0f, 25.0f, 0.0f, 4.0f, 2.0f, 1.7f),
Transform.IDENTITY, Transform.IDENTITY,
Transform.IDENTITY Transform.IDENTITY
), ),
OFFSET2( OFFSET2(
new Transform(-90.0f, 0.0f, 0.0f, 0.0f, 1.0f, -2.25f, 0.55f, 0.55f, 0.55f), transform(-90.0f, 0.0f, 0.0f, 0.0f, 1.0f, -2.25f, 0.55f),
new Transform(0.0f, -135.0f, 25.0f, 0.0f, 4.0f, 2.0f, 1.7f, 1.7f, 1.7f), transform(0.0f, -135.0f, 25.0f, 0.0f, 4.0f, 2.0f, 1.7f),
Transform.IDENTITY, Transform.IDENTITY,
Transform.IDENTITY Transform.IDENTITY
), ),
LAYER( LAYER(
new Transform(10.0f, -45.0f, 170.0f, 0.0f, 0.25f, -2.75f, 0.375f, 0.375f, 0.375f), transform(10.0f, -45.0f, 170.0f, 0.0f, 0.25f, -2.75f, 0.375f),
new Transform(0.0f, 0.0f, 0.0f, 0.0f, 5.25f, 0.0f, 1.0f, 1.0f, 1.0f), transform(0.0f, 0.0f, 0.0f, 0.0f, 5.25f, 0.0f, 1.0f),
Transform.IDENTITY, Transform.IDENTITY,
Transform.IDENTITY Transform.IDENTITY
), ),
DICE( DICE(
new Transform(10.0f, -45.0f, 170.0f, 0.0f, 1.5f, -1.75f, 0.15f, 0.15f, 0.15f), transform(10.0f, -45.0f, 170.0f, 0.0f, 1.5f, -1.75f, 0.15f),
new Transform(0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.4f, 0.4f, 0.4f), transform(0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.4f),
new Transform(135.0f, -55.0f, 180.0f, 0.0f, 0.0f, 0.0f, 1.1f, 1.1f, 1.1f), transform(135.0f, -55.0f, 180.0f, 0.0f, 0.0f, 0.0f, 1.1f),
new Transform(0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.4f, 0.4f, 0.4f) transform(0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.4f)
), ),
STAIRS( 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, 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 Transform.IDENTITY
), ),
OFFSET1( OFFSET1(
new Transform(-90.0f, 0.0f, 0.0f, 0.0f, 1.0f, -2.5f, 0.55f, 0.55f, 0.55f), transform(-90.0f, 0.0f, 0.0f, 0.0f, 1.0f, -2.5f, 0.55f),
new Transform(0.0f, -135.0f, 25.0f, 0.0f, 4.0f, 2.0f, 1.7f, 1.7f, 1.7f), transform(0.0f, -135.0f, 25.0f, 0.0f, 4.0f, 2.0f, 1.7f),
Transform.IDENTITY, Transform.IDENTITY,
Transform.IDENTITY Transform.IDENTITY
), ),
GATE( GATE(
new Transform(0.0f, -90.0f, 170.0f, 0.0f, 1.5f, -2.75f, 0.375f, 0.375f, 0.375f), transform(0.0f, -90.0f, 170.0f, 0.0f, 1.5f, -2.75f, 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, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f),
Transform.IDENTITY, Transform.IDENTITY,
Transform.IDENTITY Transform.IDENTITY
), ),
NUGGET( NUGGET(
new Transform(-90.0f, 0.0f, 0.0f, 0.0f, 1.0f, -2.0f, 0.55f, 0.55f, 0.55f), transform(-90.0f, 0.0f, 0.0f, 0.0f, 1.0f, -2.0f, 0.55f),
new Transform(0.0f, -135.0f, 25.0f, 0.0f, 4.0f, 2.0f, 1.7f, 1.7f, 1.7f), transform(0.0f, -135.0f, 25.0f, 0.0f, 4.0f, 2.0f, 1.7f),
Transform.IDENTITY, Transform.IDENTITY,
Transform.IDENTITY Transform.IDENTITY
), ),
SKULL( SKULL(
new Transform(180.0f, -45.0f, 0.0f, 0.0f, 1.0f, -2.5f, 0.25f, 0.25f, 0.25f), transform(180.0f, -45.0f, 0.0f, 0.0f, 1.0f, -2.5f, 0.25f),
new Transform(0.0f, -180.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.55f, 0.55f, 0.55f), transform(0.0f, -180.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.55f),
new Transform(0.0f, 180.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.7f, 0.7f, 0.7f), transform(0.0f, 180.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.7f),
Transform.IDENTITY Transform.IDENTITY
), ),
BUTTON( 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, Transform.IDENTITY,
Transform.IDENTITY Transform.IDENTITY
), ),
RANGED( RANGED(
new Transform(5.0f, 80.0f, -45.0f, 0.75f, 0.0f, 0.25f, 1.0f, 1.0f, 1.0f), transform(5.0f, 80.0f, -45.0f, 0.75f, 0.0f, 0.25f, 1.0f),
new Transform(0.0f, -135.0f, 25.0f, 0.0f, 4.0f, 2.0f, 1.7f, 1.7f, 1.7f), transform(0.0f, -135.0f, 25.0f, 0.0f, 4.0f, 2.0f, 1.7f),
Transform.IDENTITY, Transform.IDENTITY,
Transform.IDENTITY Transform.IDENTITY
), ),
BANNER( BANNER(
new Transform(0.0f, 90.0f, -90.0f, 0.0f, 0.0f, -4.0f, 0.5f, 0.5f, 0.5f), transform(0.0f, 90.0f, -90.0f, 0.0f, 0.0f, -4.0f, 0.5f),
new Transform(0.0f, 225.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f), transform(0.0f, 225.0f, 0.0f, 0.0f, 0.0f, 0.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, -65.0f, 0.0f, 0.0f, -3.0f, 0.0f, 0.85f),
Transform.IDENTITY Transform.IDENTITY
), ),
FENCE( 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, 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 Transform.IDENTITY
), ),
FLAT( FLAT(
new Transform(10.0f, -45.0f, 170.0f, 0.0f, 0.25f, -2.75f, 0.375f, 0.375f, 0.375f), transform(10.0f, -45.0f, 170.0f, 0.0f, 0.25f, -2.75f, 0.375f),
new Transform(0.0f, 0.0f, 0.0f, 0.0f, 5.0f, 0.0f, 1.0f, 1.0f, 1.0f), transform(0.0f, 0.0f, 0.0f, 0.0f, 5.0f, 0.0f, 1.0f),
Transform.IDENTITY, Transform.IDENTITY,
Transform.IDENTITY Transform.IDENTITY
), ),
ROD( ROD(
new Transform(0.0f, 90.0f, -35.0f, 0.0f, 0.75f, -3.5f, 0.85f, 0.85f, 0.85f), transform(0.0f, 90.0f, -35.0f, 0.0f, 0.75f, -3.5f, 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, -135.0f, 25.0f, 0.0f, 4.0f, 2.0f, 1.7f),
Transform.IDENTITY, Transform.IDENTITY,
Transform.IDENTITY Transform.IDENTITY
), ),
KEY( KEY(
new Transform(0.0f, 270.0f, -35.0f, 0.0f, 1.25f, -3.5f, 0.85f, 0.85f, 0.85f), transform(0.0f, 270.0f, -35.0f, 0.0f, 1.25f, -3.5f, 0.85f),
new Transform(180.0f, -135.0f, 25.0f, 0.0f, 4.0f, 2.0f, 1.7f, 1.7f, 1.7f), transform(180.0f, -135.0f, 25.0f, 0.0f, 4.0f, 2.0f, 1.7f),
Transform.IDENTITY, Transform.IDENTITY,
Transform.IDENTITY Transform.IDENTITY
); );
@ -136,6 +136,10 @@ public enum Transforms {
GROUND; 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 third;
public final Transform first; public final Transform first;
public final Transform gui; public final Transform gui;

View file

@ -69,13 +69,13 @@ public class SPacketCharacterList implements Packet<IClientPlayer> {
buf.writeString(""); buf.writeString("");
continue; continue;
} }
buf.writeString(chr.name); buf.writeString(chr.name());
buf.writeString(chr.info == null ? "" : chr.info); buf.writeString(chr.info() == null ? "" : chr.info());
buf.writeEnumValue(chr.align); buf.writeEnumValue(chr.align());
buf.writeString(chr.dim); buf.writeString(chr.dim());
buf.writeBlockPos(chr.pos); buf.writeBlockPos(chr.pos());
buf.writeString(chr.type); buf.writeString(chr.type());
buf.writeVarInt(chr.level); buf.writeVarInt(chr.level());
} }
buf.writeVarInt(this.selected); buf.writeVarInt(this.selected);
} }

Some files were not shown because too many files have changed in this diff Show more