Initial 1.11.2 update
This commit is contained in:
@@ -8,16 +8,18 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
|
||||
/**
|
||||
* Interface for potion effects that spawn custom particles instead of (or as well as) the vanilla 'swirly' particles.
|
||||
*
|
||||
* @author Electroblob
|
||||
* @since Wizardry 1.2
|
||||
*/
|
||||
// TODO: Backport.
|
||||
@Mod.EventBusSubscriber
|
||||
public interface ICustomPotionParticles {
|
||||
|
||||
|
||||
/**
|
||||
* Called from the event handler to spawn a <b>single</b> custom potion particle. To get an instance of
|
||||
* <code>Random</code> inside this method, use <code>world.rand</code>.
|
||||
*
|
||||
* @param world The world to spawn the particle in.
|
||||
* @param x The x coordinate of the particle, already set to a random value within the entity's bounding box.
|
||||
* @param y The y coordinate of the particle, already set to a random value within the entity's bounding box.
|
||||
@@ -27,17 +29,21 @@ public interface ICustomPotionParticles {
|
||||
|
||||
@SubscribeEvent
|
||||
public static void onLivingUpdateEvent(LivingUpdateEvent event){
|
||||
if(event.getEntityLiving().worldObj.isRemote){
|
||||
if(event.getEntityLiving().world.isRemote){
|
||||
// Behold the power of interfaces!
|
||||
for(PotionEffect effect : event.getEntityLiving().getActivePotionEffects()){
|
||||
|
||||
if(effect.getPotion() instanceof ICustomPotionParticles && effect.doesShowParticles()){
|
||||
|
||||
double x = event.getEntityLiving().posX + (event.getEntityLiving().worldObj.rand.nextDouble() - 0.5)*event.getEntityLiving().width;
|
||||
double y = event.getEntityLiving().getEntityBoundingBox().minY + event.getEntityLiving().worldObj.rand.nextDouble()*event.getEntityLiving().height;
|
||||
double z = event.getEntityLiving().posZ + (event.getEntityLiving().worldObj.rand.nextDouble() - 0.5)*event.getEntityLiving().width;
|
||||
double x = event.getEntityLiving().posX
|
||||
+ (event.getEntityLiving().world.rand.nextDouble() - 0.5) * event.getEntityLiving().width;
|
||||
double y = event.getEntityLiving().getEntityBoundingBox().minY
|
||||
+ event.getEntityLiving().world.rand.nextDouble() * event.getEntityLiving().height;
|
||||
double z = event.getEntityLiving().posZ
|
||||
+ (event.getEntityLiving().world.rand.nextDouble() - 0.5) * event.getEntityLiving().width;
|
||||
|
||||
((ICustomPotionParticles)effect.getPotion()).spawnCustomParticle(event.getEntityLiving().worldObj, x, y, z);
|
||||
((ICustomPotionParticles)effect.getPotion()).spawnCustomParticle(event.getEntityLiving().world, x,
|
||||
y, z);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,32 +17,34 @@ import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
public class PotionDecay extends Potion {
|
||||
|
||||
|
||||
private static final ResourceLocation ICON = new ResourceLocation(Wizardry.MODID, "textures/gui/decay_icon.png");
|
||||
|
||||
public PotionDecay(boolean isBadEffect, int liquidColour) {
|
||||
public PotionDecay(boolean isBadEffect, int liquidColour){
|
||||
super(isBadEffect, liquidColour);
|
||||
// This needs to be here because registerPotionAttributeModifier doesn't like it if the potion has no name yet.
|
||||
this.setPotionName("potion.wizardry:decay");
|
||||
this.registerPotionAttributeModifier(SharedMonsterAttributes.MOVEMENT_SPEED, "85602e0b-4801-4a87-94f3-bf617c97014e", -Constants.DECAY_SLOWNESS_PER_LEVEL, 2);
|
||||
this.registerPotionAttributeModifier(SharedMonsterAttributes.MOVEMENT_SPEED,
|
||||
"85602e0b-4801-4a87-94f3-bf617c97014e", -Constants.DECAY_SLOWNESS_PER_LEVEL, 2);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isReady(int p_76397_1_, int p_76397_2_) {
|
||||
public boolean isReady(int p_76397_1_, int p_76397_2_){
|
||||
// Copied from the vanilla wither effect. It does the timing stuff. 25 is the number of ticks between hits at
|
||||
// amplifier 0
|
||||
int k = 25 >> p_76397_2_;
|
||||
return k > 0 ? p_76397_1_ % k == 0 : true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void performEffect(EntityLivingBase target, int strength) {
|
||||
|
||||
target.attackEntityFrom(DamageSource.wither, 1);
|
||||
|
||||
public void performEffect(EntityLivingBase target, int strength){
|
||||
|
||||
target.attackEntityFrom(DamageSource.WITHER, 1);
|
||||
|
||||
if(target.onGround && target.ticksExisted % Constants.DECAY_SPREAD_INTERVAL == 0){
|
||||
|
||||
List<Entity> entities = target.worldObj.getEntitiesWithinAABBExcludingEntity(target, target.getEntityBoundingBox());
|
||||
List<Entity> entities = target.world.getEntitiesWithinAABBExcludingEntity(target,
|
||||
target.getEntityBoundingBox());
|
||||
|
||||
boolean flag = true;
|
||||
|
||||
@@ -51,22 +53,23 @@ public class PotionDecay extends Potion {
|
||||
}
|
||||
|
||||
if(flag){
|
||||
// The victim spreading the decay is the 'caster' here, so that it can actually wear off, otherwise it just gets infected with its own decay and the effect lasts forever.
|
||||
target.worldObj.spawnEntityInWorld(new EntityDecay(target.worldObj, target.posX, target.posY, target.posZ, target));
|
||||
// The victim spreading the decay is the 'caster' here, so that it can actually wear off, otherwise it
|
||||
// just gets infected with its own decay and the effect lasts forever.
|
||||
target.world.spawnEntity(new EntityDecay(target.world, target.posX, target.posY, target.posZ, target));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void renderInventoryEffect(int x, int y, PotionEffect effect, net.minecraft.client.Minecraft mc) {
|
||||
mc.renderEngine.bindTexture(ICON);
|
||||
WizardryUtilities.drawTexturedRect(x + 6, y + 7, 0, 0, 18, 18, 18, 18);
|
||||
}
|
||||
|
||||
public void renderInventoryEffect(int x, int y, PotionEffect effect, net.minecraft.client.Minecraft mc){
|
||||
mc.renderEngine.bindTexture(ICON);
|
||||
WizardryUtilities.drawTexturedRect(x + 6, y + 7, 0, 0, 18, 18, 18, 18);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void renderHUDEffect(int x, int y, PotionEffect effect, net.minecraft.client.Minecraft mc, float alpha) {
|
||||
public void renderHUDEffect(int x, int y, PotionEffect effect, net.minecraft.client.Minecraft mc, float alpha){
|
||||
mc.renderEngine.bindTexture(ICON);
|
||||
WizardryUtilities.drawTexturedRect(x + 3, y + 3, 0, 0, 18, 18, 18, 18);
|
||||
}
|
||||
|
||||
@@ -19,38 +19,40 @@ import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
@Mod.EventBusSubscriber
|
||||
public class PotionFrost extends Potion implements ICustomPotionParticles {
|
||||
|
||||
|
||||
private static final ResourceLocation ICON = new ResourceLocation(Wizardry.MODID, "textures/gui/frost_icon.png");
|
||||
|
||||
public PotionFrost(boolean isBadEffect, int liquidColour) {
|
||||
public PotionFrost(boolean isBadEffect, int liquidColour){
|
||||
super(isBadEffect, liquidColour);
|
||||
// This needs to be here because registerPotionAttributeModifier doesn't like it if the potion has no name yet.
|
||||
this.setPotionName("potion.wizardry:frost");
|
||||
// With -0.5 as the 'amount', frost 1 slows the entity down by a half and frost 2 roots it to the spot
|
||||
this.registerPotionAttributeModifier(SharedMonsterAttributes.MOVEMENT_SPEED, "35dded48-2f19-4541-8510-b29e2dc2cd51", -Constants.FROST_SLOWNESS_PER_LEVEL, 2);
|
||||
this.registerPotionAttributeModifier(SharedMonsterAttributes.MOVEMENT_SPEED,
|
||||
"35dded48-2f19-4541-8510-b29e2dc2cd51", -Constants.FROST_SLOWNESS_PER_LEVEL, 2);
|
||||
// More UUIDs: 85602e0b-4801-4a87-94f3-bf617c97014e
|
||||
}
|
||||
|
||||
@Override
|
||||
public void performEffect(EntityLivingBase entitylivingbase, int strength) {
|
||||
public void performEffect(EntityLivingBase entitylivingbase, int strength){
|
||||
// Nothing here because this potion works on attribute modifiers.
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void spawnCustomParticle(World world, double x, double y, double z) {
|
||||
Wizardry.proxy.spawnParticle(WizardryParticleType.SNOW, world, x, y, z, 0, -0.02, 0, 15 + world.rand.nextInt(5));
|
||||
public void spawnCustomParticle(World world, double x, double y, double z){
|
||||
Wizardry.proxy.spawnParticle(WizardryParticleType.SNOW, world, x, y, z, 0, -0.02, 0,
|
||||
15 + world.rand.nextInt(5));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void renderInventoryEffect(int x, int y, PotionEffect effect, net.minecraft.client.Minecraft mc) {
|
||||
mc.renderEngine.bindTexture(ICON);
|
||||
WizardryUtilities.drawTexturedRect(x + 6, y + 7, 0, 0, 18, 18, 18, 18);
|
||||
}
|
||||
|
||||
public void renderInventoryEffect(int x, int y, PotionEffect effect, net.minecraft.client.Minecraft mc){
|
||||
mc.renderEngine.bindTexture(ICON);
|
||||
WizardryUtilities.drawTexturedRect(x + 6, y + 7, 0, 0, 18, 18, 18, 18);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void renderHUDEffect(int x, int y, PotionEffect effect, net.minecraft.client.Minecraft mc, float alpha) {
|
||||
public void renderHUDEffect(int x, int y, PotionEffect effect, net.minecraft.client.Minecraft mc, float alpha){
|
||||
mc.renderEngine.bindTexture(ICON);
|
||||
WizardryUtilities.drawTexturedRect(x + 3, y + 3, 0, 0, 18, 18, 18, 18);
|
||||
}
|
||||
@@ -59,7 +61,8 @@ public class PotionFrost extends Potion implements ICustomPotionParticles {
|
||||
public static void onBreakSpeedEvent(BreakSpeed event){
|
||||
if(event.getEntityPlayer().isPotionActive(WizardryPotions.frost)){
|
||||
// Amplifier + 1 because it starts at 0
|
||||
event.setNewSpeed(event.getOriginalSpeed() * (1 - Constants.FROST_FATIGUE_PER_LEVEL*(event.getEntityPlayer().getActivePotionEffect(WizardryPotions.frost).getAmplifier() + 1)));
|
||||
event.setNewSpeed(event.getOriginalSpeed() * (1 - Constants.FROST_FATIGUE_PER_LEVEL
|
||||
* (event.getEntityPlayer().getActivePotionEffect(WizardryPotions.frost).getAmplifier() + 1)));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -11,32 +11,34 @@ import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
|
||||
/** Class for all potions that work on events only. */
|
||||
public class PotionMagicEffect extends Potion {
|
||||
|
||||
|
||||
private static final ResourceLocation ICONS = new ResourceLocation(Wizardry.MODID, "textures/gui/potion_icons.png");
|
||||
private final int textureIndex;
|
||||
|
||||
public PotionMagicEffect(boolean isBadEffect, int liquidColour, int textureIndex) {
|
||||
|
||||
public PotionMagicEffect(boolean isBadEffect, int liquidColour, int textureIndex){
|
||||
super(isBadEffect, liquidColour);
|
||||
this.textureIndex = textureIndex;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void performEffect(EntityLivingBase entitylivingbase, int strength) {
|
||||
public void performEffect(EntityLivingBase entitylivingbase, int strength){
|
||||
// Nothing here because this potion works on events.
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void renderInventoryEffect(int x, int y, PotionEffect effect, net.minecraft.client.Minecraft mc){
|
||||
mc.renderEngine.bindTexture(ICONS);
|
||||
WizardryUtilities.drawTexturedRect(x + 6, y + 7, 18*(textureIndex%4), 18*(textureIndex/4), 18, 18, 72, 72);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void renderHUDEffect(int x, int y, PotionEffect effect, net.minecraft.client.Minecraft mc, float alpha) {
|
||||
public void renderInventoryEffect(int x, int y, PotionEffect effect, net.minecraft.client.Minecraft mc){
|
||||
mc.renderEngine.bindTexture(ICONS);
|
||||
WizardryUtilities.drawTexturedRect(x + 3, y + 3, 18*(textureIndex%4), 18*(textureIndex/4), 18, 18, 72, 72);
|
||||
WizardryUtilities.drawTexturedRect(x + 6, y + 7, 18 * (textureIndex % 4), 18 * (textureIndex / 4), 18, 18, 72,
|
||||
72);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void renderHUDEffect(int x, int y, PotionEffect effect, net.minecraft.client.Minecraft mc, float alpha){
|
||||
mc.renderEngine.bindTexture(ICONS);
|
||||
WizardryUtilities.drawTexturedRect(x + 3, y + 3, 18 * (textureIndex % 4), 18 * (textureIndex / 4), 18, 18, 72,
|
||||
72);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
package electroblob.wizardry.potion;
|
||||
|
||||
/** Same as {@link PotionMagicEffect}, but also implements {@link ICustomPotionParticles} to allow anonymous classes
|
||||
* to extend it and add their own particles. */
|
||||
/**
|
||||
* Same as {@link PotionMagicEffect}, but also implements {@link ICustomPotionParticles} to allow anonymous classes to
|
||||
* extend it and add their own particles.
|
||||
*/
|
||||
public abstract class PotionMagicEffectParticles extends PotionMagicEffect implements ICustomPotionParticles {
|
||||
|
||||
public PotionMagicEffectParticles(boolean isBadEffect, int liquidColour, int textureIndex){
|
||||
|
||||
Reference in New Issue
Block a user