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,52 +1,51 @@
package electroblob.wizardry.spell;
import electroblob.wizardry.constants.Element;
import electroblob.wizardry.constants.SpellType;
import electroblob.wizardry.constants.Tier;
import electroblob.wizardry.registry.WizardryAdvancementTriggers;
import electroblob.wizardry.Wizardry;
import electroblob.wizardry.util.SpellModifiers;
import electroblob.wizardry.util.WizardryUtilities;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.effect.EntityLightningBolt;
import net.minecraft.entity.monster.EntityCreeper;
import net.minecraft.entity.passive.EntityPig;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.EnumAction;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.World;
import net.minecraftforge.event.entity.EntityStruckByLightningEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
@Mod.EventBusSubscriber
//@Mod.EventBusSubscriber
public class LightningBolt extends SpellRay {
/** The NBT key used to store the UUID of the player that summoned the lightning bolt. Used for achievements. */
public static final String NBT_KEY = "summoningPlayer";
public LightningBolt(){
super("lightning_bolt", Tier.ADVANCED, Element.LIGHTNING, SpellType.ATTACK, 40, 80, false, 200, null);
this.ignoreEntities(true);
super("lightning_bolt", false, EnumAction.NONE);
this.ignoreLivingEntities(true);
}
@Override public boolean doesSpellRequirePacket(){ return false; }
@Override public boolean requiresPacket(){ return false; }
@Override
protected boolean onEntityHit(World world, Entity target, EntityLivingBase caster, int ticksInUse, SpellModifiers modifiers){
protected boolean onEntityHit(World world, Entity target, Vec3d hit, EntityLivingBase caster, Vec3d origin, int ticksInUse, SpellModifiers modifiers){
return false;
}
@Override
protected boolean onBlockHit(World world, BlockPos pos, EnumFacing side, EntityLivingBase caster, int ticksInUse, SpellModifiers modifiers){
protected boolean onBlockHit(World world, BlockPos pos, EnumFacing side, Vec3d hit, EntityLivingBase caster, Vec3d origin, int ticksInUse, SpellModifiers modifiers){
if(world.canBlockSeeSky(pos.up())){
if(!world.isRemote){
// Temporarily disable the fire tick gamerule if player block damage is disabled
// Bit of a hack but it works fine!
boolean doFireTick = world.getGameRules().getBoolean("doFireTick");
if(doFireTick && !Wizardry.settings.playerBlockDamage) world.getGameRules().setOrCreateGameRule("doFireTick", "false");
EntityLightningBolt entitylightning = new EntityLightningBolt(world, pos.getX(), pos.getY(),
pos.getZ(), false);
world.addWeatherEffect(entitylightning);
// Reset doFireTick to true if it was true before
if(doFireTick && !Wizardry.settings.playerBlockDamage) world.getGameRules().setOrCreateGameRule("doFireTick", "true");
// Code for eventhandler recognition for achievements
if(caster instanceof EntityPlayer){
@@ -62,26 +61,26 @@ public class LightningBolt extends SpellRay {
}
@Override
protected boolean onMiss(World world, EntityLivingBase caster, int ticksInUse, SpellModifiers modifiers){
protected boolean onMiss(World world, EntityLivingBase caster, Vec3d origin, Vec3d direction, int ticksInUse, SpellModifiers modifiers){
return false;
}
@SubscribeEvent
public static void onEntityStruckByLightningEvent(EntityStruckByLightningEvent event){
if(event.getLightning().getEntityData() != null && event.getLightning().getEntityData().hasUniqueId(NBT_KEY)){
EntityPlayer player = (EntityPlayer)WizardryUtilities.getEntityByUUID(event.getLightning().world,
event.getLightning().getEntityData().getUniqueId("summoningPlayer"));
if(event.getEntity() instanceof EntityCreeper){
WizardryAdvancementTriggers.charge_creeper.triggerFor(player);
}
if(event.getEntity() instanceof EntityPig){
WizardryAdvancementTriggers.frankenstein.triggerFor(player);
}
}
}
// @SubscribeEvent
// public static void onEntityStruckByLightningEvent(EntityStruckByLightningEvent event){
//
// if(event.getLightning().getEntityData() != null && event.getLightning().getEntityData().hasUniqueId(NBT_KEY)){
//
// EntityPlayer player = (EntityPlayer)WizardryUtilities.getEntityByUUID(event.getLightning().world,
// event.getLightning().getEntityData().getUniqueId("summoningPlayer"));
//
// if(event.getEntity() instanceof EntityCreeper){
// WizardryAdvancementTriggers.charge_creeper.triggerFor(player);
// }
//
// if(event.getEntity() instanceof EntityPig){
// WizardryAdvancementTriggers.frankenstein.triggerFor(player);
// }
// }
// }
}