fixes
This commit is contained in:
parent
936154e5ce
commit
d404c1743a
16 changed files with 331 additions and 892 deletions
|
@ -649,6 +649,7 @@ public class Client implements IThreadListener {
|
|||
|
||||
public void refreshResources()
|
||||
{
|
||||
this.logFeed("Lade Texturen neu");
|
||||
Font.unload();
|
||||
Font.load(this.font);
|
||||
this.textureManager.onReload();
|
||||
|
@ -659,6 +660,7 @@ public class Client implements IThreadListener {
|
|||
this.renderGlobal.onReload();
|
||||
EntityTexManager.loadNpcTextures();
|
||||
this.renderGlobal.loadRenderers();
|
||||
this.logFeed("Texturen wurden neu geladen");
|
||||
}
|
||||
|
||||
public void init()
|
||||
|
@ -1406,6 +1408,8 @@ public class Client implements IThreadListener {
|
|||
{
|
||||
this.player.swingItem();
|
||||
this.player.client.addToSendQueue(new CPacketAction(Action.ITEM_ACTION, ItemControl.PRIMARY.ordinal()));
|
||||
if(this.player.getHeldItem() != null && this.player.getHeldItem().isEmpty())
|
||||
this.player.inventory.mainInventory[this.player.inventory.currentItem] = null;
|
||||
this.leftClickCounter = 10;
|
||||
return;
|
||||
}
|
||||
|
@ -1458,6 +1462,8 @@ public class Client implements IThreadListener {
|
|||
{
|
||||
this.player.swingItem();
|
||||
this.player.client.addToSendQueue(new CPacketAction(Action.ITEM_ACTION, ItemControl.SECONDARY.ordinal()));
|
||||
if(this.player.getHeldItem() != null && this.player.getHeldItem().isEmpty())
|
||||
this.player.inventory.mainInventory[this.player.inventory.currentItem] = null;
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1524,6 +1530,8 @@ public class Client implements IThreadListener {
|
|||
{
|
||||
if(this.player.getHeldItem() != null && this.player.getHeldItem().getItem().onAction(this.player.getHeldItem(), this.player, this.world, ItemControl.TERTIARY, null)) {
|
||||
this.player.client.addToSendQueue(new CPacketAction(Action.ITEM_ACTION, ItemControl.TERTIARY.ordinal()));
|
||||
if(this.player.getHeldItem() != null && this.player.getHeldItem().isEmpty())
|
||||
this.player.inventory.mainInventory[this.player.inventory.currentItem] = null;
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1576,6 +1584,8 @@ public class Client implements IThreadListener {
|
|||
{
|
||||
if(this.player.getHeldItem() != null && this.player.getHeldItem().getItem().onAction(this.player.getHeldItem(), this.player, this.world, ItemControl.QUARTERNARY, null)) {
|
||||
this.player.client.addToSendQueue(new CPacketAction(Action.ITEM_ACTION, ItemControl.QUARTERNARY.ordinal()));
|
||||
if(this.player.getHeldItem() != null && this.player.getHeldItem().isEmpty())
|
||||
this.player.inventory.mainInventory[this.player.inventory.currentItem] = null;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -1700,6 +1710,11 @@ public class Client implements IThreadListener {
|
|||
if(this.player != null)
|
||||
this.player.client.addToSendQueue(new CPacketAction(action));
|
||||
}
|
||||
|
||||
public void performAction(Action action, int data) {
|
||||
if(this.player != null)
|
||||
this.player.client.addToSendQueue(new CPacketAction(action, data));
|
||||
}
|
||||
|
||||
public void setBossStatus(EntityLiving entity) {
|
||||
if(this.bars.size() < 5 || this.bars.containsKey(entity.getId()))
|
||||
|
@ -2542,12 +2557,12 @@ public class Client implements IThreadListener {
|
|||
}
|
||||
|
||||
public void restartSound(boolean load) {
|
||||
Client.this.logFeed("Lade Sound-System neu");
|
||||
Client.this.logFeed("Lade Sound-System " + (load ? "und alle Sounds " : "") + "neu");
|
||||
this.soundManager.unload();
|
||||
if(audio.end())
|
||||
Log.SOUND.info("Audiogerät geschlossen");
|
||||
this.startSound(load);
|
||||
Client.this.logFeed("Das Sound-System wurde neu geladen");
|
||||
Client.this.logFeed("Das Sound-System " + (load ? "und alle Sounds wurden" : "wurde") + " neu geladen");
|
||||
}
|
||||
|
||||
public AudioInterface getAudioInterface() {
|
||||
|
@ -2592,9 +2607,9 @@ public class Client implements IThreadListener {
|
|||
Client.this.performAction(Action.SPEED);
|
||||
}
|
||||
});
|
||||
this.registerDebug(Keysym.R, "Gegenstand reparieren und Stapel auffüllen", new DebugRunner() {
|
||||
this.registerDebug(Keysym.R, "Gegenstand in Hand / Alle (+Shift) reparieren und auffüllen", new DebugRunner() {
|
||||
public void execute(Keysym key) {
|
||||
Client.this.performAction(Action.REPAIR);
|
||||
Client.this.performAction(Action.REPAIR, Client.this.shift() ? 1 : 0);
|
||||
}
|
||||
});
|
||||
this.registerDebug(Keysym.E, "Gegenstands-Cheat-Menü umschalten", new DebugRunner() {
|
||||
|
@ -2662,16 +2677,12 @@ public class Client implements IThreadListener {
|
|||
});
|
||||
this.registerDebug(Keysym.T, "Alle Texturen neu laden", new DebugRunner() {
|
||||
public void execute(Keysym key) {
|
||||
Client.this.logFeed("Lade Texturen neu");
|
||||
Client.this.refreshResources();
|
||||
Client.this.logFeed("Texturen wurden neu geladen");
|
||||
}
|
||||
});
|
||||
this.registerDebug(Keysym.S, "Alle Sounds neu laden", new DebugRunner() {
|
||||
this.registerDebug(Keysym.S, "Sound neu starten / Alle Sounds neu laden (+Shift)", new DebugRunner() {
|
||||
public void execute(Keysym key) {
|
||||
Client.this.logFeed("Lade Sounds neu");
|
||||
Client.this.restartSound(true);
|
||||
Client.this.logFeed("Sounds wurden neu geladen");
|
||||
Client.this.restartSound(Client.this.shift());
|
||||
}
|
||||
});
|
||||
if(Util.DEVMODE)
|
||||
|
|
|
@ -956,7 +956,7 @@ public class EffectRenderer {
|
|||
this.register(ParticleType.CRIT, (x, y, z, xSpeed, ySpeed, zSpeed, data) -> new Crit(x, y, z, xSpeed, ySpeed, zSpeed));
|
||||
this.register(ParticleType.SMOKE, (x, y, z, xSpeed, ySpeed, zSpeed, data) -> new Smoke(x, y, z, xSpeed, ySpeed, zSpeed));
|
||||
this.register(ParticleType.POTION, (x, y, z, xSpeed, ySpeed, zSpeed, data) -> new Spell(x, y, z, xSpeed, ySpeed, zSpeed,
|
||||
(data & 16383) != 0 ? ItemPotion.getPotionItem(data).getColorFromDamage() : 0xffffffff));
|
||||
ItemPotion.getPotionItem(data).getColorFromDamage()));
|
||||
this.register(ParticleType.GROW, (x, y, z, xSpeed, ySpeed, zSpeed, data) -> new Aura(x, y, z, xSpeed, ySpeed, zSpeed, false, 1));
|
||||
this.register(ParticleType.SPORE, (x, y, z, xSpeed, ySpeed, zSpeed, data) -> new Aura(x, y, z, xSpeed, ySpeed, zSpeed, false, 0));
|
||||
this.register(ParticleType.TELEPORT, (x, y, z, xSpeed, ySpeed, zSpeed, data) -> new Teleport(x, y, z, xSpeed, ySpeed, zSpeed));
|
||||
|
@ -1068,16 +1068,13 @@ public class EffectRenderer {
|
|||
this.layers[i].add(effect);
|
||||
}
|
||||
|
||||
public Effect spawnParticle(ParticleType type, double x, double y, double z, double xSpeed, double ySpeed, double zSpeed, int data) {
|
||||
public void spawnParticle(ParticleType type, double x, double y, double z, double xSpeed, double ySpeed, double zSpeed, int data) {
|
||||
Creator creator = this.types.get(type);
|
||||
if(creator != null) {
|
||||
Effect effect = creator.create(x, y, z, xSpeed, ySpeed, zSpeed, data);
|
||||
if(effect != null) {
|
||||
if(effect != null)
|
||||
this.add(effect);
|
||||
return effect;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void destroyBlock(BlockPos pos, State state) {
|
||||
|
|
|
@ -3,7 +3,6 @@ package client.renderer.entity;
|
|||
import common.entity.projectile.EntityPotion;
|
||||
import common.init.Items;
|
||||
import common.item.ItemStack;
|
||||
import common.item.tool.ItemPotion;
|
||||
|
||||
public class RenderPotion extends RenderItemEntity<EntityPotion>
|
||||
{
|
||||
|
@ -14,6 +13,6 @@ public class RenderPotion extends RenderItemEntity<EntityPotion>
|
|||
|
||||
public ItemStack getStack(EntityPotion entityIn)
|
||||
{
|
||||
return new ItemStack(ItemPotion.getPotionItem(entityIn.getPotionDamage()));
|
||||
return new ItemStack(entityIn.getPotionDamage());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -84,6 +84,8 @@ public class PlayerController {
|
|||
if(stack != null && stack.getItem().onAction(stack, this.gm.player, this.gm.world, ItemControl.PRIMARY, pos)) {
|
||||
this.interacting = true;
|
||||
this.handler.addToSendQueue(new CPacketBreak(CPacketBreak.Action.START_DESTROY_BLOCK, pos, face));
|
||||
if(this.gm.player.getHeldItem() != null && this.gm.player.getHeldItem().isEmpty())
|
||||
this.gm.player.inventory.mainInventory[this.gm.player.inventory.currentItem] = null;
|
||||
return true;
|
||||
}
|
||||
if(!this.hitting || !this.isHitting(pos)) {
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
package common.entity.npc;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import common.entity.effect.EntityLightning;
|
||||
import common.entity.types.EntityLiving;
|
||||
import common.init.Items;
|
||||
|
@ -10,6 +8,7 @@ import common.item.tool.ItemPotion;
|
|||
import common.potion.Potion;
|
||||
import common.potion.PotionEffect;
|
||||
import common.rng.Random;
|
||||
import common.util.ExtMath;
|
||||
import common.world.World;
|
||||
|
||||
public class EntityMage extends EntityNPC
|
||||
|
@ -40,17 +39,13 @@ public class EntityMage extends EntityNPC
|
|||
|
||||
if (itemstack != null && itemstack.getItem() instanceof ItemPotion potion)
|
||||
{
|
||||
List<PotionEffect> list = potion.getEffects();
|
||||
|
||||
if (list != null)
|
||||
PotionEffect potioneffect = potion.getEffect();
|
||||
if (potioneffect != null)
|
||||
{
|
||||
for (PotionEffect potioneffect : list)
|
||||
{
|
||||
if(potioneffect.getPotion().isInstant())
|
||||
potioneffect.getPotion().onImpact(null, null, this, potioneffect.getAmplifier(), 1.0);
|
||||
else
|
||||
this.addEffect(new PotionEffect(potioneffect));
|
||||
}
|
||||
if(potioneffect.getPotion().isInstant())
|
||||
potioneffect.getPotion().onImpact(null, null, this, potioneffect.getAmplifier(), 1.0);
|
||||
else
|
||||
this.addEffect(new PotionEffect(potioneffect.getPotion(), potioneffect.getDuration(), potioneffect.getAmplifier()));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -59,7 +54,7 @@ public class EntityMage extends EntityNPC
|
|||
}
|
||||
else
|
||||
{
|
||||
int i = -1;
|
||||
ItemPotion i = null;
|
||||
|
||||
// if (this.rand.floatv() < 0.15F && this.isInsideOfLiquid() && !this.hasEffect(Potion.waterBreathing))
|
||||
// {
|
||||
|
@ -68,31 +63,60 @@ public class EntityMage extends EntityNPC
|
|||
// else
|
||||
if (this.rand.floatv() < 0.15F && this.isBurning() && !this.hasEffect(Potion.FIRE_RESISTANCE))
|
||||
{
|
||||
i = 16307;
|
||||
i = Items.potion_fire_resistance;
|
||||
}
|
||||
else if (this.rand.floatv() < 0.05F && this.getHealth() < this.getMaxHealth())
|
||||
{
|
||||
i = 16341;
|
||||
i = Items.potion_health;
|
||||
}
|
||||
else if (this.rand.floatv() < 0.25F && this.getAttackTarget() != null && !this.hasEffect(Potion.SPEED) && this.getAttackTarget().getDistanceSqToEntity(this) > 121.0D)
|
||||
{
|
||||
i = 16274;
|
||||
i = Items.potion_speed;
|
||||
}
|
||||
else if (this.rand.floatv() < 0.25F && this.getAttackTarget() != null && !this.hasEffect(Potion.SPEED) && this.getAttackTarget().getDistanceSqToEntity(this) > 121.0D)
|
||||
{
|
||||
i = 16274;
|
||||
i = Items.potion_speed;
|
||||
}
|
||||
|
||||
if (i > -1)
|
||||
if (i != null)
|
||||
{
|
||||
this.setItem(0, new ItemStack(ItemPotion.getPotionItem(i)));
|
||||
this.setItem(0, new ItemStack(i));
|
||||
this.attackTimer = this.getHeldItem().getMaxItemUseDuration();
|
||||
this.drinking = true;
|
||||
this.setSpeedMod(0.165f);
|
||||
}
|
||||
else if(this.rand.chance(80)) {
|
||||
boolean far = this.getAttackTarget() != null && this.getAttackTarget().getDistanceSqToEntity(this) >= 256.0;
|
||||
this.setItem(0, far || this.rand.chance() ? new ItemStack(Items.splash_potion) : null);
|
||||
if(far || this.rand.chance()) {
|
||||
EntityLiving target = this.getAttackTarget();
|
||||
if(target == null) {
|
||||
this.setItem(0, new ItemStack(Items.potion_poison));
|
||||
}
|
||||
else {
|
||||
double d1 = target.posX + target.motionX - this.posX;
|
||||
double d3 = target.posZ + target.motionZ - this.posZ;
|
||||
float f = ExtMath.sqrtd(d1 * d1 + d3 * d3);
|
||||
if (f >= 8.0F && !target.hasEffect(Potion.SLOWNESS))
|
||||
{
|
||||
this.setItem(0, new ItemStack(Items.potion_slowness));
|
||||
}
|
||||
else if (target.getHealth() >= 8 && !target.hasEffect(Potion.POISON))
|
||||
{
|
||||
this.setItem(0, new ItemStack(Items.potion_poison));
|
||||
}
|
||||
else if (f <= 3.0F && !target.hasEffect(Potion.WEAKNESS) && this.rand.floatv() < 0.25F)
|
||||
{
|
||||
this.setItem(0, new ItemStack(Items.potion_weakness));
|
||||
}
|
||||
else
|
||||
{
|
||||
this.setItem(0, new ItemStack(Items.potion_damage));
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
this.setItem(0, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -64,6 +64,7 @@ import common.item.tool.ItemArmor;
|
|||
import common.item.tool.ItemBow;
|
||||
import common.item.tool.ItemGunBase;
|
||||
import common.item.tool.ItemHoe;
|
||||
import common.item.tool.ItemPotion;
|
||||
import common.item.tool.ItemShears;
|
||||
import common.item.tool.ItemSword;
|
||||
import common.item.tool.ItemTool;
|
||||
|
@ -450,7 +451,7 @@ public abstract class EntityNPC extends EntityLiving
|
|||
|
||||
public boolean isRangedWeapon(ItemStack stack) {
|
||||
return stack != null && (stack.getItem() == Items.bow || stack.getItem() instanceof ItemGunBase ||
|
||||
stack.getItem() == Items.snowball || stack.getItem() == Items.potion);
|
||||
stack.getItem() == Items.snowball || (stack.getItem() instanceof ItemPotion potion));
|
||||
}
|
||||
|
||||
// public boolean isSneaking()
|
||||
|
@ -763,28 +764,14 @@ public abstract class EntityNPC extends EntityLiving
|
|||
this.playSound(SoundEvent.THROW, 1.0F);
|
||||
this.worldObj.spawnEntityInWorld(entitysnowball);
|
||||
}
|
||||
else if(stack.getItem() == Items.potion) {
|
||||
EntityPotion entitypotion = new EntityPotion(this.worldObj, this, 32732);
|
||||
else if(stack.getItem() instanceof ItemPotion potion) {
|
||||
EntityPotion entitypotion = new EntityPotion(this.worldObj, this, potion);
|
||||
double d0 = target.posY + (double)target.getEyeHeight() - 1.100000023841858D;
|
||||
entitypotion.rotPitch -= -20.0F;
|
||||
double d1 = target.posX + target.motionX - this.posX;
|
||||
double d2 = d0 - this.posY;
|
||||
double d3 = target.posZ + target.motionZ - this.posZ;
|
||||
float f = ExtMath.sqrtd(d1 * d1 + d3 * d3);
|
||||
|
||||
if (f >= 8.0F && !target.hasEffect(Potion.SLOWNESS))
|
||||
{
|
||||
entitypotion.setPotionDamage(32698);
|
||||
}
|
||||
else if (target.getHealth() >= 8 && !target.hasEffect(Potion.POISON))
|
||||
{
|
||||
entitypotion.setPotionDamage(32660);
|
||||
}
|
||||
else if (f <= 3.0F && !target.hasEffect(Potion.WEAKNESS) && this.rand.floatv() < 0.25F)
|
||||
{
|
||||
entitypotion.setPotionDamage(32696);
|
||||
}
|
||||
|
||||
entitypotion.setThrowableHeading(d1, d2 + (double)(f * 0.2F), d3, 1.5F, 0.5F);
|
||||
this.worldObj.spawnEntityInWorld(entitypotion);
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ import java.util.List;
|
|||
import common.entity.types.EntityLiving;
|
||||
import common.entity.types.EntityThrowable;
|
||||
import common.entity.types.IObjectData;
|
||||
import common.init.ItemRegistry;
|
||||
import common.init.Items;
|
||||
import common.item.ItemStack;
|
||||
import common.item.tool.ItemPotion;
|
||||
|
@ -25,9 +26,9 @@ public class EntityPotion extends EntityThrowable implements IObjectData
|
|||
super(worldIn);
|
||||
}
|
||||
|
||||
public EntityPotion(World worldIn, EntityLiving throwerIn, int meta)
|
||||
public EntityPotion(World worldIn, EntityLiving throwerIn, ItemPotion meta)
|
||||
{
|
||||
this(worldIn, throwerIn, new ItemStack(ItemPotion.getPotionItem(meta)));
|
||||
this(worldIn, throwerIn, new ItemStack(meta));
|
||||
}
|
||||
|
||||
public EntityPotion(World worldIn, EntityLiving throwerIn, ItemStack potionDamageIn)
|
||||
|
@ -68,22 +69,22 @@ public class EntityPotion extends EntityThrowable implements IObjectData
|
|||
/**
|
||||
* Sets the PotionEffect by the given id of the potion effect.
|
||||
*/
|
||||
public void setPotionDamage(int potionId)
|
||||
public void setPotionDamage(ItemPotion potionId)
|
||||
{
|
||||
this.potionDamage = new ItemStack(ItemPotion.getPotionItem(potionId));
|
||||
this.potionDamage = new ItemStack(potionId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the damage value of the thrown potion that this EntityPotion represents.
|
||||
*/
|
||||
public int getPotionDamage()
|
||||
public ItemPotion getPotionDamage()
|
||||
{
|
||||
if (this.potionDamage == null)
|
||||
{
|
||||
this.potionDamage = new ItemStack(Items.potion);
|
||||
}
|
||||
|
||||
return this.potionDamage.getItem() instanceof ItemPotion potion ? potion.getPotionData() : 0;
|
||||
return this.potionDamage.getItem() instanceof ItemPotion potion ? potion : Items.potion;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -93,7 +94,7 @@ public class EntityPotion extends EntityThrowable implements IObjectData
|
|||
{
|
||||
if (!this.worldObj.client)
|
||||
{
|
||||
List<PotionEffect> list = this.potionDamage != null && this.potionDamage.getItem() instanceof ItemPotion potion ? potion.getEffects() : null;
|
||||
PotionEffect potioneffect = this.potionDamage != null && this.potionDamage.getItem() instanceof ItemPotion potion ? potion.getEffect() : null;
|
||||
|
||||
BoundingBox axisalignedbb = this.getEntityBoundingBox().expand(4.0D, 2.0D, 4.0D);
|
||||
List<EntityLiving> list1 = this.worldObj.<EntityLiving>getEntitiesWithinAABB(EntityLiving.class, axisalignedbb);
|
||||
|
@ -106,7 +107,7 @@ public class EntityPotion extends EntityThrowable implements IObjectData
|
|||
|
||||
if (d0 < 16.0D)
|
||||
{
|
||||
if (list != null && !list.isEmpty())
|
||||
if (potioneffect != null)
|
||||
{
|
||||
double d1 = 1.0D - Math.sqrt(d0) / 4.0D;
|
||||
|
||||
|
@ -115,24 +116,21 @@ public class EntityPotion extends EntityThrowable implements IObjectData
|
|||
d1 = 1.0D;
|
||||
}
|
||||
|
||||
for (PotionEffect potioneffect : list)
|
||||
Potion i = potioneffect.getPotion();
|
||||
if(!entitylivingbase.isPotionApplicable(i, potioneffect.getAmplifier()))
|
||||
continue;
|
||||
|
||||
if (i.isInstant())
|
||||
{
|
||||
Potion i = potioneffect.getPotion();
|
||||
if(!entitylivingbase.isPotionApplicable(i, potioneffect.getAmplifier()))
|
||||
continue;
|
||||
i.onImpact(this, this.getThrower(), entitylivingbase, potioneffect.getAmplifier(), d1);
|
||||
}
|
||||
else
|
||||
{
|
||||
int j = (int)(d1 * (double)((potioneffect.getDuration() * 3) / 4) + 0.5D);
|
||||
|
||||
if (i.isInstant())
|
||||
if (j > 20)
|
||||
{
|
||||
i.onImpact(this, this.getThrower(), entitylivingbase, potioneffect.getAmplifier(), d1);
|
||||
}
|
||||
else
|
||||
{
|
||||
int j = (int)(d1 * (double)potioneffect.getDuration() + 0.5D);
|
||||
|
||||
if (j > 20)
|
||||
{
|
||||
entitylivingbase.addEffect(new PotionEffect(i, j, potioneffect.getAmplifier()));
|
||||
}
|
||||
entitylivingbase.addEffect(new PotionEffect(i, j, potioneffect.getAmplifier()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -143,7 +141,7 @@ public class EntityPotion extends EntityThrowable implements IObjectData
|
|||
}
|
||||
}
|
||||
|
||||
this.worldObj.playAuxSFX(2002, new BlockPos(this), this.getPotionDamage());
|
||||
this.worldObj.playAuxSFX(2002, new BlockPos(this), ItemRegistry.getId(this.getPotionDamage()));
|
||||
this.setDead();
|
||||
}
|
||||
}
|
||||
|
@ -158,7 +156,7 @@ public class EntityPotion extends EntityThrowable implements IObjectData
|
|||
}
|
||||
else
|
||||
{
|
||||
this.setPotionDamage(tagCompund.getInt("potionValue"));
|
||||
this.potionDamage = null;
|
||||
}
|
||||
|
||||
if (this.potionDamage == null || !(this.potionDamage.getItem() instanceof ItemPotion))
|
||||
|
@ -178,7 +176,7 @@ public class EntityPotion extends EntityThrowable implements IObjectData
|
|||
}
|
||||
|
||||
public int getPacketData() {
|
||||
return this.getPotionDamage();
|
||||
return ItemRegistry.getId(this.getPotionDamage());
|
||||
}
|
||||
|
||||
// public boolean hasSpawnVelocity() {
|
||||
|
|
|
@ -343,8 +343,6 @@ public abstract class CraftingRegistry
|
|||
add(new ItemStack(Items.chick_magnet, 1), "A A", "N N", " C ", 'A', Items.aluminium_ingot, 'N', Items.nickel_ingot, 'C', Items.cobalt_ingot);
|
||||
add(new ItemStack(Items.magnet, 1), "I I", "N N", " R ", 'I', Items.iron_ingot, 'N', Items.neodymium_ingot, 'R', Items.redstone);
|
||||
|
||||
addShapeless(new ItemStack(Items.splash_potion), Items.potion, Items.gunpowder);
|
||||
|
||||
add(new ItemStack(Items.construction_table), "---", "-#-", "---", '#', Items.workbench, '-', Items.iron_ingot);
|
||||
add(new ItemStack(Items.bedrock), "#####", "#####", "#####", "#####", "#####", '#', Items.obsidian);
|
||||
|
||||
|
|
|
@ -88,6 +88,7 @@ import common.item.tool.ItemSword;
|
|||
import common.item.tool.ItemWeatherToken;
|
||||
import common.log.Log;
|
||||
import common.potion.Potion;
|
||||
import common.potion.PotionEffect;
|
||||
import common.potion.PotionHelper;
|
||||
import common.util.Pair;
|
||||
import common.util.Util;
|
||||
|
@ -288,11 +289,13 @@ public abstract class ItemRegistry {
|
|||
register("blaze_rod", (new ItemRod()).setDisplay("Lohenrute").setTab(CheatTab.MATERIALS).setMaxAmount(StackSize.XL));
|
||||
register("tear", (new ItemTiny()).setDisplay("Träne").setPotionEffect(PotionHelper.tearEffect).setTab(CheatTab.MATERIALS).setMaxAmount(StackSize.XL));
|
||||
register("gold_nugget", (new ItemNugget()).setDisplay("Goldnugget").setTab(CheatTab.METALS).setMaxAmount(StackSize.XL));
|
||||
for(int data : ItemPotion.getValidDataValues()) {
|
||||
ItemPotion potion = new ItemPotion(data);
|
||||
register(ItemPotion.getPotionName(potion), potion);
|
||||
}
|
||||
register("glass_bottle", (new ItemGlassBottle()).setDisplay("Glasflasche"));
|
||||
for(Pair<String, Potion> pot : ItemPotion.getBasePotions()) {
|
||||
register(pot.first(), new ItemPotion(pot.second(), null));
|
||||
}
|
||||
for(Pair<String, PotionEffect> pot : ItemPotion.getBrewedPotions()) {
|
||||
register(pot.first(), new ItemPotion(pot.second().getPotion(), pot.second()));
|
||||
}
|
||||
register("spider_eye", (new ItemFood(2, false)).setPotionEffect(Potion.POISON, 5, 0, 1.0F).setDisplay("Spinnenauge")
|
||||
.setPotionEffect(PotionHelper.spiderEyeEffect).setMaxAmount(StackSize.L));
|
||||
register("fermented_spider_eye", (new Item()).setDisplay("Fermentiertes Spinnenauge")
|
||||
|
|
|
@ -635,33 +635,6 @@ public abstract class Items {
|
|||
public static final ItemMetalBlock potassium_ore = get("potassium_ore");
|
||||
public static final ItemMetal potassium_powder = get("potassium_powder");
|
||||
public static final ItemSeedFood potato = get("potato");
|
||||
public static final ItemPotion potion = get("potion");
|
||||
public static final ItemPotion potion_damage = get("potion_damage");
|
||||
public static final ItemPotion potion_damage_2 = get("potion_damage_2");
|
||||
public static final ItemPotion potion_fire_resistance_3600 = get("potion_fire_resistance_3600");
|
||||
public static final ItemPotion potion_fire_resistance_9600 = get("potion_fire_resistance_9600");
|
||||
public static final ItemPotion potion_health = get("potion_health");
|
||||
public static final ItemPotion potion_health_2 = get("potion_health_2");
|
||||
public static final ItemPotion potion_night_vision_3600 = get("potion_night_vision_3600");
|
||||
public static final ItemPotion potion_night_vision_9600 = get("potion_night_vision_9600");
|
||||
public static final ItemPotion potion_poison_2400 = get("potion_poison_2400");
|
||||
public static final ItemPotion potion_poison_2_450 = get("potion_poison_2_450");
|
||||
public static final ItemPotion potion_poison_900 = get("potion_poison_900");
|
||||
public static final ItemPotion potion_regeneration_2400 = get("potion_regeneration_2400");
|
||||
public static final ItemPotion potion_regeneration_2_450 = get("potion_regeneration_2_450");
|
||||
public static final ItemPotion potion_regeneration_900 = get("potion_regeneration_900");
|
||||
public static final ItemPotion potion_slowness_1800 = get("potion_slowness_1800");
|
||||
public static final ItemPotion potion_slowness_4800 = get("potion_slowness_4800");
|
||||
public static final ItemPotion potion_speed_2_1800 = get("potion_speed_2_1800");
|
||||
public static final ItemPotion potion_speed_3600 = get("potion_speed_3600");
|
||||
public static final ItemPotion potion_speed_9600 = get("potion_speed_9600");
|
||||
public static final ItemPotion potion_stability_3600 = get("potion_stability_3600");
|
||||
public static final ItemPotion potion_stability_9600 = get("potion_stability_9600");
|
||||
public static final ItemPotion potion_strength_2_1800 = get("potion_strength_2_1800");
|
||||
public static final ItemPotion potion_strength_3600 = get("potion_strength_3600");
|
||||
public static final ItemPotion potion_strength_9600 = get("potion_strength_9600");
|
||||
public static final ItemPotion potion_weakness_1800 = get("potion_weakness_1800");
|
||||
public static final ItemPotion potion_weakness_4800 = get("potion_weakness_4800");
|
||||
public static final ItemMetalBlock praseodymium_block = get("praseodymium_block");
|
||||
public static final ItemMetal praseodymium_ingot = get("praseodymium_ingot");
|
||||
public static final ItemMetalBlock praseodymium_ore = get("praseodymium_ore");
|
||||
|
@ -775,33 +748,6 @@ public abstract class Items {
|
|||
public static final ItemSeeds soul_wart = get("soul_wart");
|
||||
public static final Item speckled_melon = get("speckled_melon");
|
||||
public static final ItemFood spider_eye = get("spider_eye");
|
||||
public static final ItemPotion splash_potion = get("splash_potion");
|
||||
public static final ItemPotion splash_potion_damage = get("splash_potion_damage");
|
||||
public static final ItemPotion splash_potion_damage_2 = get("splash_potion_damage_2");
|
||||
public static final ItemPotion splash_potion_fire_resistance_2701 = get("splash_potion_fire_resistance_2701");
|
||||
public static final ItemPotion splash_potion_fire_resistance_7201 = get("splash_potion_fire_resistance_7201");
|
||||
public static final ItemPotion splash_potion_health = get("splash_potion_health");
|
||||
public static final ItemPotion splash_potion_health_2 = get("splash_potion_health_2");
|
||||
public static final ItemPotion splash_potion_night_vision_2701 = get("splash_potion_night_vision_2701");
|
||||
public static final ItemPotion splash_potion_night_vision_7201 = get("splash_potion_night_vision_7201");
|
||||
public static final ItemPotion splash_potion_poison_1801 = get("splash_potion_poison_1801");
|
||||
public static final ItemPotion splash_potion_poison_2_338 = get("splash_potion_poison_2_338");
|
||||
public static final ItemPotion splash_potion_poison_676 = get("splash_potion_poison_676");
|
||||
public static final ItemPotion splash_potion_regeneration_1801 = get("splash_potion_regeneration_1801");
|
||||
public static final ItemPotion splash_potion_regeneration_2_338 = get("splash_potion_regeneration_2_338");
|
||||
public static final ItemPotion splash_potion_regeneration_676 = get("splash_potion_regeneration_676");
|
||||
public static final ItemPotion splash_potion_slowness_1351 = get("splash_potion_slowness_1351");
|
||||
public static final ItemPotion splash_potion_slowness_3601 = get("splash_potion_slowness_3601");
|
||||
public static final ItemPotion splash_potion_speed_2701 = get("splash_potion_speed_2701");
|
||||
public static final ItemPotion splash_potion_speed_2_1351 = get("splash_potion_speed_2_1351");
|
||||
public static final ItemPotion splash_potion_speed_7201 = get("splash_potion_speed_7201");
|
||||
public static final ItemPotion splash_potion_stability_2701 = get("splash_potion_stability_2701");
|
||||
public static final ItemPotion splash_potion_stability_7201 = get("splash_potion_stability_7201");
|
||||
public static final ItemPotion splash_potion_strength_2701 = get("splash_potion_strength_2701");
|
||||
public static final ItemPotion splash_potion_strength_2_1351 = get("splash_potion_strength_2_1351");
|
||||
public static final ItemPotion splash_potion_strength_7201 = get("splash_potion_strength_7201");
|
||||
public static final ItemPotion splash_potion_weakness_1351 = get("splash_potion_weakness_1351");
|
||||
public static final ItemPotion splash_potion_weakness_3601 = get("splash_potion_weakness_3601");
|
||||
public static final ItemBlock sponge = get("sponge");
|
||||
public static final ItemBucket springwater_bucket = get("springwater_bucket");
|
||||
public static final ItemDoor spruce_door = get("spruce_door");
|
||||
|
@ -1019,6 +965,47 @@ public abstract class Items {
|
|||
public static final ItemEnchantedBook enchanted_book_unbreaking_3 = get("enchanted_book_unbreaking_3");
|
||||
public static final ItemRocketLauncher rocket_launcher = get("rocket_launcher");
|
||||
public static final ItemAmmo rocket = get("rocket");
|
||||
public static final ItemPotion potion = get("potion");
|
||||
public static final ItemPotion potion_fire_resistance = get("potion_fire_resistance");
|
||||
public static final ItemPotion potion_health = get("potion_health");
|
||||
public static final ItemPotion potion_speed = get("potion_speed");
|
||||
public static final ItemPotion potion_damage = get("potion_damage");
|
||||
public static final ItemPotion potion_damage_2 = get("potion_damage_2");
|
||||
public static final ItemPotion potion_damage_base = get("potion_damage_base");
|
||||
public static final ItemPotion potion_fire_resistance_base = get("potion_fire_resistance_base");
|
||||
public static final ItemPotion potion_fire_resistance_extended = get("potion_fire_resistance_extended");
|
||||
public static final ItemPotion potion_health_2 = get("potion_health_2");
|
||||
public static final ItemPotion potion_health_base = get("potion_health_base");
|
||||
public static final ItemPotion potion_mana = get("potion_mana");
|
||||
public static final ItemPotion potion_mana_2 = get("potion_mana_2");
|
||||
public static final ItemPotion potion_mana_base = get("potion_mana_base");
|
||||
public static final ItemPotion potion_night_vision = get("potion_night_vision");
|
||||
public static final ItemPotion potion_night_vision_base = get("potion_night_vision_base");
|
||||
public static final ItemPotion potion_night_vision_extended = get("potion_night_vision_extended");
|
||||
public static final ItemPotion potion_poison = get("potion_poison");
|
||||
public static final ItemPotion potion_poison_2 = get("potion_poison_2");
|
||||
public static final ItemPotion potion_poison_base = get("potion_poison_base");
|
||||
public static final ItemPotion potion_poison_extended = get("potion_poison_extended");
|
||||
public static final ItemPotion potion_regeneration = get("potion_regeneration");
|
||||
public static final ItemPotion potion_regeneration_2 = get("potion_regeneration_2");
|
||||
public static final ItemPotion potion_regeneration_base = get("potion_regeneration_base");
|
||||
public static final ItemPotion potion_regeneration_extended = get("potion_regeneration_extended");
|
||||
public static final ItemPotion potion_slowness = get("potion_slowness");
|
||||
public static final ItemPotion potion_slowness_base = get("potion_slowness_base");
|
||||
public static final ItemPotion potion_slowness_extended = get("potion_slowness_extended");
|
||||
public static final ItemPotion potion_speed_2 = get("potion_speed_2");
|
||||
public static final ItemPotion potion_speed_base = get("potion_speed_base");
|
||||
public static final ItemPotion potion_speed_extended = get("potion_speed_extended");
|
||||
public static final ItemPotion potion_stability = get("potion_stability");
|
||||
public static final ItemPotion potion_stability_base = get("potion_stability_base");
|
||||
public static final ItemPotion potion_stability_extended = get("potion_stability_extended");
|
||||
public static final ItemPotion potion_strength = get("potion_strength");
|
||||
public static final ItemPotion potion_strength_2 = get("potion_strength_2");
|
||||
public static final ItemPotion potion_strength_base = get("potion_strength_base");
|
||||
public static final ItemPotion potion_strength_extended = get("potion_strength_extended");
|
||||
public static final ItemPotion potion_weakness = get("potion_weakness");
|
||||
public static final ItemPotion potion_weakness_base = get("potion_weakness_base");
|
||||
public static final ItemPotion potion_weakness_extended = get("potion_weakness_extended");
|
||||
|
||||
private static <T extends Item> T get(String id) {
|
||||
T item = (T)ItemRegistry.byName(id);
|
||||
|
|
|
@ -1,20 +1,19 @@
|
|||
package common.item.tool;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import common.collect.Lists;
|
||||
import common.collect.Maps;
|
||||
import common.color.TextColor;
|
||||
import common.entity.npc.EntityNPC;
|
||||
import common.entity.projectile.EntityPotion;
|
||||
import common.init.ItemRegistry;
|
||||
import common.init.Items;
|
||||
import common.init.SoundEvent;
|
||||
import common.item.CheatTab;
|
||||
import common.item.Item;
|
||||
import common.item.ItemAction;
|
||||
import common.item.ItemControl;
|
||||
import common.item.ItemStack;
|
||||
import common.item.StackSize;
|
||||
import common.model.Model;
|
||||
import common.model.ModelProvider;
|
||||
import common.potion.Potion;
|
||||
|
@ -23,50 +22,45 @@ import common.potion.PotionHelper;
|
|||
import common.tileentity.TileEntity;
|
||||
import common.util.BlockPos;
|
||||
import common.util.Facing;
|
||||
import common.util.Pair;
|
||||
import common.util.Vec3;
|
||||
import common.world.World;
|
||||
|
||||
public class ItemPotion extends Item
|
||||
{
|
||||
private static final Map<Integer, ItemPotion> POTIONS = Maps.newTreeMap();
|
||||
private static final Map<List<PotionEffect>, Integer> SUB_ITEMS_CACHE = Maps.<List<PotionEffect>, Integer>newLinkedHashMap();
|
||||
|
||||
private final int data;
|
||||
|
||||
private List<PotionEffect> effectCache;
|
||||
private static final List<ItemPotion> POTIONS = Lists.newArrayList();
|
||||
|
||||
private final Potion type;
|
||||
private final PotionEffect effect;
|
||||
|
||||
public static ItemPotion getPotionItem(int data) {
|
||||
return POTIONS.getOrDefault(data, (data & 16384) != 0 ? Items.splash_potion : Items.potion);
|
||||
Item item = ItemRegistry.byId(data);
|
||||
return item instanceof ItemPotion potion ? potion : Items.potion;
|
||||
}
|
||||
|
||||
public static Collection<ItemPotion> getPotions() {
|
||||
return POTIONS.values();
|
||||
public static List<ItemPotion> getPotions() {
|
||||
return POTIONS;
|
||||
}
|
||||
|
||||
public ItemPotion(int data)
|
||||
public ItemPotion(Potion type, PotionEffect effect)
|
||||
{
|
||||
this.data = data;
|
||||
this.setUnstackable();
|
||||
this.type = type;
|
||||
this.effect = effect;
|
||||
this.setMaxAmount(StackSize.XS);
|
||||
this.setTab(CheatTab.POTIONS);
|
||||
this.setColor(TextColor.ORK);
|
||||
this.setDisplay(getDisplay(this));
|
||||
POTIONS.put(data, this);
|
||||
}
|
||||
|
||||
public int getPotionData() {
|
||||
return this.data;
|
||||
POTIONS.add(this);
|
||||
}
|
||||
|
||||
public List<PotionEffect> getEffects()
|
||||
public PotionEffect getEffect()
|
||||
{
|
||||
List<PotionEffect> list = this.effectCache;
|
||||
return this.effect;
|
||||
}
|
||||
|
||||
if (list == null)
|
||||
{
|
||||
list = this.effectCache = PotionHelper.getPotionEffects(this.data);
|
||||
}
|
||||
|
||||
return list;
|
||||
public Potion getType()
|
||||
{
|
||||
return this.type;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -82,17 +76,12 @@ public class ItemPotion extends Item
|
|||
|
||||
if (!worldIn.client)
|
||||
{
|
||||
List<PotionEffect> list = this.getEffects();
|
||||
|
||||
if (list != null)
|
||||
if (this.effect != null)
|
||||
{
|
||||
for (PotionEffect potioneffect : list)
|
||||
{
|
||||
if(potioneffect.getPotion().isInstant())
|
||||
potioneffect.getPotion().onImpact(null, null, playerIn, potioneffect.getAmplifier(), 1.0);
|
||||
else
|
||||
playerIn.addEffect(new PotionEffect(potioneffect));
|
||||
}
|
||||
if(this.effect.getPotion().isInstant())
|
||||
this.effect.getPotion().onImpact(null, null, playerIn, this.effect.getAmplifier(), 1.0);
|
||||
else
|
||||
playerIn.addEffect(new PotionEffect(this.effect.getPotion(), this.effect.getDuration(), this.effect.getAmplifier()));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -126,43 +115,30 @@ public class ItemPotion extends Item
|
|||
{
|
||||
return ItemAction.DRINK;
|
||||
}
|
||||
|
||||
public boolean onAction(ItemStack stack, EntityNPC player, World world, ItemControl control, BlockPos block) {
|
||||
if(control == ItemControl.TERTIARY || control == ItemControl.QUARTERNARY) {
|
||||
stack.decrSize();
|
||||
world.playSoundAtEntity(player, SoundEvent.THROW, 0.5F);
|
||||
if(!world.client)
|
||||
world.spawnEntityInWorld(new EntityPotion(world, player, stack));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer
|
||||
*/
|
||||
public ItemStack onItemRightClick(ItemStack itemStackIn, World worldIn, EntityNPC playerIn)
|
||||
{
|
||||
if (this.isSplashPotion())
|
||||
{
|
||||
// if (!playerIn.creative)
|
||||
// {
|
||||
itemStackIn.decrSize();
|
||||
// }
|
||||
|
||||
worldIn.playSoundAtEntity(playerIn, SoundEvent.THROW, 0.5F);
|
||||
|
||||
if (!worldIn.client)
|
||||
{
|
||||
worldIn.spawnEntityInWorld(new EntityPotion(worldIn, playerIn, itemStackIn));
|
||||
}
|
||||
|
||||
// playerIn.triggerAchievement(StatRegistry.objectUseStats[ItemRegistry.getIdFromItem(this)]);
|
||||
return itemStackIn;
|
||||
}
|
||||
else
|
||||
{
|
||||
playerIn.setItemInUse(itemStackIn, this.getMaxItemUseDuration(itemStackIn));
|
||||
return itemStackIn;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isSplashPotion() {
|
||||
return (this.data & 16384) != 0;
|
||||
playerIn.setItemInUse(itemStackIn, this.getMaxItemUseDuration(itemStackIn));
|
||||
return itemStackIn;
|
||||
}
|
||||
|
||||
public int getColorFromDamage()
|
||||
{
|
||||
return PotionHelper.getLiquidColor(this.data);
|
||||
return this.effect == null ? 0x385dc6 : this.effect.getPotion().getColor();
|
||||
}
|
||||
|
||||
public int getColorFromItemStack(ItemStack stack, int renderPass)
|
||||
|
@ -172,53 +148,22 @@ public class ItemPotion extends Item
|
|||
|
||||
public boolean isEffectInstant()
|
||||
{
|
||||
List<PotionEffect> list = this.getEffects();
|
||||
|
||||
if (list != null && !list.isEmpty())
|
||||
{
|
||||
for (PotionEffect potioneffect : list)
|
||||
{
|
||||
if (potioneffect.getPotion().isInstant())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return this.effect != null && this.effect.getPotion().isInstant();
|
||||
}
|
||||
|
||||
private static String getDisplay(ItemPotion potion)
|
||||
{
|
||||
if ((potion.data & 16383) == 0)
|
||||
if (potion.effect == null && potion.type == null)
|
||||
{
|
||||
return (potion.isSplashPotion() ? "Werfbare " : "") + "Wasserflasche";
|
||||
return "Wasserflasche";
|
||||
}
|
||||
else if (potion.effect != null)
|
||||
{
|
||||
return potion.effect.getPotionName();
|
||||
}
|
||||
else
|
||||
{
|
||||
String s = "";
|
||||
|
||||
if (potion.isSplashPotion())
|
||||
{
|
||||
s = "Werfbarer ";
|
||||
}
|
||||
|
||||
List<PotionEffect> list = potion.getEffects();
|
||||
|
||||
if (list != null && !list.isEmpty())
|
||||
{
|
||||
String s2 = list.get(0).getPotionName();
|
||||
return s + s2.trim();
|
||||
}
|
||||
else
|
||||
{
|
||||
String s1 = PotionHelper.getPotionPrefix(potion.data);
|
||||
return s1.trim() + " Trank";
|
||||
}
|
||||
return PotionHelper.getPotionPrefix(potion.type) + " Trank";
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -227,139 +172,72 @@ public class ItemPotion extends Item
|
|||
*/
|
||||
public void addInformation(ItemStack stack, EntityNPC playerIn, List<String> tooltip)
|
||||
{
|
||||
if ((this.data & 16383) != 0)
|
||||
if (this.effect != null)
|
||||
{
|
||||
List<PotionEffect> list = this.getEffects();
|
||||
List<String> implications = Lists.newArrayList();
|
||||
String s1 = this.effect.getEffectName().trim();
|
||||
Potion potion = this.effect.getPotion();
|
||||
|
||||
if (list != null && !list.isEmpty())
|
||||
if (this.effect.getDuration() > 0)
|
||||
{
|
||||
for (PotionEffect potioneffect : list)
|
||||
{
|
||||
String s1 = potioneffect.getEffectName().trim();
|
||||
Potion potion = potioneffect.getPotion();
|
||||
s1 = s1 + " (" + this.effect.getDurationString() + ")";
|
||||
}
|
||||
|
||||
if (potioneffect.getDuration() > 20)
|
||||
{
|
||||
s1 = s1 + " (" + potioneffect.getDurationString() + ")";
|
||||
}
|
||||
|
||||
if (potion.isBadEffect())
|
||||
{
|
||||
tooltip.add(TextColor.RED + s1);
|
||||
}
|
||||
else
|
||||
{
|
||||
tooltip.add(TextColor.LGRAY + s1);
|
||||
}
|
||||
String effectTip = potioneffect.getPotion().getTooltip(potioneffect.getAmplifier());
|
||||
if(effectTip != null)
|
||||
implications.add(effectTip);
|
||||
}
|
||||
if (potion.isBadEffect())
|
||||
{
|
||||
tooltip.add(TextColor.RED + s1);
|
||||
}
|
||||
else
|
||||
{
|
||||
String s = "Wirkungslos";
|
||||
tooltip.add(TextColor.LGRAY + s);
|
||||
}
|
||||
|
||||
if (!implications.isEmpty())
|
||||
{
|
||||
tooltip.add("");
|
||||
tooltip.add(TextColor.DMAGENTA + "Auswirkungen:");
|
||||
tooltip.addAll(implications);
|
||||
tooltip.add(TextColor.LGRAY + s1);
|
||||
}
|
||||
String effectTip = this.effect.getPotion().getTooltip(this.effect.getAmplifier());
|
||||
if(effectTip != null)
|
||||
tooltip.add(effectTip);
|
||||
}
|
||||
else if(this.type != null) {
|
||||
tooltip.add(TextColor.LGRAY + "Wirkungslos");
|
||||
}
|
||||
}
|
||||
|
||||
public boolean hasEffect(ItemStack stack)
|
||||
{
|
||||
List<PotionEffect> list = this.getEffects();
|
||||
return list != null && !list.isEmpty();
|
||||
return this.effect != null;
|
||||
}
|
||||
|
||||
public static String getPotionName(ItemPotion potion) { //TODO: fix potion names
|
||||
if((potion.getPotionData() & 16383) == 0)
|
||||
return potion.isSplashPotion() ? "splash_potion" : "potion";
|
||||
List<PotionEffect> list = potion.getEffects();
|
||||
if(list == null || list.isEmpty())
|
||||
return (potion.isSplashPotion() ? "splash_potion_" : "potion_") + PotionHelper.getPotionPrefixIndex(potion.getPotionData());
|
||||
PotionEffect effect = list.get(0);
|
||||
return (potion.isSplashPotion() ? "splash_potion_" : "potion_") + effect.getPotion().getName() + (effect.getAmplifier() == 0 ? "" : "_" + (effect.getAmplifier() + 1)) + (effect.getPotion().isInstant() ? "" : "_" + effect.getDuration());
|
||||
public static List<Pair<String, Potion>> getBasePotions() {
|
||||
List<Pair<String, Potion>> effects = Lists.newArrayList();
|
||||
effects.add(new Pair("potion", null));
|
||||
for(Potion potion : Potion.values()) {
|
||||
if(potion.getMaxStrength() > 0) {
|
||||
effects.add(new Pair("potion_" + potion + "_base", potion));
|
||||
}
|
||||
}
|
||||
return effects;
|
||||
}
|
||||
|
||||
public static List<Integer> getValidDataValues()
|
||||
{
|
||||
List<Integer> data = Lists.newArrayList();
|
||||
data.add(0);
|
||||
data.add(16384);
|
||||
|
||||
if (SUB_ITEMS_CACHE.isEmpty())
|
||||
{
|
||||
for (int i = 0; i <= 15; ++i)
|
||||
{
|
||||
for (int j = 0; j <= 1; ++j)
|
||||
{
|
||||
int lvt_6_1_;
|
||||
|
||||
if (j == 0)
|
||||
{
|
||||
lvt_6_1_ = i | 8192;
|
||||
}
|
||||
else
|
||||
{
|
||||
lvt_6_1_ = i | 16384;
|
||||
}
|
||||
|
||||
for (int l = 0; l <= 2; ++l)
|
||||
{
|
||||
int i1 = lvt_6_1_;
|
||||
|
||||
if (l != 0)
|
||||
{
|
||||
if (l == 1)
|
||||
{
|
||||
i1 = lvt_6_1_ | 32;
|
||||
}
|
||||
else if (l == 2)
|
||||
{
|
||||
i1 = lvt_6_1_ | 64;
|
||||
}
|
||||
}
|
||||
|
||||
List<PotionEffect> list = PotionHelper.getPotionEffects(i1);
|
||||
|
||||
if (list != null && !list.isEmpty())
|
||||
{
|
||||
SUB_ITEMS_CACHE.put(list, Integer.valueOf(i1));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Iterator iterator = SUB_ITEMS_CACHE.values().iterator();
|
||||
|
||||
while (iterator.hasNext())
|
||||
{
|
||||
int j1 = ((Integer)iterator.next()).intValue();
|
||||
data.add(j1);
|
||||
}
|
||||
|
||||
return data;
|
||||
|
||||
public static List<Pair<String, PotionEffect>> getBrewedPotions() {
|
||||
List<Pair<String, PotionEffect>> effects = Lists.newArrayList();
|
||||
for(Potion potion : Potion.values()) {
|
||||
int maxStrength = potion.getMaxStrength();
|
||||
int baseDuration = potion.getBaseDuration();
|
||||
for(int z = 0; z < maxStrength; z++) {
|
||||
effects.add(new Pair("potion_" + potion + (z == 0 ? "" : "_" + (z + 1)), new PotionEffect(potion, baseDuration / (z + 1), z)));
|
||||
if(z == 0 && !potion.isInstant())
|
||||
effects.add(new Pair("potion_" + potion + "_extended", new PotionEffect(potion, (baseDuration * 8) / 3, z)));
|
||||
}
|
||||
}
|
||||
return effects;
|
||||
}
|
||||
|
||||
public Model getModel(ModelProvider provider, String name) {
|
||||
return provider.getModel(this.getTransform(), "potion_overlay", this.isSplashPotion() ? "potion_bottle_splash" : "potion_bottle_drinkable");
|
||||
return provider.getModel(this.getTransform(), "potion_overlay", "potion_bottle_drinkable");
|
||||
}
|
||||
|
||||
public ItemStack dispenseStack(World world, TileEntity source, Vec3 position, BlockPos blockpos, Facing facing, ItemStack stack) {
|
||||
if(this.isSplashPotion())
|
||||
return this.dispenseProjectile(world, facing, stack, new EntityPotion(world, position.xCoord, position.yCoord, position.zCoord, stack.copy()), 1.375f, 3.0f);
|
||||
return super.dispenseStack(world, source, position, blockpos, facing, stack);
|
||||
return this.dispenseProjectile(world, facing, stack, new EntityPotion(world, position.xCoord, position.yCoord, position.zCoord, stack.copy()), 1.375f, 3.0f);
|
||||
}
|
||||
|
||||
public int getDispenseSoundId() {
|
||||
return this.isSplashPotion() ? 1002 : super.getDispenseSoundId();
|
||||
return 1002;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,12 +10,12 @@ import common.entity.types.EntityLiving;
|
|||
import common.vars.Vars;
|
||||
|
||||
public enum Potion {
|
||||
SPEED("speed", "Schnelligkeit", "Trank der Schnelligkeit", false, 8171462) {
|
||||
SPEED("speed", 2, 3600, "Schnelligkeit", "Trank der Schnelligkeit", false, 8171462) {
|
||||
public String getTooltip(int amp) {
|
||||
return String.format(TextColor.BLUE + "+%d%% Geschwindigkeit", 20 * (amp + 1));
|
||||
}
|
||||
},
|
||||
SLOWNESS("slowness", "Langsamkeit", "Trank der Langsamkeit", true, 5926017) {
|
||||
SLOWNESS("slowness", 1, 1800, "Langsamkeit", "Trank der Langsamkeit", true, 5926017) {
|
||||
public String getTooltip(int amp) {
|
||||
return String.format(TextColor.RED + "-%d%% Geschwindigkeit", 15 * (amp + 1));
|
||||
}
|
||||
|
@ -26,16 +26,12 @@ public enum Potion {
|
|||
}
|
||||
},
|
||||
FATIGUE("mining_fatigue", "Abbaulähmung", "Trank der Trägheit", true, 4866583),
|
||||
STRENGTH("strength", "Stärke", "Trank der Stärke", false, 9643043) {
|
||||
STRENGTH("strength", 2, 3600, "Stärke", "Trank der Stärke", false, 9643043) {
|
||||
public String getTooltip(int amp) {
|
||||
return String.format(TextColor.BLUE + "+%d%% Angriffsschaden", 50 * (amp + 1));
|
||||
}
|
||||
},
|
||||
HEAL("health", "Direktheilung", "Trank der Heilung", false, 16262179) {
|
||||
public boolean isInstant() {
|
||||
return true;
|
||||
}
|
||||
|
||||
HEAL("health", 2, "Direktheilung", "Trank der Heilung", false, 16262179) {
|
||||
public void onImpact(EntityPotion potion, EntityLiving thrower, EntityLiving entity, int amp, double effect) {
|
||||
if(entity.arePotionsInverted()) {
|
||||
if(Vars.damagePotion) {
|
||||
|
@ -51,11 +47,7 @@ public enum Potion {
|
|||
}
|
||||
}
|
||||
},
|
||||
DAMAGE("damage", "Direktschaden", "Trank des Schadens", true, 4393481) {
|
||||
public boolean isInstant() {
|
||||
return true;
|
||||
}
|
||||
|
||||
DAMAGE("damage", 2, "Direktschaden", "Trank des Schadens", true, 4393481) {
|
||||
public void onImpact(EntityPotion potion, EntityLiving thrower, EntityLiving entity, int amp, double effect) {
|
||||
if(!entity.arePotionsInverted()) {
|
||||
if(Vars.damagePotion) {
|
||||
|
@ -77,7 +69,7 @@ public enum Potion {
|
|||
return 0.25;
|
||||
}
|
||||
},
|
||||
REGENERATION("regeneration", "Regeneration", "Trank der Regeneration", false, 13458603) {
|
||||
REGENERATION("regeneration", 2, 900, "Regeneration", "Trank der Regeneration", false, 13458603) {
|
||||
public void onUpdate(EntityLiving entity, int duration, int amp) {
|
||||
int k = 50 >> amp;
|
||||
if((k <= 0 || duration % k == 0) && entity.getHealth() < entity.getMaxHealth())
|
||||
|
@ -89,7 +81,7 @@ public enum Potion {
|
|||
}
|
||||
},
|
||||
RESISTANCE("resistance", "Resistenz", "Trank des Widerstandes", false, 10044730),
|
||||
FIRE_RESISTANCE("fire_resistance", "Feuerschutz", "Trank der Feuerresistenz", false, 14981690),
|
||||
FIRE_RESISTANCE("fire_resistance", 1, 3600, "Feuerschutz", "Trank der Feuerresistenz", false, 14981690),
|
||||
MANA_GENERATION("mana_generation", "Manaschub", "Trank des Manaschubes", false, 3035801) {
|
||||
public void onUpdate(EntityLiving entity, int duration, int amp) {
|
||||
if(!(entity instanceof EntityNPC npc))
|
||||
|
@ -113,14 +105,14 @@ public enum Potion {
|
|||
return 0.25;
|
||||
}
|
||||
},
|
||||
NIGHT_VISION("night_vision", "Nachtsicht", "Trank der Nachtsicht", false, 2039713),
|
||||
STABILITY("stability", "Stabilität", "Trank der Standfestigkeit", false, 5797459),
|
||||
WEAKNESS("weakness", "Schwäche", "Trank der Schwäche", true, 4738376) {
|
||||
NIGHT_VISION("night_vision", 1, 3600, "Nachtsicht", "Trank der Nachtsicht", false, 2039713),
|
||||
STABILITY("stability", 1, 3600, "Stabilität", "Trank der Standfestigkeit", false, 5797459),
|
||||
WEAKNESS("weakness", 1, 1800, "Schwäche", "Trank der Schwäche", true, 4738376) {
|
||||
public String getTooltip(int amp) {
|
||||
return String.format(TextColor.RED + "-%d%% Angriffsschaden", 20 * (amp + 1));
|
||||
}
|
||||
},
|
||||
POISON("poison", "Vergiftung", "Trank der Vergiftung", true, 5149489) {
|
||||
POISON("poison", 2, 900, "Vergiftung", "Trank der Vergiftung", true, 5149489) {
|
||||
public void onUpdate(EntityLiving entity, int duration, int amp) {
|
||||
int j = 25 >> amp;
|
||||
if((j <= 0 || duration % j == 0) && (entity.worldObj.client || Vars.damagePoison) && entity.getHealth() > 1)
|
||||
|
@ -146,11 +138,7 @@ public enum Potion {
|
|||
entity.attackEntityFrom(DamageSource.radiation, 1 + amp);
|
||||
}
|
||||
},
|
||||
MANA("mana", "Mana", "Manatrank", false, 0x0000ff) {
|
||||
public boolean isInstant() {
|
||||
return true;
|
||||
}
|
||||
|
||||
MANA("mana", 2, "Mana", "Manatrank", false, 0x0000ff) {
|
||||
public void onImpact(EntityPotion potion, EntityLiving thrower, EntityLiving entity, int amp, double effect) {
|
||||
if(entity instanceof EntityNPC npc)
|
||||
npc.healMana(Math.max((int)(effect * (double)(4 << amp) + 0.5D), 0));
|
||||
|
@ -163,7 +151,10 @@ public enum Potion {
|
|||
private final String effectDisplay;
|
||||
private final String potionDisplay;
|
||||
private final boolean bad;
|
||||
private final boolean instant;
|
||||
private final int color;
|
||||
private final int maxStrength;
|
||||
private final int baseDuration;
|
||||
|
||||
static {
|
||||
for(Potion potion : values()) {
|
||||
|
@ -176,9 +167,24 @@ public enum Potion {
|
|||
}
|
||||
|
||||
private Potion(String name, String effectDisplay, String potionDisplay, boolean bad, int color) {
|
||||
this(name, 0, 0, effectDisplay, potionDisplay, bad, color, false);
|
||||
}
|
||||
|
||||
private Potion(String name, int maxStrength, String effectDisplay, String potionDisplay, boolean bad, int color) {
|
||||
this(name, maxStrength, 0, effectDisplay, potionDisplay, bad, color, true);
|
||||
}
|
||||
|
||||
private Potion(String name, int maxStrength, int baseDuration, String effectDisplay, String potionDisplay, boolean bad, int color) {
|
||||
this(name, maxStrength, baseDuration, effectDisplay, potionDisplay, bad, color, false);
|
||||
}
|
||||
|
||||
private Potion(String name, int maxStrength, int baseDuration, String effectDisplay, String potionDisplay, boolean bad, int color, boolean instant) {
|
||||
this.name = name;
|
||||
this.bad = bad;
|
||||
this.instant = instant;
|
||||
this.color = color;
|
||||
this.maxStrength = maxStrength;
|
||||
this.baseDuration = baseDuration;
|
||||
this.effectDisplay = effectDisplay;
|
||||
this.potionDisplay = potionDisplay;
|
||||
}
|
||||
|
@ -207,6 +213,14 @@ public enum Potion {
|
|||
return this.color;
|
||||
}
|
||||
|
||||
public int getMaxStrength() {
|
||||
return this.maxStrength;
|
||||
}
|
||||
|
||||
public int getBaseDuration() {
|
||||
return this.baseDuration;
|
||||
}
|
||||
|
||||
public void onUpdate(EntityLiving entity, int duration, int amp) {
|
||||
}
|
||||
|
||||
|
@ -214,7 +228,7 @@ public enum Potion {
|
|||
}
|
||||
|
||||
public boolean isInstant() {
|
||||
return false;
|
||||
return this.instant;
|
||||
}
|
||||
|
||||
public String getTooltip(int amp) {
|
||||
|
|
|
@ -18,12 +18,6 @@ public class PotionEffect {
|
|||
this.amplifier = amplifier;
|
||||
}
|
||||
|
||||
public PotionEffect(PotionEffect other) {
|
||||
this.potion = other.potion;
|
||||
this.duration = this.remaining = other.duration;
|
||||
this.amplifier = other.amplifier;
|
||||
}
|
||||
|
||||
public PotionEffect combine(PotionEffect other) {
|
||||
if(this.potion != other.potion)
|
||||
Log.TICK.warn("PotionEffect.combine(): Diese Methode sollte nur für gleiche Effekte aufgerufen werden!");
|
||||
|
|
|
@ -1,16 +1,15 @@
|
|||
package common.potion;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import common.collect.Lists;
|
||||
import common.collect.Maps;
|
||||
import common.init.Items;
|
||||
import common.item.tool.ItemPotion;
|
||||
|
||||
public class PotionHelper
|
||||
{
|
||||
private static final String[] POTENCIES = new String[] {"II", "III", "IV", "V", "VI", "VII", "VIII", "IX", "X"};
|
||||
private static final Integer[] INTEGERS = new Integer[65535];
|
||||
|
||||
public static final String sugarEffect = "-0+1-2-3&4-4+13";
|
||||
public static final String tearEffect = "+0-1-2-3&4-4+13";
|
||||
|
@ -24,7 +23,6 @@ public class PotionHelper
|
|||
public static final String gunpowderEffect = "+14&13-13";
|
||||
public static final String goldenCarrotEffect = "-0+1+2-3+13&4-4";
|
||||
public static final String pufferfishEffect = "+0-1+2+3+13&4-4";
|
||||
// public static final String rabbitFootEffect = "+0+1-2+3&4-4+13";
|
||||
|
||||
private static final Map<Potion, String> potionRequirements = Maps.<Potion, String>newEnumMap(Potion.class);
|
||||
private static final Map<Potion, String> potionAmplifiers = Maps.<Potion, String>newEnumMap(Potion.class);
|
||||
|
@ -39,51 +37,10 @@ public class PotionHelper
|
|||
"Fauler", "Geruchloser", "Ranziger", "Rauer", "Beißender",
|
||||
"Widerlicher", "Stinkender"
|
||||
};
|
||||
|
||||
static {
|
||||
for(int z = 0; z < INTEGERS.length; z++) {
|
||||
INTEGERS[z] = z;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the bit at 1 << j is on in i.
|
||||
*/
|
||||
public static boolean checkFlag(int p_77914_0_, int p_77914_1_)
|
||||
{
|
||||
return (p_77914_0_ & 1 << p_77914_1_) != 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns 1 if the flag is set, 0 if it is not set.
|
||||
*/
|
||||
private static int isFlagSet(int p_77910_0_, int p_77910_1_)
|
||||
{
|
||||
return checkFlag(p_77910_0_, p_77910_1_) ? 1 : 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns 0 if the flag is set, 1 if it is not set.
|
||||
*/
|
||||
private static int isFlagUnset(int p_77916_0_, int p_77916_1_)
|
||||
{
|
||||
return checkFlag(p_77916_0_, p_77916_1_) ? 0 : 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Given a potion data value, get its prefix index number.
|
||||
*/
|
||||
public static int getPotionPrefixIndex(int dataValue)
|
||||
{
|
||||
return getPotionPrefixIndexFlags(dataValue, 5, 4, 3, 2, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Given a {@link Collection}<{@link PotionEffect}> will return an Integer color.
|
||||
*/
|
||||
public static int calcPotionLiquidColor(Collection<PotionEffect> effects)
|
||||
{
|
||||
int i = 3694022;
|
||||
int i = Items.potion.getColorFromDamage();
|
||||
|
||||
if (effects != null && !effects.isEmpty())
|
||||
{
|
||||
|
@ -123,25 +80,9 @@ public class PotionHelper
|
|||
}
|
||||
}
|
||||
|
||||
public static int getLiquidColor(int meta)
|
||||
public static String getPotionPrefix(Potion potion)
|
||||
{
|
||||
Integer key = meta > 0 && meta < INTEGERS.length ? INTEGERS[meta] : meta;
|
||||
if (DATAVALUE_COLORS.containsKey(key))
|
||||
{
|
||||
return ((Integer)DATAVALUE_COLORS.get(key)).intValue();
|
||||
}
|
||||
else
|
||||
{
|
||||
int i = calcPotionLiquidColor(getPotionEffects(key.intValue()));
|
||||
DATAVALUE_COLORS.put(key, Integer.valueOf(i));
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
public static String getPotionPrefix(int dataValue)
|
||||
{
|
||||
int i = getPotionPrefixIndex(dataValue);
|
||||
return potionPrefixes[i];
|
||||
return potionPrefixes[potion.ordinal() % potionPrefixes.length];
|
||||
}
|
||||
|
||||
public static String getPotionPotency(int value)
|
||||
|
@ -149,419 +90,9 @@ public class PotionHelper
|
|||
return value >= 1 && value <= 9 ? " " + POTENCIES[value - 1] : (value == 0 ? "" : (" " + (value + 1)));
|
||||
}
|
||||
|
||||
private static int getPotionEffect(boolean p_77904_0_, boolean p_77904_1_, boolean p_77904_2_, int p_77904_3_, int p_77904_4_, int p_77904_5_, int meta)
|
||||
public static ItemPotion applyIngredient(ItemPotion potion, String effect)
|
||||
{
|
||||
int i = 0;
|
||||
|
||||
if (p_77904_0_)
|
||||
{
|
||||
i = isFlagUnset(meta, p_77904_4_);
|
||||
}
|
||||
else if (p_77904_3_ != -1)
|
||||
{
|
||||
if (p_77904_3_ == 0 && countSetFlags(meta) == p_77904_4_)
|
||||
{
|
||||
i = 1;
|
||||
}
|
||||
else if (p_77904_3_ == 1 && countSetFlags(meta) > p_77904_4_)
|
||||
{
|
||||
i = 1;
|
||||
}
|
||||
else if (p_77904_3_ == 2 && countSetFlags(meta) < p_77904_4_)
|
||||
{
|
||||
i = 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
i = isFlagSet(meta, p_77904_4_);
|
||||
}
|
||||
|
||||
if (p_77904_1_)
|
||||
{
|
||||
i *= p_77904_5_;
|
||||
}
|
||||
|
||||
if (p_77904_2_)
|
||||
{
|
||||
i *= -1;
|
||||
}
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of 1 bits in the given integer.
|
||||
*/
|
||||
private static int countSetFlags(int meta)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; meta > 0; ++i)
|
||||
{
|
||||
meta &= meta - 1;
|
||||
}
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
private static int parsePotionEffects(String data, int start, int end, int meta)
|
||||
{
|
||||
if (start < data.length() && end >= 0 && start < end)
|
||||
{
|
||||
int i = data.indexOf(124, start);
|
||||
|
||||
if (i >= 0 && i < end)
|
||||
{
|
||||
int l1 = parsePotionEffects(data, start, i - 1, meta);
|
||||
|
||||
if (l1 > 0)
|
||||
{
|
||||
return l1;
|
||||
}
|
||||
else
|
||||
{
|
||||
int j2 = parsePotionEffects(data, i + 1, end, meta);
|
||||
return j2 > 0 ? j2 : 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
int j = data.indexOf(38, start);
|
||||
|
||||
if (j >= 0 && j < end)
|
||||
{
|
||||
int i2 = parsePotionEffects(data, start, j - 1, meta);
|
||||
|
||||
if (i2 <= 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
int k2 = parsePotionEffects(data, j + 1, end, meta);
|
||||
return k2 <= 0 ? 0 : (i2 > k2 ? i2 : k2);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
boolean flag = false;
|
||||
boolean flag1 = false;
|
||||
boolean flag2 = false;
|
||||
boolean flag3 = false;
|
||||
boolean flag4 = false;
|
||||
int k = -1;
|
||||
int l = 0;
|
||||
int i1 = 0;
|
||||
int j1 = 0;
|
||||
|
||||
for (int k1 = start; k1 < end; ++k1)
|
||||
{
|
||||
char c0 = data.charAt(k1);
|
||||
|
||||
if (c0 >= 48 && c0 <= 57)
|
||||
{
|
||||
if (flag)
|
||||
{
|
||||
i1 = c0 - 48;
|
||||
flag1 = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
l = l * 10;
|
||||
l = l + (c0 - 48);
|
||||
flag2 = true;
|
||||
}
|
||||
}
|
||||
else if (c0 == 42)
|
||||
{
|
||||
flag = true;
|
||||
}
|
||||
else if (c0 == 33)
|
||||
{
|
||||
if (flag2)
|
||||
{
|
||||
j1 += getPotionEffect(flag3, flag1, flag4, k, l, i1, meta);
|
||||
flag3 = false;
|
||||
flag4 = false;
|
||||
flag = false;
|
||||
flag1 = false;
|
||||
flag2 = false;
|
||||
i1 = 0;
|
||||
l = 0;
|
||||
k = -1;
|
||||
}
|
||||
|
||||
flag3 = true;
|
||||
}
|
||||
else if (c0 == 45)
|
||||
{
|
||||
if (flag2)
|
||||
{
|
||||
j1 += getPotionEffect(flag3, flag1, flag4, k, l, i1, meta);
|
||||
flag3 = false;
|
||||
flag4 = false;
|
||||
flag = false;
|
||||
flag1 = false;
|
||||
flag2 = false;
|
||||
i1 = 0;
|
||||
l = 0;
|
||||
k = -1;
|
||||
}
|
||||
|
||||
flag4 = true;
|
||||
}
|
||||
else if (c0 != 61 && c0 != 60 && c0 != 62)
|
||||
{
|
||||
if (c0 == 43 && flag2)
|
||||
{
|
||||
j1 += getPotionEffect(flag3, flag1, flag4, k, l, i1, meta);
|
||||
flag3 = false;
|
||||
flag4 = false;
|
||||
flag = false;
|
||||
flag1 = false;
|
||||
flag2 = false;
|
||||
i1 = 0;
|
||||
l = 0;
|
||||
k = -1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (flag2)
|
||||
{
|
||||
j1 += getPotionEffect(flag3, flag1, flag4, k, l, i1, meta);
|
||||
flag3 = false;
|
||||
flag4 = false;
|
||||
flag = false;
|
||||
flag1 = false;
|
||||
flag2 = false;
|
||||
i1 = 0;
|
||||
l = 0;
|
||||
k = -1;
|
||||
}
|
||||
|
||||
if (c0 == 61)
|
||||
{
|
||||
k = 0;
|
||||
}
|
||||
else if (c0 == 60)
|
||||
{
|
||||
k = 2;
|
||||
}
|
||||
else if (c0 == 62)
|
||||
{
|
||||
k = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (flag2)
|
||||
{
|
||||
j1 += getPotionEffect(flag3, flag1, flag4, k, l, i1, meta);
|
||||
}
|
||||
|
||||
return j1;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public static List<PotionEffect> getPotionEffects(int meta)
|
||||
{
|
||||
List<PotionEffect> list = null;
|
||||
|
||||
for (Potion potion : Potion.values())
|
||||
{
|
||||
// if (potion != null) // && (!potion.isUsable() || all))
|
||||
// {
|
||||
String s = potionRequirements.get(potion);
|
||||
|
||||
if (s != null)
|
||||
{
|
||||
int i = parsePotionEffects(s, 0, s.length(), meta);
|
||||
|
||||
if (i > 0)
|
||||
{
|
||||
int j = 0;
|
||||
String s1 = potionAmplifiers.get(potion);
|
||||
|
||||
if (s1 != null)
|
||||
{
|
||||
j = parsePotionEffects(s1, 0, s1.length(), meta);
|
||||
|
||||
if (j < 0)
|
||||
{
|
||||
j = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (potion.isInstant())
|
||||
{
|
||||
i = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
i = 1200 * (i * 3 + (i - 1) * 2);
|
||||
i = i >> j;
|
||||
i = (int)Math.round((double)i * potion.getEffectiveness());
|
||||
|
||||
if ((meta & 16384) != 0)
|
||||
{
|
||||
i = (int)Math.round((double)i * 0.75D + 0.5D);
|
||||
}
|
||||
}
|
||||
|
||||
if (list == null)
|
||||
{
|
||||
list = Lists.<PotionEffect>newArrayList();
|
||||
}
|
||||
|
||||
PotionEffect potioneffect = new PotionEffect(potion, i, j);
|
||||
|
||||
if ((meta & 16384) != 0)
|
||||
{
|
||||
potioneffect.setThrown(true);
|
||||
}
|
||||
|
||||
list.add(potioneffect);
|
||||
}
|
||||
}
|
||||
// }
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* Manipulates the specified bit of the potion damage value according to the rules passed from applyIngredient.
|
||||
*/
|
||||
private static int brewBitOperations(int p_77906_0_, int p_77906_1_, boolean p_77906_2_, boolean p_77906_3_, boolean p_77906_4_)
|
||||
{
|
||||
if (p_77906_4_)
|
||||
{
|
||||
if (!checkFlag(p_77906_0_, p_77906_1_))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else if (p_77906_2_)
|
||||
{
|
||||
p_77906_0_ &= ~(1 << p_77906_1_);
|
||||
}
|
||||
else if (p_77906_3_)
|
||||
{
|
||||
if ((p_77906_0_ & 1 << p_77906_1_) == 0)
|
||||
{
|
||||
p_77906_0_ |= 1 << p_77906_1_;
|
||||
}
|
||||
else
|
||||
{
|
||||
p_77906_0_ &= ~(1 << p_77906_1_);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
p_77906_0_ |= 1 << p_77906_1_;
|
||||
}
|
||||
|
||||
return p_77906_0_;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the new potion damage value after the specified ingredient info is applied to the specified potion.
|
||||
*/
|
||||
public static int applyIngredient(int p_77913_0_, String p_77913_1_)
|
||||
{
|
||||
int i = 0;
|
||||
int j = p_77913_1_.length();
|
||||
boolean flag = false;
|
||||
boolean flag1 = false;
|
||||
boolean flag2 = false;
|
||||
boolean flag3 = false;
|
||||
int k = 0;
|
||||
|
||||
for (int l = i; l < j; ++l)
|
||||
{
|
||||
char c0 = p_77913_1_.charAt(l);
|
||||
|
||||
if (c0 >= 48 && c0 <= 57)
|
||||
{
|
||||
k = k * 10;
|
||||
k = k + (c0 - 48);
|
||||
flag = true;
|
||||
}
|
||||
else if (c0 == 33)
|
||||
{
|
||||
if (flag)
|
||||
{
|
||||
p_77913_0_ = brewBitOperations(p_77913_0_, k, flag2, flag1, flag3);
|
||||
flag3 = false;
|
||||
flag1 = false;
|
||||
flag2 = false;
|
||||
flag = false;
|
||||
k = 0;
|
||||
}
|
||||
|
||||
flag1 = true;
|
||||
}
|
||||
else if (c0 == 45)
|
||||
{
|
||||
if (flag)
|
||||
{
|
||||
p_77913_0_ = brewBitOperations(p_77913_0_, k, flag2, flag1, flag3);
|
||||
flag3 = false;
|
||||
flag1 = false;
|
||||
flag2 = false;
|
||||
flag = false;
|
||||
k = 0;
|
||||
}
|
||||
|
||||
flag2 = true;
|
||||
}
|
||||
else if (c0 == 43)
|
||||
{
|
||||
if (flag)
|
||||
{
|
||||
p_77913_0_ = brewBitOperations(p_77913_0_, k, flag2, flag1, flag3);
|
||||
flag3 = false;
|
||||
flag1 = false;
|
||||
flag2 = false;
|
||||
flag = false;
|
||||
k = 0;
|
||||
}
|
||||
}
|
||||
else if (c0 == 38)
|
||||
{
|
||||
if (flag)
|
||||
{
|
||||
p_77913_0_ = brewBitOperations(p_77913_0_, k, flag2, flag1, flag3);
|
||||
flag3 = false;
|
||||
flag1 = false;
|
||||
flag2 = false;
|
||||
flag = false;
|
||||
k = 0;
|
||||
}
|
||||
|
||||
flag3 = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (flag)
|
||||
{
|
||||
p_77913_0_ = brewBitOperations(p_77913_0_, k, flag2, flag1, flag3);
|
||||
}
|
||||
|
||||
return p_77913_0_ & 32767;
|
||||
}
|
||||
|
||||
public static int getPotionPrefixIndexFlags(int data, int v1, int v2, int v3, int v4, int v5)
|
||||
{
|
||||
return (checkFlag(data, v1) ? 16 : 0) | (checkFlag(data, v2) ? 8 : 0) | (checkFlag(data, v3) ? 4 : 0) | (checkFlag(data, v4) ? 2 : 0) | (checkFlag(data, v5) ? 1 : 0);
|
||||
return potion; // TODO: add brewing back
|
||||
}
|
||||
|
||||
static
|
||||
|
@ -577,8 +108,7 @@ public class PotionHelper
|
|||
potionRequirements.put(Potion.STRENGTH, "0 & !1 & !2 & 3 & 3+6");
|
||||
potionRequirements.put(Potion.NIGHT_VISION, "!0 & 1 & 2 & !3 & 2+6");
|
||||
potionRequirements.put(Potion.STABILITY, "!0 & 1 & 2 & 3 & 2+6");
|
||||
// potionRequirements.put(Potion.waterBreathing, "0 & !1 & 2 & 3 & 2+6");
|
||||
// potionRequirements.put(Potion.jump, "0 & 1 & !2 & 3 & 3+6");
|
||||
|
||||
potionAmplifiers.put(Potion.SPEED, "5");
|
||||
potionAmplifiers.put(Potion.HASTE, "5");
|
||||
potionAmplifiers.put(Potion.STRENGTH, "5");
|
||||
|
@ -587,6 +117,5 @@ public class PotionHelper
|
|||
potionAmplifiers.put(Potion.HEAL, "5");
|
||||
potionAmplifiers.put(Potion.RESISTANCE, "5");
|
||||
potionAmplifiers.put(Potion.POISON, "5");
|
||||
// potionAmplifiers.put(Potion.jump, "5");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -147,16 +147,10 @@ public class TileEntityBrewingStand extends TileEntityLockable implements ITicka
|
|||
{
|
||||
ItemPotion result = this.getPotionResult(potion, itemstack);
|
||||
|
||||
if (!potion.isSplashPotion() && result.isSplashPotion())
|
||||
{
|
||||
flag = true;
|
||||
break;
|
||||
}
|
||||
PotionEffect list = potion.getEffect();
|
||||
PotionEffect list1 = result.getEffect();
|
||||
|
||||
List<PotionEffect> list = potion.getEffects();
|
||||
List<PotionEffect> list1 = result.getEffects();
|
||||
|
||||
if ((potion.getPotionData() <= 0 || list != list1) && (list == null || !list.equals(list1) && list1 != null) && potion != result)
|
||||
if ((potion.getType() == null || list != list1) && (list == null || !list.equals(list1) && list1 != null) && potion != result)
|
||||
{
|
||||
flag = true;
|
||||
break;
|
||||
|
@ -184,15 +178,11 @@ public class TileEntityBrewingStand extends TileEntityLockable implements ITicka
|
|||
if (this.brewingItemStacks[i] != null && this.brewingItemStacks[i].getItem() instanceof ItemPotion potion)
|
||||
{
|
||||
ItemPotion result = this.getPotionResult(potion, itemstack);
|
||||
List<PotionEffect> list = potion.getEffects();
|
||||
List<PotionEffect> list1 = result.getEffects();
|
||||
PotionEffect list = potion.getEffect();
|
||||
PotionEffect list1 = result.getEffect();
|
||||
|
||||
if (potion.getPotionData() > 0 && list == list1 || list != null && (list.equals(list1) || list1 == null))
|
||||
if (potion.getType() != null && list == list1 || list != null && (list.equals(list1) || list1 == null))
|
||||
{
|
||||
if (!potion.isSplashPotion() && result.isSplashPotion())
|
||||
{
|
||||
this.brewingItemStacks[i] = new ItemStack(result);
|
||||
}
|
||||
}
|
||||
else if (potion != result)
|
||||
{
|
||||
|
@ -217,7 +207,7 @@ public class TileEntityBrewingStand extends TileEntityLockable implements ITicka
|
|||
|
||||
private ItemPotion getPotionResult(ItemPotion potion, ItemStack stack)
|
||||
{
|
||||
return stack == null ? potion : (stack.getItem().isPotionIngredient(stack) ? ItemPotion.getPotionItem(PotionHelper.applyIngredient(potion.getPotionData(), stack.getItem().getPotionEffect(stack))) : potion);
|
||||
return stack == null ? potion : (stack.getItem().isPotionIngredient(stack) ? PotionHelper.applyIngredient(potion, stack.getItem().getPotionEffect(stack)) : potion);
|
||||
}
|
||||
|
||||
public void readTags(TagObject compound)
|
||||
|
|
|
@ -1117,6 +1117,9 @@ public class Player extends User implements Executor, IPlayer
|
|||
{
|
||||
if(this.onPlayerInteract(true, pos)) {
|
||||
this.sendPacket(new SPacketBlockChange(this.entity.worldObj, pos));
|
||||
if(this.entity.getCurrentEquippedItem() != null && this.entity.getCurrentEquippedItem().isEmpty())
|
||||
this.entity.inventory.mainInventory[this.entity.inventory.currentItem] = null;
|
||||
this.entity.openContainer.detectAndSendChanges();
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1277,6 +1280,9 @@ public class Player extends User implements Executor, IPlayer
|
|||
if(this.onPlayerInteract(false, pos)) {
|
||||
this.sendPacket(new SPacketBlockChange(this.entity.worldObj, pos));
|
||||
stack.getItem().onItemUse(stack, this.entity, this.entity.worldObj, pos, side, offsetX, offsetY, offsetZ);
|
||||
if(stack.isEmpty())
|
||||
this.entity.inventory.mainInventory[this.entity.inventory.currentItem] = null;
|
||||
this.entity.openContainer.detectAndSendChanges();
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1333,8 +1339,7 @@ public class Player extends User implements Executor, IPlayer
|
|||
}
|
||||
|
||||
private boolean onPlayerInteract(boolean primary, BlockPos pos) {
|
||||
if(this.isAdmin() && this.entity.getCurrentEquippedItem() != null &&
|
||||
this.entity.getCurrentEquippedItem().getItem().onAction(this.entity.getCurrentEquippedItem(), this.entity, this.entity.worldObj, primary ? ItemControl.PRIMARY : ItemControl.SECONDARY, pos))
|
||||
if(this.entity.getCurrentEquippedItem() != null && this.entity.getCurrentEquippedItem().getItem().onAction(this.entity.getCurrentEquippedItem(), this.entity, this.entity.worldObj, primary ? ItemControl.PRIMARY : ItemControl.SECONDARY, pos))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
@ -2662,9 +2667,13 @@ public class Player extends User implements Executor, IPlayer
|
|||
|
||||
case ITEM_ACTION:
|
||||
ItemStack item = this.entity.getCurrentEquippedItem();
|
||||
if(item != null)
|
||||
if(item != null) {
|
||||
item.getItem().onAction(item, this.entity, this.entity.worldObj,
|
||||
ItemControl.values()[packetIn.getAuxData() % ItemControl.values().length], null);
|
||||
if(item.isEmpty())
|
||||
this.entity.inventory.mainInventory[this.entity.inventory.currentItem] = null;
|
||||
this.entity.openContainer.detectAndSendChanges();
|
||||
}
|
||||
break;
|
||||
|
||||
case GOD:
|
||||
|
@ -2707,13 +2716,32 @@ public class Player extends User implements Executor, IPlayer
|
|||
break;
|
||||
|
||||
case REPAIR:
|
||||
if(this.isAdmin() && this.entity.getCurrentEquippedItem() != null) {
|
||||
ItemStack itemstack = this.entity.getCurrentEquippedItem();
|
||||
int diff = itemstack.getMaxStackSize() - itemstack.getSize();
|
||||
itemstack.setSize(itemstack.getMaxStackSize());
|
||||
itemstack.setRepairCost(0);
|
||||
if(itemstack.getItem().getMaxDamage() > 0)
|
||||
itemstack.setItemDamage(0);
|
||||
if(this.isAdmin()) {
|
||||
if(packetIn.getAuxData() != 0) {
|
||||
for(ItemStack stack : this.entity.inventory.mainInventory) {
|
||||
if(stack != null) {
|
||||
stack.setSize(stack.getMaxStackSize());
|
||||
stack.setRepairCost(0);
|
||||
if(stack.getItem().getMaxDamage() > 0)
|
||||
stack.setItemDamage(0);
|
||||
}
|
||||
}
|
||||
for(ItemStack stack : this.entity.inventory.armorInventory) {
|
||||
if(stack != null) {
|
||||
stack.setSize(stack.getMaxStackSize());
|
||||
stack.setRepairCost(0);
|
||||
if(stack.getItem().getMaxDamage() > 0)
|
||||
stack.setItemDamage(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(this.entity.getCurrentEquippedItem() != null) {
|
||||
ItemStack stack = this.entity.getCurrentEquippedItem();
|
||||
stack.setSize(stack.getMaxStackSize());
|
||||
stack.setRepairCost(0);
|
||||
if(stack.getItem().getMaxDamage() > 0)
|
||||
stack.setItemDamage(0);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue