Made inebriation into a potion effect.

This commit is contained in:
bconlon 2020-07-20 21:41:01 -07:00
parent 58a0fce9e9
commit cdb80bf1f2
16 changed files with 344 additions and 182 deletions

View file

@ -27,6 +27,8 @@ public class AetherConfig {
private static boolean legacy_altar_name;
private static int inebriation_id;
public static void init(File location) {
File newFile = new File(location + "/aether" + "/AetherI.cfg");
@ -64,6 +66,8 @@ public class AetherConfig {
legacy_altar_name = config.get("Misc", "Changes whether the Altar should be named Enchanter or not.", false).getBoolean(false);
inebriation_id = config.get("Misc", "Sets the id for the Inebriation effect.", 31).getInt(31);
config.save();
}
@ -130,4 +134,9 @@ public class AetherConfig {
public static boolean legacyAltarName() {
return AetherConfig.legacy_altar_name;
}
public static int getInebriationId()
{
return AetherConfig.inebriation_id;
}
}

View file

@ -27,14 +27,6 @@ public interface IPlayerAether extends IExtendedEntityProperties {
public EntityLivingBase getEntity();
public void inflictPoison(int ticks);
public boolean isPoisoned();
public void inflictCure(int ticks);
public boolean isCured();
public boolean setHammerCooldown(int cooldown, String hammerName);
public String getHammerName();

View file

@ -38,11 +38,11 @@ public class AetherOverlay {
public static void renderPoison(Minecraft mc) {
PlayerAether playerAether = PlayerAether.get(mc.thePlayer);
if (playerAether.isPoisoned()) {
if (playerAether.poisonTime > 0) {
ScaledResolution scaledresolution = new ScaledResolution(mc, mc.displayWidth, mc.displayHeight);
Tessellator tessellator = Tessellator.instance;
float alpha = getPoisonAlpha((float) (playerAether.poisonMovement.ticks % 50) / 50);
float alpha = getPoisonAlpha((float) (playerAether.poisonTime % 50) / 50);
int width = scaledresolution.getScaledWidth();
int height = scaledresolution.getScaledHeight();

View file

@ -29,10 +29,6 @@ public class DartBaseRenderer extends Render {
return;
}
if (dart instanceof EntityDartPoison && ((EntityDartPoison) dart).victim != null) {
return;
}
this.bindEntityTexture(dart);
GL11.glPushMatrix();
GL11.glTranslatef((float) d, (float) d1, (float) d2);

View file

@ -0,0 +1,54 @@
package com.legacy.aether.entities.effects;
import com.legacy.aether.items.ItemsAether;
import com.legacy.aether.items.util.EnumSkyrootBucketType;
import net.minecraft.item.ItemStack;
import net.minecraft.potion.PotionEffect;
import java.util.ArrayList;
import java.util.List;
public class EffectInebriation extends PotionEffect
{
private List<ItemStack> curativeItems;
public EffectInebriation(int potionID, int duration, int amplifier)
{
this(potionID, duration, amplifier, false);
}
public EffectInebriation(int potionID, int duration, int amplifier, boolean isAmbient)
{
super(potionID, duration, amplifier, isAmbient);
this.curativeItems = new ArrayList<>();
this.curativeItems.add(new ItemStack(ItemsAether.skyroot_bucket, EnumSkyrootBucketType.Remedy.meta));
this.curativeItems.add(new ItemStack(ItemsAether.white_apple));
}
@Override
public List<ItemStack> getCurativeItems()
{
return this.curativeItems;
}
@Override
public boolean isCurativeItem(ItemStack stack)
{
boolean found = false;
for (ItemStack curativeItem : this.curativeItems)
{
if (curativeItem.isItemEqual(stack))
{
found = true;
}
}
return found;
}
@Override
public void setCurativeItems(List<ItemStack> curativeItems)
{
this.curativeItems = curativeItems;
}
}

View file

@ -0,0 +1,91 @@
package com.legacy.aether.entities.effects;
import com.legacy.aether.Aether;
import com.legacy.aether.AetherConfig;
import com.legacy.aether.api.AetherAPI;
import com.legacy.aether.network.AetherNetwork;
import com.legacy.aether.network.packets.PacketSendPoison;
import com.legacy.aether.player.PlayerAether;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.potion.Potion;
import net.minecraft.util.DamageSource;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.WorldServer;
public class PotionInebriation extends Potion
{
public static Potion inebriation = new PotionInebriation();
private int duration;
public double rotD, motD;
public PotionInebriation()
{
super(AetherConfig.getInebriationId(), true, 0x51297B);
this.duration = 0;
this.setPotionName("Inebriation");
this.setIconIndex(0, 0);
}
public boolean isReady(int duration, int amplifier)
{
this.duration = duration;
return true;
}
@Override
public void performEffect(EntityLivingBase entityLivingBaseIn, int amplifier)
{
this.distractEntity(entityLivingBaseIn);
if (this.duration % 50 == 0)
{
entityLivingBaseIn.attackEntityFrom(new DamageSource("inebriation"), 1.0F);
}
if (entityLivingBaseIn instanceof EntityPlayer)
{
if (this.duration >= 500)
{
((PlayerAether) AetherAPI.get((EntityPlayer) entityLivingBaseIn)).setPoisoned();
AetherNetwork.sendToAll(new PacketSendPoison((EntityPlayer) entityLivingBaseIn));
}
}
}
public void distractEntity(EntityLivingBase entityLivingBaseIn)
{
double gaussian = entityLivingBaseIn.worldObj.rand.nextGaussian();
double newMotD = 0.1D * gaussian;
double newRotD = (Math.PI / 4D) * gaussian;
this.motD = 0.2D * newMotD + (0.8D) * this.motD;
entityLivingBaseIn.motionX += this.motD;
entityLivingBaseIn.motionZ += this.motD;
this.rotD = 0.125D * newRotD + (1.0D - 0.125D) * this.rotD;
entityLivingBaseIn.rotationYaw = (float)((double)entityLivingBaseIn.rotationYaw + rotD);
entityLivingBaseIn.rotationPitch = (float)((double)entityLivingBaseIn.rotationPitch + rotD);
if (entityLivingBaseIn.worldObj instanceof WorldServer)
{
((WorldServer) entityLivingBaseIn.worldObj).func_147487_a("iconcrack_" + Item.getIdFromItem(Items.dye) + "_" + 1, entityLivingBaseIn.posX, entityLivingBaseIn.boundingBox.minY + entityLivingBaseIn.height * 0.8D, entityLivingBaseIn.posZ, 2, 0.0D, 0.0D, 0.0D, 0.0D);
}
}
@Override
@SideOnly(Side.CLIENT)
public int getStatusIconIndex()
{
Minecraft.getMinecraft().renderEngine.bindTexture(Aether.locate("textures/gui/inventory/inebriation.png"));
return super.getStatusIconIndex();
}
}

View file

@ -1,64 +0,0 @@
package com.legacy.aether.entities.movement;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.util.DamageSource;
public class AetherPoisonMovement {
public int ticks = 0;
public double rotD, motD;
private EntityLivingBase entity;
public AetherPoisonMovement(EntityLivingBase entity) {
this.entity = entity;
}
public void onUpdate() {
int timeUntilHit = this.ticks % 50;
if (this.entity.isDead) {
this.ticks = 0;
} else if (this.ticks < 0) {
this.ticks++;
} else if (this.ticks > 0) {
this.ticks--;
if (timeUntilHit == 0) {
this.entity.attackEntityFrom(causePoisonDamage(), 1.0F);
}
this.distractEntity();
}
}
public void inflictPoison(int ticks) {
if (this.ticks >= 0) {
this.ticks = ticks;
}
}
public void inflictCure(int ticks) {
this.ticks = -ticks;
}
public void distractEntity() {
double gaussian = this.entity.worldObj.rand.nextGaussian();
double newMotD = 0.1D * gaussian;
double newRotD = (Math.PI / 4D) * gaussian;
this.motD = 0.2D * newMotD + (0.8D) * this.motD;
this.entity.motionX += this.motD;
this.entity.motionZ += this.motD;
this.rotD = 0.125D * newRotD + (1.0D - 0.125D) * this.rotD;
this.entity.rotationYaw = (float) ((double) this.entity.rotationYaw + rotD);
this.entity.rotationPitch = (float) ((double) this.entity.rotationPitch + rotD);
}
public static DamageSource causePoisonDamage() {
return new DamageSource("aether_legacy.poison").setDamageBypassesArmor();
}
}

View file

@ -1,31 +1,17 @@
package com.legacy.aether.entities.projectile.darts;
import net.minecraft.entity.Entity;
import com.legacy.aether.entities.effects.EffectInebriation;
import com.legacy.aether.entities.effects.PotionInebriation;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.potion.PotionEffect;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World;
import net.minecraft.world.WorldServer;
import com.legacy.aether.api.player.util.IAetherBoss;
import com.legacy.aether.entities.hostile.EntityAechorPlant;
import com.legacy.aether.entities.hostile.EntityCockatrice;
import com.legacy.aether.entities.movement.AetherPoisonMovement;
import com.legacy.aether.items.ItemsAether;
import com.legacy.aether.network.AetherNetwork;
import com.legacy.aether.network.packets.PacketSendPoison;
import com.legacy.aether.player.PlayerAether;
public class EntityDartPoison extends EntityDartBase {
public EntityLivingBase victim;
public AetherPoisonMovement poison;
public EntityDartPoison(World worldIn) {
super(worldIn);
}
@ -39,58 +25,22 @@ public class EntityDartPoison extends EntityDartBase {
this.setDamage(0);
}
public void onUpdate() {
super.onUpdate();
if (this.victim != null) {
if (this.victim.isDead || this.poison.ticks == 0) {
this.setDead();
return;
}
if (this.getThrower() != null) {
if (this.getThrower().worldObj instanceof WorldServer) {
((WorldServer) this.getThrower().worldObj).func_147487_a("iconcrack_" + Item.getIdFromItem(Items.dye) + "_" + 1, this.victim.posX, this.victim.boundingBox.minY + this.victim.height * 0.8D, this.victim.posZ, 2, 0.0D, 0.0D, 0.0D, 0.0D);
}
}
this.isDead = false;
this.poison.onUpdate();
this.setInvisible(true);
this.setPosition(this.victim.posX, this.victim.posY, this.victim.posZ);
}
}
@Override
public void onCollideWithPlayer(EntityPlayer entity) {
if (this.victim == null) {
super.onCollideWithPlayer(entity);
}
}
@Override
public void onDartHit(MovingObjectPosition movingobjectposition) {
super.onDartHit(movingobjectposition);
if (movingobjectposition.entityHit instanceof EntityLivingBase) {
Entity entity = movingobjectposition.entityHit;
if (entity instanceof EntityPlayer) {
EntityPlayer ent = (EntityPlayer) entity;
if (!this.worldObj.isRemote) {
PlayerAether.get(ent).inflictPoison(500);
AetherNetwork.sendTo(new PacketSendPoison(), (EntityPlayerMP) ent);
if (!worldObj.isRemote)
{
if (movingobjectposition.entityHit != null)
{
if (movingobjectposition.entityHit instanceof EntityLivingBase)
{
((EntityLivingBase) movingobjectposition.entityHit).addPotionEffect(new EffectInebriation(PotionInebriation.inebriation.id, 500, 0));
}
} else if (!(entity instanceof IAetherBoss) && !(entity instanceof EntityCockatrice) && !(entity instanceof EntityAechorPlant)) {
this.victim = (EntityLivingBase) entity;
this.poison = new AetherPoisonMovement(this.victim);
this.poison.inflictPoison(500);
}
this.isDead = false;
}
this.isDead = false;
}
@Override

View file

@ -1,5 +1,6 @@
package com.legacy.aether.items.food;
import com.legacy.aether.items.ItemsAether;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
@ -16,7 +17,12 @@ public class ItemWhiteApple extends ItemAetherFood {
@Override
protected void onFoodEaten(ItemStack stack, World world, EntityPlayer player) {
PlayerAether.get(player).inflictCure(300);
}
PlayerAether.get(player).setCured(300);
if (!world.isRemote)
{
player.curePotionEffects(new ItemStack(ItemsAether.white_apple));
}
}
}

View file

@ -2,12 +2,15 @@ package com.legacy.aether.items.tools;
import java.util.List;
import com.legacy.aether.entities.effects.EffectInebriation;
import com.legacy.aether.entities.effects.PotionInebriation;
import javafx.print.PageLayout;
import net.minecraft.block.Block;
import net.minecraft.block.BlockCauldron;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
@ -15,6 +18,7 @@ import net.minecraft.item.EnumAction;
import net.minecraft.item.EnumRarity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.potion.PotionEffect;
import net.minecraft.stats.StatList;
import net.minecraft.util.IIcon;
import net.minecraft.util.MovingObjectPosition;
@ -316,9 +320,13 @@ public class ItemSkyrootBucket extends Item {
}
if (EnumSkyrootBucketType.getType(meta) == EnumSkyrootBucketType.Poison) {
player.inflictPoison(200);
entityplayer.addPotionEffect(new EffectInebriation(PotionInebriation.inebriation.id, 500, 0));
} else if (EnumSkyrootBucketType.getType(meta) == EnumSkyrootBucketType.Remedy) {
player.inflictCure(200);
player.setCured(200);
if (!world.isRemote)
{
entityplayer.curePotionEffects(new ItemStack(ItemsAether.skyroot_bucket, EnumSkyrootBucketType.Remedy.meta));
}
} else if (EnumSkyrootBucketType.getType(meta) == EnumSkyrootBucketType.Milk) {
if (!world.isRemote) {
entityplayer.curePotionEffects(new ItemStack(Items.milk_bucket));

View file

@ -27,6 +27,7 @@ public class AetherNetwork {
INSTANCE.registerMessage(PacketAchievement.class, PacketAchievement.class, discriminant++, Side.CLIENT);
INSTANCE.registerMessage(PacketSendPoison.class, PacketSendPoison.class, discriminant++, Side.CLIENT);
INSTANCE.registerMessage(PacketSendPoisonTime.class, PacketSendPoisonTime.class, discriminant++, Side.CLIENT);
INSTANCE.registerMessage(PacketInitiateValkyrieFight.class, PacketInitiateValkyrieFight.class, discriminant++, Side.SERVER);

View file

@ -1,5 +1,6 @@
package com.legacy.aether.network.packets;
import com.legacy.aether.api.AetherAPI;
import io.netty.buffer.ByteBuf;
import net.minecraft.entity.player.EntityPlayer;
@ -7,33 +8,47 @@ import com.legacy.aether.player.PlayerAether;
public class PacketSendPoison extends AetherPacket<PacketSendPoison> {
public PacketSendPoison() {
private int entityID;
public PacketSendPoison()
{
}
public PacketSendPoison(EntityPlayer thePlayer) {
public PacketSendPoison(EntityPlayer thePlayer)
{
this.entityID = thePlayer.getEntityId();
}
@Override
public void fromBytes(ByteBuf buf) {
public void fromBytes(ByteBuf buf)
{
this.entityID = buf.readInt();
}
@Override
public void toBytes(ByteBuf buf) {
public void toBytes(ByteBuf buf)
{
buf.writeInt(this.entityID);
}
@Override
public void handleClient(PacketSendPoison message, EntityPlayer player) {
if (player != null && player.worldObj != null) {
PlayerAether.get(player).inflictPoison(500);
public void handleClient(PacketSendPoison message, EntityPlayer player)
{
if (player != null && player.worldObj != null)
{
EntityPlayer parent = (EntityPlayer) player.worldObj.getEntityByID(message.entityID);
if (parent != null)
{
((PlayerAether) AetherAPI.get(parent)).setPoisoned();
}
}
}
@Override
public void handleServer(PacketSendPoison message, EntityPlayer player) {
public void handleServer(PacketSendPoison message, EntityPlayer player)
{
}

View file

@ -0,0 +1,57 @@
package com.legacy.aether.network.packets;
import com.legacy.aether.api.AetherAPI;
import com.legacy.aether.player.PlayerAether;
import io.netty.buffer.ByteBuf;
import net.minecraft.entity.player.EntityPlayer;
public class PacketSendPoisonTime extends AetherPacket<PacketSendPoisonTime>
{
private int entityID;
private int time;
public PacketSendPoisonTime()
{
}
public PacketSendPoisonTime(EntityPlayer thePlayer, int time)
{
this.entityID = thePlayer.getEntityId();
this.time = time;
}
@Override
public void fromBytes(ByteBuf buf)
{
this.entityID = buf.readInt();
this.time = buf.readInt();
}
@Override
public void toBytes(ByteBuf buf)
{
buf.writeInt(this.entityID);
buf.writeInt(this.time);
}
@Override
public void handleClient(PacketSendPoisonTime message, EntityPlayer player)
{
if (player != null && player.worldObj != null)
{
EntityPlayer parent = (EntityPlayer) player.worldObj.getEntityByID(message.entityID);
if (parent != null)
{
((PlayerAether) AetherAPI.get(parent)).poisonTime = message.time;
}
}
}
@Override
public void handleServer(PacketSendPoisonTime message, EntityPlayer player)
{
}
}

View file

@ -4,12 +4,12 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.UUID;
import com.legacy.aether.Aether;
import com.legacy.aether.entities.passive.mountable.EntityParachute;
import com.legacy.aether.items.ItemsAether;
import com.legacy.aether.network.AetherNetwork;
import com.legacy.aether.network.packets.PacketCapeChanged;
import com.legacy.aether.network.packets.PacketPerkChanged;
import com.legacy.aether.network.packets.PacketSendPoisonTime;
import com.legacy.aether.player.perks.AetherRankings;
import com.legacy.aether.player.perks.util.EnumAetherPerkType;
import net.minecraft.block.Block;
@ -35,7 +35,6 @@ import com.legacy.aether.api.player.util.IAccessoryInventory;
import com.legacy.aether.api.player.util.IAetherAbility;
import com.legacy.aether.api.player.util.IAetherBoss;
import com.legacy.aether.blocks.BlocksAether;
import com.legacy.aether.entities.movement.AetherPoisonMovement;
import com.legacy.aether.inventory.InventoryAccessories;
import com.legacy.aether.items.tools.ItemValkyrieTool;
import com.legacy.aether.player.abilities.AbilityAccessories;
@ -53,8 +52,6 @@ public class PlayerAether implements IPlayerAether {
private EntityPlayer player;
public AetherPoisonMovement poisonMovement;
private IAetherBoss focusedBoss;
private IAccessoryInventory accessories = new InventoryAccessories(this);
@ -95,6 +92,10 @@ public class PlayerAether implements IPlayerAether {
private ChunkCoordinates bedLocation;
public boolean isPoisoned = false, isCured = false;
public int poisonTime = 0, cureTime = 0;
public PlayerAether() {
this.shouldRenderHalo = true;
this.shouldRenderGlow = false;
@ -109,7 +110,6 @@ public class PlayerAether implements IPlayerAether {
@Override
public void init(Entity entity, World world) {
this.player = (EntityPlayer) entity;
this.poisonMovement = new AetherPoisonMovement(this.player);
}
@Override
@ -119,6 +119,33 @@ public class PlayerAether implements IPlayerAether {
AetherNetwork.sendToAll(new PacketPerkChanged(this.getEntity().getEntityId(), EnumAetherPerkType.Halo, this.shouldRenderHalo));
AetherNetwork.sendToAll(new PacketPerkChanged(this.getEntity().getEntityId(), EnumAetherPerkType.Glow, this.shouldRenderGlow));
AetherNetwork.sendToAll(new PacketCapeChanged(this.getEntity().getEntityId(), this.shouldRenderCape));
AetherNetwork.sendToAll(new PacketSendPoisonTime(this.getEntity(), this.poisonTime));
}
if (this.isPoisoned)
{
if (poisonTime > 0)
{
this.poisonTime--;
}
else
{
this.poisonTime = 0;
this.isPoisoned = false;
}
}
if (this.isCured)
{
if (cureTime > 0)
{
this.cureTime--;
}
else
{
this.cureTime = 0;
this.isCured = false;
}
}
for (int i = 0; i < this.getAbilities().size(); ++i) {
@ -162,8 +189,6 @@ public class PlayerAether implements IPlayerAether {
this.wingSinage += 0.1F;
}
this.poisonMovement.onUpdate();
boolean hasJumped = ReflectionHelper.getPrivateValue(EntityLivingBase.class, this.getEntity(), "isJumping", "field_70703_bu");
this.setJumping(hasJumped);
@ -400,6 +425,8 @@ public class PlayerAether implements IPlayerAether {
aetherTag.setBoolean("glow", this.shouldRenderGlow);
}
aetherTag.setBoolean("poisoned", this.isPoisoned);
aetherTag.setInteger("poison_time", this.poisonTime);
aetherTag.setBoolean("cape", this.shouldRenderCape);
aetherTag.setInteger("shardCount", this.shardCount);
aetherTag.setTag("accessories", this.getAccessoryInventory().writeToNBT(aetherTag));
@ -433,6 +460,16 @@ public class PlayerAether implements IPlayerAether {
this.shouldRenderCape = aetherTag.getBoolean("cape");
}
if (aetherTag.hasKey("poisoned"))
{
this.isPoisoned = aetherTag.getBoolean("poisoned");
}
if (aetherTag.hasKey("poison_time"))
{
this.poisonTime = aetherTag.getInteger("poison_time");
}
this.updateShardCount(aetherTag.getInteger("shardCount"));
this.getAccessoryInventory().readFromNBT(aetherTag.getTagList("accessories", 10));
this.setBedLocation(new ChunkCoordinates(aetherTag.getInteger("bedX"), aetherTag.getInteger("bedY"), aetherTag.getInteger("bedZ")));
@ -468,26 +505,6 @@ public class PlayerAether implements IPlayerAether {
return this.player;
}
@Override
public void inflictPoison(int ticks) {
this.poisonMovement.inflictPoison(ticks);
}
@Override
public boolean isPoisoned() {
return this.poisonMovement.ticks > 0;
}
@Override
public void inflictCure(int ticks) {
this.poisonMovement.inflictCure(ticks);
}
@Override
public boolean isCured() {
return this.poisonMovement.ticks < 0;
}
@Override
public void updateShardCount(int amount) {
UUID uuid = UUID.fromString("df6eabe7-6947-4a56-9099-002f90370706");
@ -573,4 +590,29 @@ public class PlayerAether implements IPlayerAether {
{
return bedLocation;
}
public boolean isPoisoned()
{
return this.isPoisoned;
}
public void setPoisoned()
{
this.isPoisoned = true;
this.poisonTime = 500;
}
public boolean isCured()
{
return this.isCured;
}
public void setCured(int time)
{
this.isCured = true;
this.cureTime = time;
this.isPoisoned = false;
this.poisonTime = 0;
}
}

View file

@ -75,6 +75,11 @@ public class PlayerAetherEvents {
AetherNetwork.sendTo(new PacketAccessory(playerAether), (EntityPlayerMP) event.player);
playerAether.updateShardCount(playerAether.getShardsUsed());
playerAether.isPoisoned = false;
playerAether.poisonTime = 0;
playerAether.isCured = false;
playerAether.cureTime = 0;
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB