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

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

View file

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

View file

@ -1,6 +1,6 @@
package common.ai;
import common.attributes.Attributes;
import common.attributes.Attribute;
import common.entity.types.EntityLiving;
import common.util.ExtMath;
@ -63,7 +63,7 @@ public class EntityMoveHelper
{
float f = (float)(ExtMath.atan2(d1, d0) * 180.0D / Math.PI) - 90.0F;
this.entity.rotYaw = this.limitAngle(this.entity.rotYaw, f, 30.0F);
this.entity.setAIMoveSpeed((float)(this.speed * this.entity.getEntityAttribute(Attributes.MOVEMENT_SPEED).getAttributeValue()));
this.entity.setAIMoveSpeed((float)(this.speed * this.entity.getEntityAttribute(Attribute.MOVEMENT_SPEED).getAttributeValue()));
if (d2 > 0.0D && d0 * d0 + d1 * d1 < 1.0D)
{

View file

@ -3,82 +3,76 @@ package common.attributes;
import java.util.Map;
import common.collect.Maps;
import common.util.Displayable;
import common.util.ExtMath;
import common.util.Identifyable;
public enum Attribute implements Identifyable, Displayable {
MAX_HEALTH("generic.maxHealth", "Maximale Gesundheit", 20.0D, 0.0D, 1024.0D, true),
FOLLOW_RANGE("generic.followRange", "Kreaturen-Folgedistanz", 32.0D, 0.0D, 2048.0D, false),
KNOCKBACK_RESISTANCE("generic.knockbackResistance", "Standfestigkeit", 0.0D, 0.0D, 1.0D, false),
MOVEMENT_SPEED("generic.movementSpeed", "Geschwindigkeit", 0.699999988079071D, 0.0D, 1024.0D, true),
ATTACK_DAMAGE("generic.attackDamage", "Angriffsschaden", 2.0D, 0.0D, 2048.0D, false),
RADIATION("generic.radiation", "Strahlung", 0.0D, 0.0D, 16384.0D, false),
RADIATION_RESISTANCE("generic.radiationResistance", "Strahlungsresistenz", 10.0D, 0.0D, 16384.0D, false),
MANA_CAPACITY("generic.manaCapacity", "Mana-Kapazität", 0.0D, 0.0D, 2048.0D, false),
MAGIC_RESISTANCE("generic.magicResistance", "Magieresistenz", 0.0D, 0.0D, 4096.0D, false),
REINFORCEMENT_CHANCE("zombie.spawnReinforcements", "Zombie-Verstärkung", 0.0D, 0.0D, 1.0D, false),
HORSE_JUMP_STRENGTH("horse.jumpStrength", "Pferdesprungstärke", 0.7D, 0.0D, 2.0D, true);
public class Attribute
{
private static final Map<String, Attribute> ATTRIBUTES = Maps.newHashMap();
private final String name;
private final String display;
private final double defValue;
private final double minValue;
private final double maxValue;
private final boolean shouldWatch;
public static Attribute getAttribute(String name) {
return ATTRIBUTES.get(name);
}
public Attribute(String name, String display, double def, double min, double max, boolean watch)
{
this.name = name;
this.display = display;
this.defValue = def;
if(name == null)
throw new IllegalArgumentException("Name cannot be null!");
this.minValue = min;
this.maxValue = max;
this.shouldWatch = watch;
private final String name;
private final String display;
private final double defValue;
private final double minValue;
private final double maxValue;
private final boolean watch;
if (min > max)
{
throw new IllegalArgumentException("Minimum value cannot be bigger than maximum value!");
}
else if (def < min)
{
throw new IllegalArgumentException("Default value cannot be lower than minimum value!");
}
else if (def > max)
{
throw new IllegalArgumentException("Default value cannot be bigger than maximum value!");
}
ATTRIBUTES.put(name, this);
}
static {
for(Attribute attr : values()) {
ATTRIBUTES.put(attr.name, attr);
}
}
public String getUnlocalizedName()
{
return this.name;
}
public static Attribute getAttribute(String name) {
return ATTRIBUTES.get(name);
}
public String getDisplayName()
{
return this.display;
}
private Attribute(String name, String display, double def, double min, double max, boolean watch) {
if(name == null)
throw new IllegalArgumentException("Name kann nicht null sein");
else if(min > max)
throw new IllegalArgumentException("Mindestwert kann nicht größer als Maximalwert sein");
else if(def < min)
throw new IllegalArgumentException("Standardwert kann nicht kleiner als Mindestwert sein");
else if(def > max)
throw new IllegalArgumentException("Standardwert kann nicht größer als Maximalwert sein");
this.name = name;
this.display = display;
this.defValue = def;
this.minValue = min;
this.maxValue = max;
this.watch = watch;
}
public double getDefaultValue()
{
return this.defValue;
}
public String getName() {
return this.name;
}
public boolean getShouldWatch()
{
return this.shouldWatch;
}
public String getDisplay() {
return this.display;
}
public double clampValue(double value)
{
return ExtMath.clampd(value, this.minValue, this.maxValue);
}
public double getDefault() {
return this.defValue;
}
public int hashCode()
{
return this.name.hashCode();
}
public boolean isWatched() {
return this.watch;
}
public boolean equals(Object obj)
{
return obj instanceof Attribute && this.name.equals(((Attribute)obj).getUnlocalizedName());
}
public double clamp(double value) {
return ExtMath.clampd(value, this.minValue, this.maxValue);
}
}

View file

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

View file

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

View file

@ -7,156 +7,105 @@ import common.log.Log;
import common.tags.TagObject;
import java.util.List;
public class Attributes
{
public static final Attribute MAX_HEALTH = (new Attribute("generic.maxHealth", "Maximale Gesundheit", 20.0D, 0.0D, 1024.0D, true));
public static final Attribute FOLLOW_RANGE = (new Attribute("generic.followRange", "Kreaturen-Folgedistanz", 32.0D, 0.0D, 2048.0D, false));
public static final Attribute KNOCKBACK_RESISTANCE = (new Attribute("generic.knockbackResistance", "Standfestigkeit", 0.0D, 0.0D, 1.0D, false));
public static final Attribute MOVEMENT_SPEED = (new Attribute("generic.movementSpeed", "Geschwindigkeit", 0.699999988079071D, 0.0D, 1024.0D, true));
public static final Attribute ATTACK_DAMAGE = new Attribute("generic.attackDamage", "Angriffsschaden", 2.0D, 0.0D, 2048.0D, false);
public static final Attribute RADIATION = new Attribute("generic.radiation", "Strahlung", 0.0D, 0.0D, 16384.0D, false);
public static final Attribute RADIATION_RESISTANCE = new Attribute("generic.radiationResistance", "Strahlungsresistenz", 10.0D, 0.0D, 16384.0D, false);
public static final Attribute MANA_CAPACITY = new Attribute("generic.manaCapacity", "Mana-Kapazität", 0.0D, 0.0D, 2048.0D, false);
public static final Attribute MAGIC_RESISTANCE = new Attribute("generic.magicResistance", "Magieresistenz", 0.0D, 0.0D, 4096.0D, false);
public static final Attribute REINFORCEMENT_CHANCE = (new Attribute("zombie.spawnReinforcements", "Zombie-Verstärkung", 0.0D, 0.0D, 1.0D, false));
public static final Attribute HORSE_JUMP_STRENGTH = (new Attribute("horse.jumpStrength", "Pferdesprungstärke", 0.7D, 0.0D, 2.0D, true));
public class Attributes {
public static final AttributeModifier RUSHING_SPEED_MOD = new AttributeModifier(AttributeModifier.getModifierId("RushSpd"), "Attacking speed boost", 0.05, false, false);
public static final AttributeModifier MAGE_POTSPEED_MOD = new AttributeModifier(AttributeModifier.getModifierId("MagePot"), "Drinking speed penalty", -0.25, false, false);
public static final AttributeModifier ZOMBIE_BABY_MOD = new AttributeModifier(AttributeModifier.getModifierId("ZombSpd"), "Baby speed boost", 0.5, true);
public static final AttributeModifier FLEEING_SPEED_MOD = new AttributeModifier(AttributeModifier.getModifierId("FleeSpd"), "Fleeing speed bonus", 2.0, true, false);
public static final AttributeModifier SPRINT_SPEED_MOD = new AttributeModifier(AttributeModifier.getModifierId("Sprint"), "Sprinting speed boost", 0.3, true, false);
public static final AttributeModifier MOUSE_SPEEDY_MOD = new AttributeModifier(AttributeModifier.getModifierId("SpeedyG"), "Mouse speed boost", 1.0, true);
// public static final long ATTACK_SPEED_ID = AttributeModifier.getModifierId("EnderSp");
// public static final AttributeModifier ATTACK_SPEED_MOD = (new AttributeModifier(ATTACK_SPEED_ID, "Attacking speed boost", 0.15000000596046448D, false, false));
public static final long RUSHING_SPEED_ID = AttributeModifier.getModifierId("RushSpd");
public static final AttributeModifier RUSHING_SPEED_MOD = (new AttributeModifier(RUSHING_SPEED_ID, "Attacking speed boost", 0.05D, false, false));
public static final long MAGE_POTSPEED_ID = AttributeModifier.getModifierId("MagePot");
public static final AttributeModifier MAGE_POTSPEED_MOD = (new AttributeModifier(MAGE_POTSPEED_ID, "Drinking speed penalty", -0.25D, false, false));
public static final long ZOMBIE_BABY_ID = AttributeModifier.getModifierId("ZombSpd");
public static final AttributeModifier ZOMBIE_BABY_MOD = new AttributeModifier(ZOMBIE_BABY_ID, "Baby speed boost", 0.5D, true);
public static final long FLEEING_SPEED_ID = AttributeModifier.getModifierId("FleeSpd");
public static final AttributeModifier FLEEING_SPEED_MOD = (new AttributeModifier(FLEEING_SPEED_ID, "Fleeing speed bonus", 2.0D, true, false));
public static final long SPRINT_SPEED_ID = AttributeModifier.getModifierId("Sprint");
public static final AttributeModifier SPRINT_SPEED_MOD = (new AttributeModifier(SPRINT_SPEED_ID, "Sprinting speed boost", 0.30000001192092896D, true, false));
public static final long ITEM_VAL_ID = AttributeModifier.getModifierId("ItemVal");
public static final long RADIATION_BASE = AttributeModifier.getModifierId("NukeVal");
public static final long MOUSE_SPEEDY_ID = AttributeModifier.getModifierId("SpeedyG");
public static final AttributeModifier MOUSE_SPEEDY_MOD = new AttributeModifier(MOUSE_SPEEDY_ID, "Mouse speed boost", 1.0D, true);
public static final long ITEM_DMG_ID = AttributeModifier.getModifierId("ItemDmg");
/**
* Creates an NBTTagList from a BaseAttributeMap, including all its AttributeInstances
*/
public static List<TagObject> writeBaseAttributeMapToNBT(AttributeMap map)
{
List<TagObject> nbttaglist = Lists.newArrayList();
public static List<TagObject> writeBaseAttributeMapToNBT(AttributeMap map) {
List<TagObject> attrs = Lists.newArrayList();
for (AttributeInstance iattributeinstance : map.getAllAttributes())
{
nbttaglist.add(writeAttributeInstanceToNBT(iattributeinstance));
}
for(AttributeInstance instance : map.getAllAttributes()) {
attrs.add(writeAttributeInstanceToNBT(instance));
}
return nbttaglist;
}
return attrs;
}
/**
* Creates an NBTTagCompound from an AttributeInstance, including its AttributeModifiers
*/
private static TagObject writeAttributeInstanceToNBT(AttributeInstance instance)
{
TagObject nbttagcompound = new TagObject();
Attribute iattribute = instance.getAttribute();
nbttagcompound.setString("Name", iattribute.getUnlocalizedName());
nbttagcompound.setDouble("Base", instance.getBaseValue());
Collection<AttributeModifier> collection = instance.getModifiers();
private static TagObject writeAttributeInstanceToNBT(AttributeInstance instance) {
TagObject tag = new TagObject();
Attribute attr = instance.getAttribute();
tag.setString("Name", attr.getName());
tag.setDouble("Base", instance.getBaseValue());
Collection<AttributeModifier> modifiers = instance.getModifiers();
if (collection != null && !collection.isEmpty())
{
List<TagObject> nbttaglist = Lists.newArrayList();
if(modifiers != null && !modifiers.isEmpty()) {
List<TagObject> mods = Lists.newArrayList();
for (AttributeModifier attributemodifier : collection)
{
if (attributemodifier.isSaved())
{
nbttaglist.add(writeAttributeModifierToNBT(attributemodifier));
}
}
for(AttributeModifier mod : modifiers) {
if(mod.isSaved()) {
mods.add(writeAttributeModifierToNBT(mod));
}
}
nbttagcompound.setList("Modifiers", nbttaglist);
}
tag.setList("Modifiers", mods);
}
return nbttagcompound;
}
return tag;
}
/**
* Creates an NBTTagCompound from an AttributeModifier
*/
private static TagObject writeAttributeModifierToNBT(AttributeModifier modifier)
{
TagObject nbttagcompound = new TagObject();
nbttagcompound.setString("Name", modifier.getName());
nbttagcompound.setDouble("Amount", modifier.getAmount());
nbttagcompound.setBool("Multiply", modifier.isMultiplied());
nbttagcompound.setLong("AttrId", modifier.getID());
return nbttagcompound;
}
private static TagObject writeAttributeModifierToNBT(AttributeModifier mod) {
TagObject tag = new TagObject();
tag.setString("Name", mod.getName());
tag.setDouble("Amount", mod.getAmount());
tag.setBool("Multiply", mod.isMultiplied());
tag.setLong("AttrId", mod.getID());
return tag;
}
public static void setAttributeModifiers(AttributeMap map, List<TagObject> list)
{
for (int i = 0; i < list.size(); ++i)
{
TagObject nbttagcompound = list.get(i);
AttributeInstance iattributeinstance = map.getAttributeInstanceByName(nbttagcompound.getString("Name"));
public static void setAttributeModifiers(AttributeMap map, List<TagObject> mods) {
for(int i = 0; i < mods.size(); ++i) {
TagObject mod = mods.get(i);
AttributeInstance instance = map.getAttributeInstanceByName(mod.getString("Name"));
if (iattributeinstance != null)
{
applyModifiersToAttributeInstance(iattributeinstance, nbttagcompound);
}
else
{
Log.TICK.warn("Ignoriere unbekannte Attribute \'" + nbttagcompound.getString("Name") + "\'");
}
}
}
if(instance != null) {
applyModifiersToAttributeInstance(instance, mod);
}
else {
Log.TICK.warn("Ignoriere unbekannte Attribute \'" + mod.getString("Name") + "\'");
}
}
}
private static void applyModifiersToAttributeInstance(AttributeInstance instance, TagObject compound)
{
instance.setBaseValue(compound.getDouble("Base"));
private static void applyModifiersToAttributeInstance(AttributeInstance instance, TagObject tag) {
instance.setBaseValue(tag.getDouble("Base"));
if (compound.hasList("Modifiers"))
{
List<TagObject> nbttaglist = compound.getList("Modifiers");
if(tag.hasList("Modifiers")) {
List<TagObject> mods = tag.getList("Modifiers");
for (int i = 0; i < nbttaglist.size(); ++i)
{
AttributeModifier attributemodifier = readAttributeModifierFromNBT(nbttaglist.get(i));
for(int i = 0; i < mods.size(); ++i) {
AttributeModifier mod = readAttributeModifierFromNBT(mods.get(i));
if (attributemodifier != null)
{
AttributeModifier attributemodifier1 = instance.getModifier(attributemodifier.getID());
if(mod != null) {
AttributeModifier old = instance.getModifier(mod.getID());
if (attributemodifier1 != null)
{
instance.removeModifier(attributemodifier1);
}
if(old != null) {
instance.removeModifier(old);
}
instance.applyModifier(attributemodifier);
}
}
}
}
instance.applyModifier(mod);
}
}
}
}
/**
* Creates an AttributeModifier from an NBTTagCompound
*/
public static AttributeModifier readAttributeModifierFromNBT(TagObject compound)
{
long id = compound.getLong("AttrId");
if(id == 0L)
return null;
public static AttributeModifier readAttributeModifierFromNBT(TagObject tag) {
long id = tag.getLong("AttrId");
if(id == 0L)
return null;
try
{
return new AttributeModifier(id, compound.getString("Name"), compound.getDouble("Amount"), compound.getBool("Multiply"));
}
catch (Exception exception)
{
Log.TICK.warn("Konnte Attribute nicht erstellen: " + exception.getMessage());
return null;
}
}
try {
return new AttributeModifier(id, tag.getString("Name"), tag.getDouble("Amount"), tag.getBool("Multiply"));
}
catch(Exception e) {
Log.TICK.warn("Konnte Attribute nicht erstellen: " + e.getMessage());
return null;
}
}
}

View file

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

View file

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

View file

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

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

View file

@ -2,22 +2,5 @@ package common.dimension;
import common.world.State;
public class Lake {
public final State state;
public final State filler;
public final State top;
public final int chance;
public final int minHeight;
public final int maxHeight;
public final boolean ratiod;
public Lake(State state, State filler, State top, int chance, int minHeight, int maxHeight, boolean ratiod) {
this.state = state;
this.filler = filler;
this.top = top;
this.chance = chance;
this.minHeight = minHeight;
this.maxHeight = maxHeight;
this.ratiod = ratiod;
}
public record Lake(State state, State filler, State top, int chance, int minHeight, int maxHeight, boolean ratiod) {
}

View file

@ -2,18 +2,5 @@ package common.dimension;
import common.world.State;
public class Liquid {
public final State state;
public final int chance;
public final int minHeight;
public final int maxHeight;
public final boolean lower;
public Liquid(State state, int chance, int minHeight, int maxHeight, boolean lower) {
this.state = state;
this.chance = chance;
this.minHeight = minHeight;
this.maxHeight = maxHeight;
this.lower = lower;
}
public record Liquid(State state, int chance, int minHeight, int maxHeight, boolean lower) {
}

View file

@ -2,22 +2,5 @@ package common.dimension;
import common.world.State;
public class Ore {
public final State state;
public final int count;
public final int more;
public final int size;
public final int min;
public final int max;
public final boolean dist;
public Ore(State state, int count, int more, int size, int min, int max, boolean dist) {
this.state = state;
this.count = count;
this.more = more;
this.size = size;
this.min = min;
this.max = max;
this.dist = dist;
}
public record Ore(State state, int count, int more, int size, int min, int max, boolean dist) {
}

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,14 +2,17 @@ package common.dispenser;
import common.tileentity.TileEntity;
import common.util.BlockPos;
import common.world.World;
public interface IBlockSource extends ILocatableSource
public interface IBlockSource extends IPosition
{
double getX();
double getY();
double getZ();
World getWorld();
BlockPos getBlockPos();

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) {
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) {

View file

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

View file

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

View file

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

View file

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

View file

@ -13,7 +13,7 @@ import common.ai.EntityAITargetNonTamed;
import common.ai.EntityAITempt;
import common.ai.EntityAIWander;
import common.ai.EntityAIWatchClosest;
import common.attributes.Attributes;
import common.attributes.Attribute;
import common.entity.DamageSource;
import common.entity.Entity;
import common.entity.npc.Alignment;
@ -113,7 +113,7 @@ public class EntityOcelot extends EntityTameable
{
super.applyEntityAttributes();
this.setMaxHealth(10);
this.getEntityAttribute(Attributes.MOVEMENT_SPEED).setBaseValue(0.30000001192092896D);
this.getEntityAttribute(Attribute.MOVEMENT_SPEED).setBaseValue(0.30000001192092896D);
}
public void fall(float distance, float damageMultiplier)

View file

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

View file

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

View file

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

View file

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

View file

@ -11,7 +11,7 @@ import common.item.ItemStack;
import common.tags.TagObject;
import java.util.List;
import common.tileentity.ILockableContainer;
import common.tileentity.LockCode;
import common.tileentity.Passcode;
import common.util.BlockPos;
import common.util.PortalType;
import common.world.World;
@ -269,13 +269,13 @@ public abstract class EntityCartContainer extends EntityCart implements ILockabl
return false;
}
public void setLockCode(LockCode code)
public void setLockCode(Passcode code)
{
}
public LockCode getLockCode()
public Passcode getLockCode()
{
return LockCode.EMPTY_CODE;
return Passcode.EMPTY_CODE;
}
public void clear()

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 common.attributes.Attributes;
import common.attributes.Attribute;
import common.collect.Lists;
import common.init.Items;
import common.init.SpeciesRegistry;
@ -118,7 +118,7 @@ public class EntityChaosMarine extends EntityNPC {
protected void applyEntityAttributes() {
super.applyEntityAttributes();
this.getEntityAttribute(Attributes.ATTACK_DAMAGE).setBaseValue(12.0D);
this.getEntityAttribute(Attribute.ATTACK_DAMAGE).setBaseValue(12.0D);
}
protected ItemStack pickItem() {

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -2,7 +2,7 @@ package common.entity.npc;
import common.ai.EntityAIBase;
import common.ai.EntityMoveHelper;
import common.attributes.Attributes;
import common.attributes.Attribute;
import common.biome.Biome;
import common.entity.DamageSource;
import common.entity.Entity;
@ -661,7 +661,7 @@ public class EntitySlime extends EntityNPC
if (this.entity.onGround)
{
this.entity.setAIMoveSpeed((float)(this.speed * this.entity.getEntityAttribute(Attributes.MOVEMENT_SPEED).getAttributeValue()));
this.entity.setAIMoveSpeed((float)(this.speed * this.entity.getEntityAttribute(Attribute.MOVEMENT_SPEED).getAttributeValue()));
if (this.jumpDelay-- <= 0)
{
@ -688,7 +688,7 @@ public class EntitySlime extends EntityNPC
}
else
{
this.entity.setAIMoveSpeed((float)(this.speed * this.entity.getEntityAttribute(Attributes.MOVEMENT_SPEED).getAttributeValue()));
this.entity.setAIMoveSpeed((float)(this.speed * this.entity.getEntityAttribute(Attribute.MOVEMENT_SPEED).getAttributeValue()));
}
}
}

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -2,22 +2,5 @@ package common.entity.npc;
import common.util.BlockPos;
public class PlayerCharacter {
public final String name;
public final String info;
public final Alignment align;
public final String dim;
public final BlockPos pos;
public final String type;
public final int level;
public PlayerCharacter(String name, String info, Alignment align, String dim, BlockPos pos, String type, int level) {
this.name = name;
this.info = info;
this.align = align;
this.dim = dim;
this.pos = pos;
this.type = type;
this.level = level;
}
public record PlayerCharacter(String name, String info, Alignment align, String dim, BlockPos pos, String type, int level) {
}

View file

@ -2,32 +2,5 @@ package common.entity.types;
import common.entity.DamageSource;
public class CombatEntry {
private final DamageSource source;
private final int damage;
private final String blockType;
private final float fallDistance;
public CombatEntry(DamageSource source, int damage, String blockType, float fallDistance) {
this.source = source;
this.damage = damage;
this.blockType = blockType;
this.fallDistance = fallDistance;
}
public DamageSource getSource() {
return this.source;
}
public int getDamage() {
return this.damage;
}
public String getBlockType() {
return this.blockType;
}
public float getFallDistance() {
return this.source == DamageSource.outOfWorld ? Float.MAX_VALUE : this.fallDistance;
}
public record CombatEntry(DamageSource source, int damage, String blockType, float fallDistance) {
}

View file

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

View file

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

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<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();
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 boolean register;
@ -89,7 +89,7 @@ public abstract class EntityRegistry {
}
else {
// String name = clazz.getSimpleName().substring(6);
SPAWN_EGGS.put(name, new EntityEggInfo(name, origin, eggColor, spotColor));
SPAWN_EGGS.put(name, new EntityInfo(name, origin, eggColor, spotColor));
}
}

View file

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

View file

@ -5,7 +5,7 @@ import java.util.Map;
import common.collect.Maps;
import common.entity.npc.EntityNPC;
import common.tileentity.ILockableContainer;
import common.tileentity.LockCode;
import common.tileentity.Passcode;
public class ContainerLocalMenu extends InventoryBasic implements ILockableContainer
{
@ -38,13 +38,13 @@ public class ContainerLocalMenu extends InventoryBasic implements ILockableConta
return false;
}
public void setLockCode(LockCode code)
public void setLockCode(Passcode code)
{
}
public LockCode getLockCode()
public Passcode getLockCode()
{
return LockCode.EMPTY_CODE;
return Passcode.EMPTY_CODE;
}
public String getGuiID()

View file

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

View file

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

View file

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

View file

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

View file

@ -67,7 +67,7 @@ public class ItemBucketMilk extends Item
public Map<Attribute, Set<AttributeModifier>> 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;
}

View file

@ -39,7 +39,7 @@ public class ItemMetal extends Item {
{
Map<Attribute, Set<AttributeModifier>> multimap = super.getItemInventoryModifiers();
if(this.metal.radioactivity > 0.0f)
multimap.put(Attributes.RADIATION, Sets.newHashSet(new AttributeModifier(Attributes.ITEM_VAL_ID, "Metal modifier", (double)this.metal.radioactivity * 4.0, false, true, true)));
multimap.put(Attribute.RADIATION, Sets.newHashSet(new AttributeModifier(Attributes.ITEM_VAL_ID, "Metal modifier", (double)this.metal.radioactivity * 4.0, false, true, true)));
return multimap;
}

View file

@ -43,7 +43,7 @@ public class ItemMetalBlock extends ItemBlock {
{
Map<Attribute, Set<AttributeModifier>> multimap = super.getItemInventoryModifiers();
if(this.metal.radioactivity > 0.0f)
multimap.put(Attributes.RADIATION, Sets.newHashSet(new AttributeModifier(Attributes.ITEM_VAL_ID, "Metal modifier", (double)this.metal.radioactivity * 4.0 * (this.ore ? 2.0 : 9.0), false, true, true)));
multimap.put(Attribute.RADIATION, Sets.newHashSet(new AttributeModifier(Attributes.ITEM_VAL_ID, "Metal modifier", (double)this.metal.radioactivity * 4.0 * (this.ore ? 2.0 : 9.0), false, true, true)));
return multimap;
}

View file

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

View file

@ -324,12 +324,12 @@ public class ItemPotion extends Item
if (d0 > 0.0D)
{
tooltip.add(TextColor.BLUE + String.format("+%s" + (attributemodifier2.isMultiplied() ? "%%" : "") + " %s", ItemStack.DECIMALFORMAT.format(d1), entry1.getKey().getDisplayName()));
tooltip.add(TextColor.BLUE + String.format("+%s" + (attributemodifier2.isMultiplied() ? "%%" : "") + " %s", ItemStack.DECIMALFORMAT.format(d1), entry1.getKey().getDisplay()));
}
else if (d0 < 0.0D)
{
d1 = d1 * -1.0D;
tooltip.add(TextColor.RED + String.format("-%s" + (attributemodifier2.isMultiplied() ? "%%" : "") + " %s", ItemStack.DECIMALFORMAT.format(d1), entry1.getKey().getDisplayName()));
tooltip.add(TextColor.RED + String.format("-%s" + (attributemodifier2.isMultiplied() ? "%%" : "") + " %s", ItemStack.DECIMALFORMAT.format(d1), entry1.getKey().getDisplay()));
}
}
}

View file

@ -882,7 +882,7 @@ public final class ItemStack
for(AttributeModifier mod : entry.getValue()) {
double amt = mod.getAmount();
if (mod.getID() == Attributes.ITEM_VAL_ID)
if (mod.getID() == Attributes.ITEM_DMG_ID)
{
amt += (double)EnchantmentHelper.getDamageModifier(this);
}
@ -901,25 +901,20 @@ public final class ItemStack
if(mod.isInventory() && this.size != 1) {
double total = num * (double)this.size;
if (amt > 0.0D)
list.add(TextColor.BLUE + String.format("+%s" + (mod.isMultiplied() ? "%%" : "") + " %s [%dx +%s" + (mod.isMultiplied() ? "%%" : "") + "]", DECIMALFORMAT.format(total), entry.getKey().getDisplayName(), this.size, DECIMALFORMAT.format(num)));
list.add(TextColor.BLUE + String.format("+%s" + (mod.isMultiplied() ? "%%" : "") + " %s [%dx +%s" + (mod.isMultiplied() ? "%%" : "") + "]", DECIMALFORMAT.format(total), entry.getKey().getDisplay(), this.size, DECIMALFORMAT.format(num)));
else if (amt < 0.0D)
list.add(TextColor.RED + String.format("-%s" + (mod.isMultiplied() ? "%%" : "") + " %s [%dx -%s" + (mod.isMultiplied() ? "%%" : "") + "]", DECIMALFORMAT.format(total * -1.0), entry.getKey().getDisplayName(), this.size, DECIMALFORMAT.format(num * -1.0)));
list.add(TextColor.RED + String.format("-%s" + (mod.isMultiplied() ? "%%" : "") + " %s [%dx -%s" + (mod.isMultiplied() ? "%%" : "") + "]", DECIMALFORMAT.format(total * -1.0), entry.getKey().getDisplay(), this.size, DECIMALFORMAT.format(num * -1.0)));
}
else {
if (amt > 0.0D)
list.add(TextColor.BLUE + String.format("+%s" + (mod.isMultiplied() ? "%%" : "") + " %s", DECIMALFORMAT.format(num), entry.getKey().getDisplayName()));
list.add(TextColor.BLUE + String.format("+%s" + (mod.isMultiplied() ? "%%" : "") + " %s", DECIMALFORMAT.format(num), entry.getKey().getDisplay()));
else if (amt < 0.0D)
list.add(TextColor.RED + String.format("-%s" + (mod.isMultiplied() ? "%%" : "") + " %s", DECIMALFORMAT.format(num * -1.0), entry.getKey().getDisplayName()));
list.add(TextColor.RED + String.format("-%s" + (mod.isMultiplied() ? "%%" : "") + " %s", DECIMALFORMAT.format(num * -1.0), entry.getKey().getDisplay()));
}
}
}
}
if (this.hasTagCompound() && this.getTagCompound().getBool("Unbreakable")) // && (i1 & 4) == 0)
{
list.add(TextColor.BLUE + "Unzerstörbar");
}
// if (this.hasTagCompound() && this.stackTagCompound.hasList("CanDestroy") && (i1 & 8) == 0)
// {
// NBTTagList nbttaglist2 = this.stackTagCompound.getTagList("CanDestroy", 8);

View file

@ -148,7 +148,7 @@ public class ItemSword extends Item
public Map<Attribute, Set<AttributeModifier>> 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;
}

View file

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

View file

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

View file

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

View file

@ -1,37 +1,5 @@
package common.model;
import common.util.Vector3f;
public class Transform {
public static final Transform IDENTITY = new Transform(0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f);
public final Vector3f rotation;
public final Vector3f translation;
public final Vector3f scale;
public Transform(float rx, float ry, float rz, float tx, float ty, float tz, float sx, float sy, float sz) {
this.rotation = new Vector3f(rx, ry, rz);
this.translation = (Vector3f)new Vector3f(tx, ty, tz).scale(0.0625F);
this.scale = new Vector3f(sx, sy, sz);
}
public boolean equals(Object obj) {
if(this == obj) {
return true;
}
else if(this.getClass() != obj.getClass()) {
return false;
}
else {
Transform other = (Transform)obj;
return this.rotation.equals(other.rotation) && this.scale.equals(other.scale) && this.translation.equals(other.translation);
}
}
public int hashCode() {
int i = this.rotation.hashCode();
i = 31 * i + this.translation.hashCode();
i = 31 * i + this.scale.hashCode();
return i;
}
public record Transform(float rotationX, float rotationY, float rotationZ, float translationX, float translationY, float translationZ, float scale) {
public static final Transform IDENTITY = new Transform(0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f);
}

View file

@ -8,122 +8,122 @@ public enum Transforms {
Transform.IDENTITY
),
ANVIL(
new Transform(10.0f, -45.0f, 170.0f, 0.25f, 1.5f, -2.5f, 0.375f, 0.375f, 0.375f),
transform(10.0f, -45.0f, 170.0f, 0.25f, 1.5f, -2.5f, 0.375f),
Transform.IDENTITY,
Transform.IDENTITY,
Transform.IDENTITY
),
BLOCK(
new Transform(10.0f, -45.0f, 170.0f, 0.0f, 1.5f, -2.75f, 0.375f, 0.375f, 0.375f),
transform(10.0f, -45.0f, 170.0f, 0.0f, 1.5f, -2.75f, 0.375f),
Transform.IDENTITY,
Transform.IDENTITY,
Transform.IDENTITY
),
ITEM(
new Transform(-90.0f, 0.0f, 0.0f, 0.0f, 1.0f, -3.0f, 0.55f, 0.55f, 0.55f),
new Transform(0.0f, -135.0f, 25.0f, 0.0f, 4.0f, 2.0f, 1.7f, 1.7f, 1.7f),
transform(-90.0f, 0.0f, 0.0f, 0.0f, 1.0f, -3.0f, 0.55f),
transform(0.0f, -135.0f, 25.0f, 0.0f, 4.0f, 2.0f, 1.7f),
Transform.IDENTITY,
Transform.IDENTITY
),
TOOL_FLIP(
new Transform(180.0f, 90.0f, -35.0f, 0.0f, 0.0f, -3.5f, 0.85f, 0.85f, 0.85f),
new Transform(0.0f, 45.0f, 25.0f, 0.0f, 4.0f, 2.0f, 1.7f, 1.7f, 1.7f),
transform(180.0f, 90.0f, -35.0f, 0.0f, 0.0f, -3.5f, 0.85f),
transform(0.0f, 45.0f, 25.0f, 0.0f, 4.0f, 2.0f, 1.7f),
Transform.IDENTITY,
Transform.IDENTITY
),
TOOL(
new Transform(0.0f, 90.0f, -35.0f, 0.0f, 1.25f, -3.5f, 0.85f, 0.85f, 0.85f),
new Transform(0.0f, -135.0f, 25.0f, 0.0f, 4.0f, 2.0f, 1.7f, 1.7f, 1.7f),
transform(0.0f, 90.0f, -35.0f, 0.0f, 1.25f, -3.5f, 0.85f),
transform(0.0f, -135.0f, 25.0f, 0.0f, 4.0f, 2.0f, 1.7f),
Transform.IDENTITY,
Transform.IDENTITY
),
OFFSET2(
new Transform(-90.0f, 0.0f, 0.0f, 0.0f, 1.0f, -2.25f, 0.55f, 0.55f, 0.55f),
new Transform(0.0f, -135.0f, 25.0f, 0.0f, 4.0f, 2.0f, 1.7f, 1.7f, 1.7f),
transform(-90.0f, 0.0f, 0.0f, 0.0f, 1.0f, -2.25f, 0.55f),
transform(0.0f, -135.0f, 25.0f, 0.0f, 4.0f, 2.0f, 1.7f),
Transform.IDENTITY,
Transform.IDENTITY
),
LAYER(
new Transform(10.0f, -45.0f, 170.0f, 0.0f, 0.25f, -2.75f, 0.375f, 0.375f, 0.375f),
new Transform(0.0f, 0.0f, 0.0f, 0.0f, 5.25f, 0.0f, 1.0f, 1.0f, 1.0f),
transform(10.0f, -45.0f, 170.0f, 0.0f, 0.25f, -2.75f, 0.375f),
transform(0.0f, 0.0f, 0.0f, 0.0f, 5.25f, 0.0f, 1.0f),
Transform.IDENTITY,
Transform.IDENTITY
),
DICE(
new Transform(10.0f, -45.0f, 170.0f, 0.0f, 1.5f, -1.75f, 0.15f, 0.15f, 0.15f),
new Transform(0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.4f, 0.4f, 0.4f),
new Transform(135.0f, -55.0f, 180.0f, 0.0f, 0.0f, 0.0f, 1.1f, 1.1f, 1.1f),
new Transform(0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.4f, 0.4f, 0.4f)
transform(10.0f, -45.0f, 170.0f, 0.0f, 1.5f, -1.75f, 0.15f),
transform(0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.4f),
transform(135.0f, -55.0f, 180.0f, 0.0f, 0.0f, 0.0f, 1.1f),
transform(0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.4f)
),
STAIRS(
new Transform(10.0f, -45.0f, 170.0f, 0.0f, 1.5f, -2.75f, 0.375f, 0.375f, 0.375f),
transform(10.0f, -45.0f, 170.0f, 0.0f, 1.5f, -2.75f, 0.375f),
Transform.IDENTITY,
new Transform(0.0f, 180.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f),
transform(0.0f, 180.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f),
Transform.IDENTITY
),
OFFSET1(
new Transform(-90.0f, 0.0f, 0.0f, 0.0f, 1.0f, -2.5f, 0.55f, 0.55f, 0.55f),
new Transform(0.0f, -135.0f, 25.0f, 0.0f, 4.0f, 2.0f, 1.7f, 1.7f, 1.7f),
transform(-90.0f, 0.0f, 0.0f, 0.0f, 1.0f, -2.5f, 0.55f),
transform(0.0f, -135.0f, 25.0f, 0.0f, 4.0f, 2.0f, 1.7f),
Transform.IDENTITY,
Transform.IDENTITY
),
GATE(
new Transform(0.0f, -90.0f, 170.0f, 0.0f, 1.5f, -2.75f, 0.375f, 0.375f, 0.375f),
new Transform(0.0f, 90.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f),
transform(0.0f, -90.0f, 170.0f, 0.0f, 1.5f, -2.75f, 0.375f),
transform(0.0f, 90.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f),
Transform.IDENTITY,
Transform.IDENTITY
),
NUGGET(
new Transform(-90.0f, 0.0f, 0.0f, 0.0f, 1.0f, -2.0f, 0.55f, 0.55f, 0.55f),
new Transform(0.0f, -135.0f, 25.0f, 0.0f, 4.0f, 2.0f, 1.7f, 1.7f, 1.7f),
transform(-90.0f, 0.0f, 0.0f, 0.0f, 1.0f, -2.0f, 0.55f),
transform(0.0f, -135.0f, 25.0f, 0.0f, 4.0f, 2.0f, 1.7f),
Transform.IDENTITY,
Transform.IDENTITY
),
SKULL(
new Transform(180.0f, -45.0f, 0.0f, 0.0f, 1.0f, -2.5f, 0.25f, 0.25f, 0.25f),
new Transform(0.0f, -180.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.55f, 0.55f, 0.55f),
new Transform(0.0f, 180.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.7f, 0.7f, 0.7f),
transform(180.0f, -45.0f, 0.0f, 0.0f, 1.0f, -2.5f, 0.25f),
transform(0.0f, -180.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.55f),
transform(0.0f, 180.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.7f),
Transform.IDENTITY
),
BUTTON(
new Transform(10.0f, -45.0f, 170.0f, 0.0f, 1.0f, -1.75f, 0.375f, 0.375f, 0.375f),
transform(10.0f, -45.0f, 170.0f, 0.0f, 1.0f, -1.75f, 0.375f),
Transform.IDENTITY,
Transform.IDENTITY,
Transform.IDENTITY
),
RANGED(
new Transform(5.0f, 80.0f, -45.0f, 0.75f, 0.0f, 0.25f, 1.0f, 1.0f, 1.0f),
new Transform(0.0f, -135.0f, 25.0f, 0.0f, 4.0f, 2.0f, 1.7f, 1.7f, 1.7f),
transform(5.0f, 80.0f, -45.0f, 0.75f, 0.0f, 0.25f, 1.0f),
transform(0.0f, -135.0f, 25.0f, 0.0f, 4.0f, 2.0f, 1.7f),
Transform.IDENTITY,
Transform.IDENTITY
),
BANNER(
new Transform(0.0f, 90.0f, -90.0f, 0.0f, 0.0f, -4.0f, 0.5f, 0.5f, 0.5f),
new Transform(0.0f, 225.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f),
new Transform(0.0f, -65.0f, 0.0f, 0.0f, -3.0f, 0.0f, 0.85f, 0.85f, 0.85f),
transform(0.0f, 90.0f, -90.0f, 0.0f, 0.0f, -4.0f, 0.5f),
transform(0.0f, 225.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f),
transform(0.0f, -65.0f, 0.0f, 0.0f, -3.0f, 0.0f, 0.85f),
Transform.IDENTITY
),
FENCE(
new Transform(0.0f, 0.0f, 180.0f, 0.0f, 1.5f, -2.75f, 0.375f, 0.375f, 0.375f),
transform(0.0f, 0.0f, 180.0f, 0.0f, 1.5f, -2.75f, 0.375f),
Transform.IDENTITY,
new Transform(0.0f, 90.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f),
transform(0.0f, 90.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f),
Transform.IDENTITY
),
FLAT(
new Transform(10.0f, -45.0f, 170.0f, 0.0f, 0.25f, -2.75f, 0.375f, 0.375f, 0.375f),
new Transform(0.0f, 0.0f, 0.0f, 0.0f, 5.0f, 0.0f, 1.0f, 1.0f, 1.0f),
transform(10.0f, -45.0f, 170.0f, 0.0f, 0.25f, -2.75f, 0.375f),
transform(0.0f, 0.0f, 0.0f, 0.0f, 5.0f, 0.0f, 1.0f),
Transform.IDENTITY,
Transform.IDENTITY
),
ROD(
new Transform(0.0f, 90.0f, -35.0f, 0.0f, 0.75f, -3.5f, 0.85f, 0.85f, 0.85f),
new Transform(0.0f, -135.0f, 25.0f, 0.0f, 4.0f, 2.0f, 1.7f, 1.7f, 1.7f),
transform(0.0f, 90.0f, -35.0f, 0.0f, 0.75f, -3.5f, 0.85f),
transform(0.0f, -135.0f, 25.0f, 0.0f, 4.0f, 2.0f, 1.7f),
Transform.IDENTITY,
Transform.IDENTITY
),
KEY(
new Transform(0.0f, 270.0f, -35.0f, 0.0f, 1.25f, -3.5f, 0.85f, 0.85f, 0.85f),
new Transform(180.0f, -135.0f, 25.0f, 0.0f, 4.0f, 2.0f, 1.7f, 1.7f, 1.7f),
transform(0.0f, 270.0f, -35.0f, 0.0f, 1.25f, -3.5f, 0.85f),
transform(180.0f, -135.0f, 25.0f, 0.0f, 4.0f, 2.0f, 1.7f),
Transform.IDENTITY,
Transform.IDENTITY
);
@ -135,6 +135,10 @@ public enum Transforms {
GUI,
GROUND;
}
private static Transform transform(float rx, float ry, float rz, float tx, float ty, float tz, float scale) {
return new Transform(rx, ry, rz, tx * 0.0625f, ty * 0.0625f, tz * 0.0625f, scale);
}
public final Transform third;
public final Transform first;

View file

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

View file

@ -62,8 +62,8 @@ public class SPacketDisplayForm implements Packet<IClientPlayer>
buf.writeString(this.title);
buf.writeVarInt(this.data.length);
for(int z = 0; z < this.data.length; z++) {
buf.writeString(this.data[z].first);
Object obj = this.data[z].second;
buf.writeString(this.data[z].first());
Object obj = this.data[z].second();
if(obj instanceof Boolean) {
buf.writeByte(0);
buf.writeBoolean((Boolean)obj);
@ -80,7 +80,7 @@ public class SPacketDisplayForm implements Packet<IClientPlayer>
buf.writeByte(2);
buf.writeString((String)obj);
}
buf.writeVarInt(this.data[z].third);
buf.writeVarInt(this.data[z].third());
}
}

View file

@ -26,7 +26,7 @@ public class SPacketEntityProperties implements Packet<IClientPlayer>
for (AttributeInstance iattributeinstance : p_i45236_2_)
{
this.field_149444_b.add(new SPacketEntityProperties.Snapshot(iattributeinstance.getAttribute().getUnlocalizedName(), iattributeinstance.getBaseValue(), iattributeinstance.getModifiers()));
this.field_149444_b.add(new SPacketEntityProperties.Snapshot(iattributeinstance.getAttribute().getName(), iattributeinstance.getBaseValue(), iattributeinstance.getModifiers()));
}
}

View file

@ -69,9 +69,9 @@ public class SPacketTrades implements Packet<IClientPlayer>
for (int i = 0; i < this.recipes.size(); ++i)
{
MerchantRecipe merchantrecipe = (MerchantRecipe)this.recipes.get(i);
buf.writeItemStack(merchantrecipe.getBuying());
buf.writeItemStack(merchantrecipe.getSelling());
ItemStack itemstack = merchantrecipe.getSecondBuy();
buf.writeItemStack(merchantrecipe.first());
buf.writeItemStack(merchantrecipe.result());
ItemStack itemstack = merchantrecipe.second();
buf.writeBoolean(itemstack != null);
if (itemstack != null)

View file

@ -2,8 +2,8 @@ package common.pathfinding;
import java.util.List;
import common.attributes.Attribute;
import common.attributes.AttributeInstance;
import common.attributes.Attributes;
import common.entity.Entity;
import common.entity.types.EntityLiving;
import common.util.BlockPos;
@ -45,7 +45,7 @@ public abstract class PathNavigate
{
this.theEntity = entitylivingIn;
this.worldObj = worldIn;
this.pathSearchRange = entitylivingIn.getEntityAttribute(Attributes.FOLLOW_RANGE);
this.pathSearchRange = entitylivingIn.getEntityAttribute(Attribute.FOLLOW_RANGE);
this.pathFinder = this.getPathFinder();
}

View file

@ -7,7 +7,6 @@ import common.attributes.Attribute;
import common.attributes.AttributeInstance;
import common.attributes.AttributeMap;
import common.attributes.AttributeModifier;
import common.attributes.Attributes;
import common.collect.Maps;
import common.entity.DamageSource;
import common.entity.projectile.EntityPotion;
@ -15,15 +14,15 @@ import common.entity.types.EntityLiving;
import common.init.Config;
public enum Potion {
SPEED("speed", "Schnelligkeit", "Trank der Schnelligkeit", false, 8171462, new PotionModifier(Attributes.MOVEMENT_SPEED, "PotSpd", 0.2, true)),
SLOWNESS("slowness", "Langsamkeit", "Trank der Langsamkeit", true, 5926017, new PotionModifier(Attributes.MOVEMENT_SPEED, "PotSlow", -0.15, true)),
SPEED("speed", "Schnelligkeit", "Trank der Schnelligkeit", false, 8171462, new PotionModifier(Attribute.MOVEMENT_SPEED, "PotSpd", 0.2, true)),
SLOWNESS("slowness", "Langsamkeit", "Trank der Langsamkeit", true, 5926017, new PotionModifier(Attribute.MOVEMENT_SPEED, "PotSlow", -0.15, true)),
HASTE("haste", "Eile", "Trank der Eile", false, 14270531) {
public double getEffectiveness() {
return 1.5;
}
},
FATIGUE("mining_fatigue", "Abbaulähmung", "Trank der Trägheit", true, 4866583),
STRENGTH("strength", "Stärke", "Trank der Stärke", false, 9643043, new PotionModifier(Attributes.ATTACK_DAMAGE, "PotDmg", 2.5, true)) {
STRENGTH("strength", "Stärke", "Trank der Stärke", false, 9643043, new PotionModifier(Attribute.ATTACK_DAMAGE, "PotDmg", 2.5, true)) {
public double getAmount(int amp, AttributeModifier modifier) {
return 1.3D * (double)(amp + 1);
}
@ -109,8 +108,8 @@ public enum Potion {
}
},
NIGHT_VISION("night_vision", "Nachtsicht", "Trank der Nachtsicht", false, 2039713),
STABILITY("stability", "Stabilität", "Trank der Standfestigkeit", false, 5797459, new PotionModifier(Attributes.KNOCKBACK_RESISTANCE, "PotStbl", 1.0, false)),
WEAKNESS("weakness", "Schwäche", "Trank der Schwäche", true, 4738376, new PotionModifier(Attributes.ATTACK_DAMAGE, "PotWeak", 2.0, false)) {
STABILITY("stability", "Stabilität", "Trank der Standfestigkeit", false, 5797459, new PotionModifier(Attribute.KNOCKBACK_RESISTANCE, "PotStbl", 1.0, false)),
WEAKNESS("weakness", "Schwäche", "Trank der Schwäche", true, 4738376, new PotionModifier(Attribute.ATTACK_DAMAGE, "PotWeak", 2.0, false)) {
public double getAmount(int amp, AttributeModifier modifier) {
return (double)(-0.5F * (float)(amp + 1));
}
@ -126,7 +125,7 @@ public enum Potion {
return 0.25;
}
},
HEALTH("health_boost", "Extraenergie", "Trank der Extraenergie", false, 16284963, new PotionModifier(Attributes.MAX_HEALTH, "PotHp", 4.0, false)) {
HEALTH("health_boost", "Extraenergie", "Trank der Extraenergie", false, 16284963, new PotionModifier(Attribute.MAX_HEALTH, "PotHp", 4.0, false)) {
public void removeModifiers(EntityLiving entity, AttributeMap map, int amp) {
super.removeModifiers(entity, map, amp);
if(entity.getHealth() > entity.getMaxHealth())

View file

@ -6,7 +6,7 @@ public interface ILockableContainer extends IInventory, IInteractionObject
{
boolean isLocked();
void setLockCode(LockCode code);
void setLockCode(Passcode code);
LockCode getLockCode();
Passcode getLockCode();
}

View file

@ -1,51 +0,0 @@
package common.tileentity;
import common.entity.npc.EntityNPC;
import common.inventory.Container;
import common.inventory.InventoryPlayer;
public class LocalBlockIntercommunication implements IInteractionObject
{
private String guiID;
private String displayName;
public LocalBlockIntercommunication(String guiIdIn, String displayNameIn)
{
this.guiID = guiIdIn;
this.displayName = displayNameIn;
}
public Container createContainer(InventoryPlayer playerInventory, EntityNPC playerIn)
{
throw new UnsupportedOperationException();
}
/**
* Get the name of this object. For players this returns their username
*/
public String getName()
{
return this.displayName;
}
/**
* Returns true if this thing is named
*/
public boolean hasCustomName()
{
return true;
}
public String getGuiID()
{
return this.guiID;
}
/**
* Get the formatted ChatComponent that will be used for the sender's username in chat
*/
public String getCommandName()
{
return this.displayName;
}
}

View file

@ -1,42 +0,0 @@
package common.tileentity;
import common.tags.TagObject;
public class LockCode
{
public static final LockCode EMPTY_CODE = new LockCode("");
private final String lock;
public LockCode(String code)
{
this.lock = code;
}
public boolean isEmpty()
{
return this.lock == null || this.lock.isEmpty();
}
public String getLock()
{
return this.lock;
}
public void toNBT(TagObject nbt)
{
nbt.setString("Lock", this.lock);
}
public static LockCode fromNBT(TagObject nbt)
{
if (nbt.hasString("Lock"))
{
String s = nbt.getString("Lock");
return new LockCode(s);
}
else
{
return EMPTY_CODE;
}
}
}

View file

@ -0,0 +1,19 @@
package common.tileentity;
import common.tags.TagObject;
public record Passcode(String code) {
public static final Passcode EMPTY_CODE = new Passcode("");
public boolean empty() {
return this.code == null || this.code.isEmpty();
}
public void toNBT(TagObject tag) {
tag.setString("Lock", this.code);
}
public static Passcode fromNBT(TagObject tag) {
return tag.hasString("Lock") ? new Passcode(tag.getString("Lock")) : EMPTY_CODE;
}
}

View file

@ -4,12 +4,12 @@ import common.tags.TagObject;
public abstract class TileEntityLockable extends TileEntity implements IInteractionObject, ILockableContainer
{
private LockCode code = LockCode.EMPTY_CODE;
private Passcode code = Passcode.EMPTY_CODE;
public void readTags(TagObject compound)
{
super.readTags(compound);
this.code = LockCode.fromNBT(compound);
this.code = Passcode.fromNBT(compound);
}
public void writeTags(TagObject compound)
@ -24,15 +24,15 @@ public abstract class TileEntityLockable extends TileEntity implements IInteract
public boolean isLocked()
{
return this.code != null && !this.code.isEmpty();
return this.code != null && !this.code.empty();
}
public LockCode getLockCode()
public Passcode getLockCode()
{
return this.code;
}
public void setLockCode(LockCode code)
public void setLockCode(Passcode code)
{
this.code = code;
}

View file

@ -148,7 +148,7 @@ public class EncryptUtil {
return cn == null || cn.isEmpty() ? sb.toString() : sb.append(' ').append(Util.sanitizeCommonName(cn)).toString();
}
public static Tuple<PublicKey, String> parseArmoredPubkey(String armor) throws IllegalArgumentException {
public static Pair<PublicKey, String> parseArmoredPubkey(String armor) throws IllegalArgumentException {
String[] tok = armor.trim().split(" ");
if(tok.length != 3 && tok.length != 4)
throw new IllegalArgumentException("Key muss aus 3 oder 4 Segmenten bestehen");
@ -184,7 +184,7 @@ public class EncryptUtil {
}
if(tok.length == 4 && !Util.isValidCommonName(tok[3]))
throw new IllegalArgumentException("Name muss aus 'a-z' '0-9' und '-' bestehen, kann keine aufeinander folgenden Bindestriche haben und darf nicht damit beginnen oder darin enden");
return new Tuple<PublicKey, String>(pubkey, tok.length == 4 ? tok[3] : null);
return new Pair<PublicKey, String>(pubkey, tok.length == 4 ? tok[3] : null);
}
private static final long CRC24_INIT = 0xB704CEL;

View file

@ -0,0 +1,4 @@
package common.util;
public record Pair<A, B>(A first, B second) {
}

View file

@ -1,19 +1,4 @@
package common.util;
public class Position {
public final double x;
public final double y;
public final double z;
public final float yaw;
public final float pitch;
public final int dim;
public Position(double x, double y, double z, float yaw, float pitch, int dim) {
this.x = x;
this.y = y;
this.z = z;
this.yaw = yaw;
this.pitch = pitch;
this.dim = dim;
}
public record Position(double x, double y, double z, float yaw, float pitch, int dim) {
}

View file

@ -1,10 +1,4 @@
package common.util;
public class Triplet<S, T, U> extends Tuple<S, T> {
public final U third;
public Triplet(S first, T second, U third) {
super(first, second);
this.third = third;
}
public record Triplet<A, B, C>(A first, B second, C third) {
}

View file

@ -1,11 +0,0 @@
package common.util;
public class Tuple<S, T> {
public final S first;
public final T second;
public Tuple(S first, T second) {
this.first = first;
this.second = second;
}
}

View file

@ -338,14 +338,14 @@ int utf_len(const char *str) {
}
}
public static Tuple<String, String> getKeyValue(String text, char separator) {
public static Pair<String, String> getKeyValue(String text, char separator) {
int index = text.indexOf(separator);
if(index == -1)
return new Tuple<String, String>(text, null);
return new Tuple<String, String>(text.substring(0, index), text.substring(index + 1));
return new Pair<String, String>(text, null);
return new Pair<String, String>(text.substring(0, index), text.substring(index + 1));
}
public static Tuple<String, String> getKeyValue(String text) {
public static Pair<String, String> getKeyValue(String text) {
return getKeyValue(text, ' ');
}

View file

@ -252,7 +252,7 @@ public class Vector3f extends Vector implements Serializable {
/* (non-Javadoc)
* @see org.lwjgl.vector.Vector#load(FloatBuffer)
*/
public Vector load(FloatBuffer buf) {
public Vector3f load(FloatBuffer buf) {
x = buf.get();
y = buf.get();
z = buf.get();
@ -262,7 +262,7 @@ public class Vector3f extends Vector implements Serializable {
/* (non-Javadoc)
* @see org.lwjgl.vector.Vector#scale(float)
*/
public Vector scale(float scale) {
public Vector3f scale(float scale) {
x *= scale;
y *= scale;
@ -275,7 +275,7 @@ public class Vector3f extends Vector implements Serializable {
/* (non-Javadoc)
* @see org.lwjgl.vector.Vector#store(FloatBuffer)
*/
public Vector store(FloatBuffer buf) {
public Vector3f store(FloatBuffer buf) {
buf.put(x);
buf.put(y);

View file

@ -4,21 +4,9 @@ import common.item.Item;
import common.item.ItemStack;
import common.tags.TagObject;
public class MerchantRecipe {
private final ItemStack buying;
private final ItemStack buySecond;
private final ItemStack selling;
public record MerchantRecipe(ItemStack first, ItemStack second, ItemStack result) {
public MerchantRecipe(TagObject tag) {
this.buying = ItemStack.readFromTag(tag.getObject("buy"));
this.selling = ItemStack.readFromTag(tag.getObject("sell"));
this.buySecond = tag.hasObject("buyB") ? ItemStack.readFromTag(tag.getObject("buyB")) : null;
}
public MerchantRecipe(ItemStack buy1, ItemStack buy2, ItemStack sell) {
this.buying = buy1;
this.buySecond = buy2;
this.selling = sell;
this(ItemStack.readFromTag(tag.getObject("buy")), tag.hasObject("buyB") ? ItemStack.readFromTag(tag.getObject("buyB")) : null, ItemStack.readFromTag(tag.getObject("sell")));
}
public MerchantRecipe(ItemStack buy, ItemStack sell) {
@ -29,28 +17,16 @@ public class MerchantRecipe {
this(buy, new ItemStack(sell));
}
public ItemStack getBuying() {
return this.buying;
}
public ItemStack getSecondBuy() {
return this.buySecond;
}
public boolean hasSecondBuy() {
return this.buySecond != null;
}
public ItemStack getSelling() {
return this.selling;
public boolean both() {
return this.second != null;
}
public TagObject toTags() {
TagObject tag = new TagObject();
tag.setObject("buy", this.buying.writeTags(new TagObject()));
tag.setObject("sell", this.selling.writeTags(new TagObject()));
if(this.buySecond != null)
tag.setObject("buyB", this.buySecond.writeTags(new TagObject()));
tag.setObject("buy", this.first.writeTags(new TagObject()));
tag.setObject("sell", this.result.writeTags(new TagObject()));
if(this.second != null)
tag.setObject("buyB", this.second.writeTags(new TagObject()));
return tag;
}
}

View file

@ -11,19 +11,19 @@ public class MerchantRecipeList extends ArrayList<MerchantRecipe> {
public MerchantRecipe canUse(ItemStack stack1, ItemStack stack2, int index) {
if(index > 0 && index < this.size()) {
MerchantRecipe recipe = this.get(index);
return !areItemsSimilar(stack1, recipe.getBuying())
|| (stack2 != null || recipe.hasSecondBuy())
&& (!recipe.hasSecondBuy() || !areItemsSimilar(stack2, recipe.getSecondBuy()))
|| stack1.size < recipe.getBuying().size
|| recipe.hasSecondBuy() && stack2.size < recipe.getSecondBuy().size ? null : recipe;
return !areItemsSimilar(stack1, recipe.first())
|| (stack2 != null || recipe.both())
&& (!recipe.both() || !areItemsSimilar(stack2, recipe.second()))
|| stack1.size < recipe.first().size
|| recipe.both() && stack2.size < recipe.second().size ? null : recipe;
}
else {
for(int z = 0; z < this.size(); z++) {
MerchantRecipe recipe = this.get(z);
if(areItemsSimilar(stack1, recipe.getBuying()) && stack1.size >= recipe.getBuying().size
&& (!recipe.hasSecondBuy() && stack2 == null
|| recipe.hasSecondBuy() && areItemsSimilar(stack2, recipe.getSecondBuy())
&& stack2.size >= recipe.getSecondBuy().size)) {
if(areItemsSimilar(stack1, recipe.first()) && stack1.size >= recipe.first().size
&& (!recipe.both() && stack2 == null
|| recipe.both() && areItemsSimilar(stack2, recipe.second())
&& stack2.size >= recipe.second().size)) {
return recipe;
}
}