Skip to content

Commit

Permalink
import water bolt fixes from cyclic magic
Browse files Browse the repository at this point in the history
  • Loading branch information
Lothrazar committed Mar 28, 2016
1 parent d0ecf57 commit d778d08
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 47 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ plugins {
id "net.minecraftforge.gradle.forge" version "2.0.2"
}
*/
version = "1.9-1.2.1"
version = "1.9-1.2.2"
group= "com.lothrazar.samsprojectiles"
archivesBaseName = "EnderProjectiles"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,17 @@
import java.util.ArrayList;
import net.minecraft.block.Block;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.monster.EntityBlaze;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.projectile.EntityThrowable;
import net.minecraft.init.Blocks;
import net.minecraft.util.DamageSource;
import net.minecraft.init.SoundEvents;
import net.minecraft.util.SoundCategory;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.world.World;

public class EntityWaterBolt extends EntityThrowable{

public static int secondsFrozenOnHit;
public static int damageToNormal = 0;// TODO CONFIG
public static int damageToBlaze = 2;// TODO CONFIG

public EntityWaterBolt(World worldIn){

super(worldIn);
Expand All @@ -32,68 +28,72 @@ public EntityWaterBolt(World worldIn, double x, double y, double z){

super(worldIn, x, y, z);
}


public static final int nether = -1;
@Override
protected void onImpact(RayTraceResult mop){

if(mop.entityHit != null){
float damage = damageToNormal;

if(mop.entityHit instanceof EntityBlaze){
damage = damageToBlaze;// TODO: config file blaze damage
}

// do the snowball damage, which should be none. put out the fire
mop.entityHit.attackEntityFrom(DamageSource.causeThrownDamage(this, this.getThrower()), damage);


if(mop.entityHit instanceof EntityLivingBase){
EntityLivingBase e = (EntityLivingBase) mop.entityHit;

if(e.isBurning()){
e.extinguish();
}

// e.addPotionEffect(new PotionEffect(PotionRegistry.frozen.id, secondsFrozenOnHit
// * Reference.TICKS_PER_SEC,0));
}
}

BlockPos pos = mop.getBlockPos();
BlockPos offset = null;

if(pos == null){
return;
}// hasn't happened yet, but..
pos = this.getPosition();
}

ArrayList<Block> waterBoth = new ArrayList<Block>();
waterBoth.add(Blocks.flowing_water);
waterBoth.add(Blocks.water);
// Util.spawnParticle(this.worldObj, EnumParticleTypes.SNOWBALL, pos);
// Util.spawnParticle(this.worldObj, EnumParticleTypes.SNOW_SHOVEL, pos);
if(pos != null){
//UtilParticle.spawnParticle(this.worldObj, EnumParticleTypes.WATER_SPLASH, pos);

if(mop.sideHit != null && this.getThrower() instanceof EntityPlayer){
this.worldObj.extinguishFire((EntityPlayer) this.getThrower(), pos, mop.sideHit);
if(this.getThrower() instanceof EntityPlayer && mop.sideHit != null && this.worldObj.isRemote == false){

offset = mop.getBlockPos().offset(mop.sideHit);
this.worldObj.extinguishFire((EntityPlayer) this.getThrower(), pos, mop.sideHit);
}
}

if(this.dimension != nether){

worldObj.playSound(pos.getX(), pos.getY(), pos.getZ(), SoundEvents.entity_player_splash, SoundCategory.PLAYERS, 1.0F, 1.0F, false);

Block hitBlock = this.worldObj.getBlockState(pos).getBlock();
// so far its both client and server
if(this.worldObj.isRemote == false){

if(waterBoth.contains(hitBlock)){
// turn flowing water into solid
this.worldObj.setBlockState(pos, Blocks.water.getDefaultState());
}
if(pos != null){

if(this.isInWater() == false){
if(this.worldObj.isAirBlock(pos)){
this.worldObj.setBlockState(pos, Blocks.water.getDefaultState());
}
else if(offset != null && this.worldObj.isAirBlock(mop.getBlockPos().offset(mop.sideHit))){
this.worldObj.setBlockState(mop.getBlockPos().offset(mop.sideHit), Blocks.water.getDefaultState());
if(this.isAirOrWater(pos)){

this.worldObj.setBlockState(pos, Blocks.flowing_water.getDefaultState(), 3);
}
if(mop.sideHit != null){
BlockPos offset = pos.offset(mop.sideHit);

if(offset != null && this.isAirOrWater(offset)){

this.worldObj.setBlockState(offset, Blocks.flowing_water.getDefaultState(), 3);
}
}
}
}
}

this.setDead();
}

private boolean isAirOrWater(BlockPos pos){

ArrayList<Block> waterBoth = new ArrayList<Block>();
waterBoth.add(Blocks.flowing_water);
waterBoth.add(Blocks.water);
if(pos == null){
return false;
}
return this.worldObj.isAirBlock(pos) || this.worldObj.getBlockState(pos).getBlock().getUnlocalizedName().equalsIgnoreCase("tile.water") || (this.worldObj.getBlockState(pos) != null && waterBoth.contains(this.worldObj.getBlockState(pos).getBlock()));
}
}
2 changes: 1 addition & 1 deletion src/main/resources/mcmod.info
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"modid": "samsprojectiles",
"name": "Ender Projectiles",
"description": "Adds tons of throwable items: Bombs, lightning, water, snow that lands on the ground, throwing torches, a dungeonfinder, and a ruby that sends you home.",
"version": "1.2.1",
"version": "1.2.2",
"mcversion": "1.9",
"url": "http://www.curse.com/mc-mods/minecraft/232155-ender-projectiles-adds-throwable-items-including",
"updateUrl": "",
Expand Down
7 changes: 5 additions & 2 deletions update.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@
"1.8.8-recommended": "1.2.1",
"1.8.9-latest": "1.2.1",
"1.8.9-recommended": "1.2.1",
"1.9-latest": "1.2.1",
"1.9-recommended": "1.2.1"
"1.9-latest": "1.2.2",
"1.9-recommended": "1.2.2"
}
,"1.9":{
"1.2.2":"Dungeon eye less glitchy and more particles so you can follow it."
}
}

0 comments on commit d778d08

Please sign in to comment.