That's one heck of a commit you've got there...

I may have got a bit behind with version control. A lot behind, in fact. Maybe I'll go back and split this sometime - then again, I probably won't. But hey, at least it's here!
This commit is contained in:
Electroblob77
2019-08-18 00:04:18 +01:00
parent 2680d02304
commit f37812be3e
1564 changed files with 47652 additions and 12984 deletions
@@ -1,46 +1,63 @@
package electroblob.wizardry.spell;
import electroblob.wizardry.constants.Element;
import electroblob.wizardry.constants.SpellType;
import electroblob.wizardry.constants.Tier;
import electroblob.wizardry.Wizardry;
import electroblob.wizardry.registry.WizardryItems;
import electroblob.wizardry.util.SpellModifiers;
import electroblob.wizardry.util.WizardryUtilities;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.projectile.EntityWitherSkull;
import net.minecraft.init.SoundEvents;
import net.minecraft.item.EnumAction;
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.World;
import net.minecraftforge.event.entity.EntityMobGriefingEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.eventhandler.Event;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
@Mod.EventBusSubscriber
public class WitherSkull extends Spell {
public static final String ACCELERATION = "acceleration";
public WitherSkull(){
super("wither_skull", Tier.ADVANCED, Element.NECROMANCY, SpellType.ATTACK, 20, 30, EnumAction.NONE, false);
super("wither_skull", EnumAction.NONE, false);
addProperties(ACCELERATION);
soundValues(1, 1.1f, 0.2f);
}
@Override
public boolean doesSpellRequirePacket(){
public boolean requiresPacket(){
return false;
}
@Override
public boolean canBeCastByNPCs(){
return true;
}
@Override
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){
Vec3d look = caster.getLookVec();
if(!world.isRemote){
EntityWitherSkull witherskull = new EntityWitherSkull(world, caster, 1, 1, 1);
witherskull.setPosition(caster.posX + look.x, caster.posY + look.y + 1.3,
caster.posZ + look.z);
witherskull.accelerationX = look.x * 0.1;
witherskull.accelerationY = look.y * 0.1;
witherskull.accelerationZ = look.z * 0.1;
witherskull.setPosition(caster.posX + look.x, caster.posY + look.y + 1.3, caster.posZ + look.z);
double acceleration = getProperty(ACCELERATION).doubleValue() * modifiers.get(WizardryItems.range_upgrade);
witherskull.accelerationX = look.x * acceleration;
witherskull.accelerationY = look.y * acceleration;
witherskull.accelerationZ = look.z * acceleration;
witherskull.shootingEntity = caster;
world.spawnEntity(witherskull);
WizardryUtilities.playSoundAtPlayer(caster, SoundEvents.ENTITY_WITHER_SHOOT, 1.0F,
world.rand.nextFloat() * 0.2F + 1.0F);
this.playSound(world, caster, ticksInUse, -1, modifiers);
}
caster.swingArm(hand);
return true;
@@ -65,10 +82,11 @@ public class WitherSkull extends Spell {
witherskull.accelerationY = dy / caster.getDistance(target) * 0.1;
witherskull.accelerationZ = dz / caster.getDistance(target) * 0.1;
witherskull.shootingEntity = caster;
witherskull.setPosition(caster.posX, caster.posY + caster.getEyeHeight(), caster.posZ);
world.spawnEntity(witherskull);
caster.playSound(SoundEvents.ENTITY_WITHER_SHOOT, 1.0F, world.rand.nextFloat() * 0.2F + 1.0F);
this.playSound(world, caster, ticksInUse, -1, modifiers);
}
caster.swingArm(hand);
@@ -78,9 +96,12 @@ public class WitherSkull extends Spell {
return false;
}
@Override
public boolean canBeCastByNPCs(){
return true;
@SubscribeEvent
public static void onEntityMobGriefingEvent(EntityMobGriefingEvent event){
if(event.getEntity() instanceof EntityPlayer){
// If a player shot the wither skull, it should ignore the mob griefing gamerule and use playerBlockDamage instead
event.setResult(Wizardry.settings.playerBlockDamage ? Event.Result.ALLOW : Event.Result.DENY);
}
}
}