mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-12-30 20:39:21 +00:00
1.14+ support
This commit is contained in:
@@ -637,8 +637,6 @@ public class IrisDimension extends IrisRegistrant
|
||||
IrisLock t = new IrisLock("t");
|
||||
Iris.verbose("Checking sizes for " + Form.f(objects.size()) + " referenced objects.");
|
||||
|
||||
int tc = g.getThreads();
|
||||
g.changeThreadCount(64);
|
||||
for(String i : objects)
|
||||
{
|
||||
g.getAccelerant().queue("tx-psize", () ->
|
||||
@@ -661,7 +659,6 @@ public class IrisDimension extends IrisRegistrant
|
||||
}
|
||||
|
||||
g.getAccelerant().waitFor("tx-psize");
|
||||
g.changeThreadCount(tc);
|
||||
int x = Math.max(xg.get(), Math.max(yg.get(), zg.get()));
|
||||
int z = x;
|
||||
|
||||
|
||||
@@ -5,7 +5,6 @@ import java.lang.reflect.Field;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.util.Desc;
|
||||
import com.volmit.iris.util.DontObfuscate;
|
||||
import com.volmit.iris.util.MaxNumber;
|
||||
@@ -47,9 +46,17 @@ public class IrisEnchantment
|
||||
|
||||
public void apply(RNG rng, ItemMeta meta)
|
||||
{
|
||||
if(rng.nextDouble() < chance)
|
||||
try
|
||||
{
|
||||
meta.addEnchant(getEnchant(), getLevel(rng), true);
|
||||
if(rng.nextDouble() < chance)
|
||||
{
|
||||
meta.addEnchant(getEnchant(), getLevel(rng), true);
|
||||
}
|
||||
}
|
||||
|
||||
catch(Throwable e)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,8 +78,6 @@ public class IrisEnchantment
|
||||
}
|
||||
}
|
||||
|
||||
Iris.warn("Can't find enchantment type: " + getEnchantment());
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -244,7 +244,7 @@ public class IrisEntity extends IrisRegistrant
|
||||
}
|
||||
}
|
||||
|
||||
if(e instanceof Mob)
|
||||
if(Iris.awareEntities && e instanceof Mob)
|
||||
{
|
||||
Mob m = (Mob) e;
|
||||
m.setAware(isAware());
|
||||
|
||||
@@ -40,8 +40,8 @@ public class IrisEntitySpawn
|
||||
@Desc("The 1 in RARITY chance for this entity to spawn")
|
||||
private int rarity = 1;
|
||||
|
||||
private AtomicCache<RNG> rng = new AtomicCache<>();
|
||||
private AtomicCache<IrisEntity> ent = new AtomicCache<>();
|
||||
private transient AtomicCache<RNG> rng = new AtomicCache<>();
|
||||
private transient AtomicCache<IrisEntity> ent = new AtomicCache<>();
|
||||
|
||||
public Entity on(IrisChunkGenerator g, Location at, EntityType t, EntitySpawnEvent ee)
|
||||
{
|
||||
|
||||
@@ -69,7 +69,7 @@ public class IrisLoot
|
||||
private double maxDurability = 1;
|
||||
|
||||
@DontObfuscate
|
||||
@Desc("Define a custom model identifier")
|
||||
@Desc("Define a custom model identifier 1.14+ only")
|
||||
private Integer customModel = null;
|
||||
|
||||
@DontObfuscate
|
||||
@@ -123,98 +123,8 @@ public class IrisLoot
|
||||
|
||||
public ItemStack get(boolean debug, RNG rng)
|
||||
{
|
||||
ItemStack is = new ItemStack(getType(), Math.max(1, rng.i(getMinAmount(), getMaxAmount())));
|
||||
ItemMeta m = is.getItemMeta();
|
||||
|
||||
if(getType().getMaxDurability() > 0 && m instanceof Damageable)
|
||||
try
|
||||
{
|
||||
Damageable d = (Damageable) m;
|
||||
int max = getType().getMaxDurability();
|
||||
d.setDamage((int) Math.round(Math.max(0, Math.min(max, (1D - rng.d(getMinDurability(), getMaxDurability())) * max))));
|
||||
}
|
||||
|
||||
for(IrisEnchantment i : getEnchantments())
|
||||
{
|
||||
i.apply(rng, m);
|
||||
}
|
||||
|
||||
for(IrisAttributeModifier i : getAttributes())
|
||||
{
|
||||
i.apply(rng, m);
|
||||
}
|
||||
|
||||
m.setCustomModelData(getCustomModel());
|
||||
m.setLocalizedName(C.translateAlternateColorCodes('&', displayName));
|
||||
m.setDisplayName(C.translateAlternateColorCodes('&', displayName));
|
||||
m.setUnbreakable(isUnbreakable());
|
||||
|
||||
for(ItemFlag i : getItemFlags())
|
||||
{
|
||||
m.addItemFlags(i);
|
||||
}
|
||||
|
||||
KList<String> lore = new KList<>();
|
||||
|
||||
getLore().forEach((i) ->
|
||||
{
|
||||
String mf = C.translateAlternateColorCodes('&', i);
|
||||
|
||||
if(mf.length() > 24)
|
||||
{
|
||||
for(String g : Form.wrapWords(mf, 24).split("\\Q\n\\E"))
|
||||
{
|
||||
lore.add(g.trim());
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
lore.add(mf);
|
||||
}
|
||||
});
|
||||
|
||||
if(debug)
|
||||
{
|
||||
if(lore.isNotEmpty())
|
||||
{
|
||||
lore.add(C.GRAY + "--------------------");
|
||||
}
|
||||
|
||||
lore.add(C.GRAY + "1 in " + (getRarity()) + " Chance (" + Form.pc(1D / (getRarity()), 5) + ")");
|
||||
}
|
||||
|
||||
m.setLore(lore);
|
||||
|
||||
if(getLeatherColor() != null && m instanceof LeatherArmorMeta)
|
||||
{
|
||||
Color c = Color.decode(getLeatherColor());
|
||||
((LeatherArmorMeta) m).setColor(org.bukkit.Color.fromRGB(c.getRed(), c.getGreen(), c.getBlue()));
|
||||
}
|
||||
|
||||
if(getDyeColor() != null && m instanceof Colorable)
|
||||
{
|
||||
((Colorable) m).setColor(getDyeColor());
|
||||
}
|
||||
|
||||
is.setItemMeta(m);
|
||||
return is;
|
||||
}
|
||||
|
||||
public ItemStack get(boolean debug, IrisLootTable table, RNG rng, int x, int y, int z)
|
||||
{
|
||||
if(debug)
|
||||
{
|
||||
chance.reset();
|
||||
}
|
||||
|
||||
if(chance.aquire(() -> NoiseStyle.STATIC.create(rng)).fit(1, rarity * table.getRarity(), x, y, z) == 1)
|
||||
{
|
||||
if(getType() == null)
|
||||
{
|
||||
Iris.warn("Cant find item type " + type);
|
||||
return null;
|
||||
}
|
||||
|
||||
ItemStack is = new ItemStack(getType(), Math.max(1, rng.i(getMinAmount(), getMaxAmount())));
|
||||
ItemMeta m = is.getItemMeta();
|
||||
|
||||
@@ -235,7 +145,11 @@ public class IrisLoot
|
||||
i.apply(rng, m);
|
||||
}
|
||||
|
||||
m.setCustomModelData(getCustomModel());
|
||||
if(Iris.customModels)
|
||||
{
|
||||
m.setCustomModelData(getCustomModel());
|
||||
}
|
||||
|
||||
m.setLocalizedName(C.translateAlternateColorCodes('&', displayName));
|
||||
m.setDisplayName(C.translateAlternateColorCodes('&', displayName));
|
||||
m.setUnbreakable(isUnbreakable());
|
||||
@@ -272,15 +186,127 @@ public class IrisLoot
|
||||
lore.add(C.GRAY + "--------------------");
|
||||
}
|
||||
|
||||
lore.add(C.GRAY + "From: " + table.getName() + " (" + Form.pc(1D / table.getRarity(), 5) + ")");
|
||||
lore.add(C.GRAY + "1 in " + (table.getRarity() * getRarity()) + " Chance (" + Form.pc(1D / (table.getRarity() * getRarity()), 5) + ")");
|
||||
lore.add(C.GRAY + "1 in " + (getRarity()) + " Chance (" + Form.pc(1D / (getRarity()), 5) + ")");
|
||||
}
|
||||
|
||||
m.setLore(lore);
|
||||
|
||||
if(getLeatherColor() != null && m instanceof LeatherArmorMeta)
|
||||
{
|
||||
Color c = Color.decode(getLeatherColor());
|
||||
((LeatherArmorMeta) m).setColor(org.bukkit.Color.fromRGB(c.getRed(), c.getGreen(), c.getBlue()));
|
||||
}
|
||||
|
||||
if(getDyeColor() != null && m instanceof Colorable)
|
||||
{
|
||||
((Colorable) m).setColor(getDyeColor());
|
||||
}
|
||||
|
||||
is.setItemMeta(m);
|
||||
return is;
|
||||
}
|
||||
|
||||
catch(Throwable e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
return new ItemStack(Material.AIR);
|
||||
}
|
||||
|
||||
public ItemStack get(boolean debug, IrisLootTable table, RNG rng, int x, int y, int z)
|
||||
{
|
||||
if(debug)
|
||||
{
|
||||
chance.reset();
|
||||
}
|
||||
|
||||
if(chance.aquire(() -> NoiseStyle.STATIC.create(rng)).fit(1, rarity * table.getRarity(), x, y, z) == 1)
|
||||
{
|
||||
if(getType() == null)
|
||||
{
|
||||
Iris.warn("Cant find item type " + type);
|
||||
return null;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
ItemStack is = new ItemStack(getType(), Math.max(1, rng.i(getMinAmount(), getMaxAmount())));
|
||||
ItemMeta m = is.getItemMeta();
|
||||
|
||||
if(getType().getMaxDurability() > 0 && m instanceof Damageable)
|
||||
{
|
||||
Damageable d = (Damageable) m;
|
||||
int max = getType().getMaxDurability();
|
||||
d.setDamage((int) Math.round(Math.max(0, Math.min(max, (1D - rng.d(getMinDurability(), getMaxDurability())) * max))));
|
||||
}
|
||||
|
||||
for(IrisEnchantment i : getEnchantments())
|
||||
{
|
||||
i.apply(rng, m);
|
||||
}
|
||||
|
||||
for(IrisAttributeModifier i : getAttributes())
|
||||
{
|
||||
i.apply(rng, m);
|
||||
}
|
||||
|
||||
if(Iris.customModels)
|
||||
{
|
||||
m.setCustomModelData(getCustomModel());
|
||||
}
|
||||
|
||||
m.setLocalizedName(C.translateAlternateColorCodes('&', displayName));
|
||||
m.setDisplayName(C.translateAlternateColorCodes('&', displayName));
|
||||
m.setUnbreakable(isUnbreakable());
|
||||
|
||||
for(ItemFlag i : getItemFlags())
|
||||
{
|
||||
m.addItemFlags(i);
|
||||
}
|
||||
|
||||
KList<String> lore = new KList<>();
|
||||
|
||||
getLore().forEach((i) ->
|
||||
{
|
||||
String mf = C.translateAlternateColorCodes('&', i);
|
||||
|
||||
if(mf.length() > 24)
|
||||
{
|
||||
for(String g : Form.wrapWords(mf, 24).split("\\Q\n\\E"))
|
||||
{
|
||||
lore.add(g.trim());
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
lore.add(mf);
|
||||
}
|
||||
});
|
||||
|
||||
if(debug)
|
||||
{
|
||||
if(lore.isNotEmpty())
|
||||
{
|
||||
lore.add(C.GRAY + "--------------------");
|
||||
}
|
||||
|
||||
lore.add(C.GRAY + "From: " + table.getName() + " (" + Form.pc(1D / table.getRarity(), 5) + ")");
|
||||
lore.add(C.GRAY + "1 in " + (table.getRarity() * getRarity()) + " Chance (" + Form.pc(1D / (table.getRarity() * getRarity()), 5) + ")");
|
||||
}
|
||||
|
||||
m.setLore(lore);
|
||||
is.setItemMeta(m);
|
||||
return is;
|
||||
}
|
||||
|
||||
catch(Throwable e)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user