-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
308 additions
and
58 deletions.
There are no files selected for viewing
119 changes: 119 additions & 0 deletions
119
src/main/java/mod/emt/harkenscythe/entities/HSEntitySpectralPotion.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
package mod.emt.harkenscythe.entities; | ||
|
||
import mod.emt.harkenscythe.init.HSItems; | ||
import mod.emt.harkenscythe.items.HSItemSpectralPotion; | ||
import mod.emt.harkenscythe.potions.HSPotionFlame; | ||
import mod.emt.harkenscythe.potions.HSPotionWater; | ||
import net.minecraft.entity.EntityAreaEffectCloud; | ||
import net.minecraft.entity.EntityLivingBase; | ||
import net.minecraft.entity.projectile.EntityThrowable; | ||
import net.minecraft.init.Blocks; | ||
import net.minecraft.item.ItemStack; | ||
import net.minecraft.potion.PotionEffect; | ||
import net.minecraft.util.math.BlockPos; | ||
import net.minecraft.util.math.RayTraceResult; | ||
import net.minecraft.world.World; | ||
|
||
public class HSEntitySpectralPotion extends EntityThrowable | ||
{ | ||
private PotionEffect potionEffect; | ||
private ItemStack potionStack = new ItemStack(HSItems.spectral_glass_bottle); | ||
|
||
public HSEntitySpectralPotion(World world) | ||
{ | ||
super(world); | ||
} | ||
|
||
public HSEntitySpectralPotion(World world, double x, double y, double z) | ||
{ | ||
super(world, x, y, z); | ||
} | ||
|
||
public HSEntitySpectralPotion(World world, EntityLivingBase thrower) | ||
{ | ||
super(world, thrower); | ||
} | ||
|
||
public HSEntitySpectralPotion(World world, EntityLivingBase thrower, ItemStack potionStack) | ||
{ | ||
super(world, thrower); | ||
if (potionStack.getItem() instanceof HSItemSpectralPotion) | ||
{ | ||
this.potionEffect = ((HSItemSpectralPotion) potionStack.getItem()).getPotionEffect(); | ||
this.potionStack = potionStack; | ||
} | ||
} | ||
|
||
public ItemStack getPotionStack() | ||
{ | ||
return potionStack; | ||
} | ||
|
||
public PotionEffect getPotionEffect() | ||
{ | ||
return potionEffect; | ||
} | ||
|
||
@Override | ||
protected float getGravityVelocity() | ||
{ | ||
return 0.07F; | ||
} | ||
|
||
@Override | ||
protected void onImpact(RayTraceResult result) | ||
{ | ||
if (!this.world.isRemote) | ||
{ | ||
if (potionEffect.getPotion() instanceof HSPotionFlame) | ||
{ | ||
this.world.playEvent(2002, new BlockPos(this), potionEffect.getPotion().getLiquidColor()); | ||
for (int x = -1; x <= 1; x++) | ||
{ | ||
for (int y = 0; y <= 2; y++) | ||
{ | ||
for (int z = -1; z <= 1; z++) | ||
{ | ||
BlockPos pos = this.getPosition().add(x, y, z); | ||
if (world.isAirBlock(pos)) | ||
{ | ||
world.setBlockState(pos, Blocks.FIRE.getDefaultState()); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
else if (potionEffect.getPotion() instanceof HSPotionWater) | ||
{ | ||
this.world.playEvent(2002, new BlockPos(this), potionEffect.getPotion().getLiquidColor()); | ||
for (int x = -1; x <= 1; x++) | ||
{ | ||
for (int y = 0; y <= 2; y++) | ||
{ | ||
for (int z = -1; z <= 1; z++) | ||
{ | ||
BlockPos pos = this.getPosition().add(x, y, z); | ||
if (world.getBlockState(pos).getBlock() == Blocks.FIRE) | ||
{ | ||
world.setBlockToAir(pos); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
else if (potionEffect != null) | ||
{ | ||
this.world.playEvent(2002, new BlockPos(this), potionEffect.getPotion().getLiquidColor()); | ||
EntityAreaEffectCloud effectCloud = new EntityAreaEffectCloud(this.world, this.posX, this.posY, this.posZ); | ||
effectCloud.setRadius(3.0F); | ||
effectCloud.setRadiusOnUse(-0.5F); | ||
effectCloud.setWaitTime(10); | ||
effectCloud.setDuration(effectCloud.getDuration() / 2); | ||
effectCloud.setRadiusPerTick(-effectCloud.getRadius() / (float) effectCloud.getDuration()); | ||
effectCloud.addEffect(potionEffect); | ||
this.world.spawnEntity(effectCloud); | ||
} | ||
this.setDead(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
src/main/java/mod/emt/harkenscythe/items/HSItemSpectralBottle.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package mod.emt.harkenscythe.items; | ||
|
||
import mod.emt.harkenscythe.init.HSItems; | ||
import net.minecraft.block.material.Material; | ||
import net.minecraft.block.state.IBlockState; | ||
import net.minecraft.entity.player.EntityPlayer; | ||
import net.minecraft.init.Blocks; | ||
import net.minecraft.init.SoundEvents; | ||
import net.minecraft.item.EnumRarity; | ||
import net.minecraft.item.ItemStack; | ||
import net.minecraft.stats.StatList; | ||
import net.minecraft.util.ActionResult; | ||
import net.minecraft.util.EnumActionResult; | ||
import net.minecraft.util.EnumHand; | ||
import net.minecraft.util.SoundCategory; | ||
import net.minecraft.util.math.BlockPos; | ||
import net.minecraft.util.math.RayTraceResult; | ||
import net.minecraft.world.World; | ||
|
||
public class HSItemSpectralBottle extends HSItem | ||
{ | ||
public HSItemSpectralBottle(EnumRarity rarity) | ||
{ | ||
super(rarity); | ||
this.setMaxStackSize(16); | ||
} | ||
|
||
@Override | ||
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) | ||
{ | ||
if (!world.isRemote) | ||
{ | ||
ItemStack itemStack = player.getHeldItem(hand); | ||
RayTraceResult rayTraceResult = this.rayTrace(world, player, true); | ||
if (rayTraceResult.typeOfHit == RayTraceResult.Type.BLOCK) | ||
{ | ||
BlockPos pos = rayTraceResult.getBlockPos(); | ||
IBlockState state = world.getBlockState(pos); | ||
IBlockState stateUp = world.getBlockState(pos.up()); | ||
if (state.getMaterial() == Material.WATER || stateUp.getMaterial() == Material.FIRE) | ||
{ | ||
if (stateUp.getMaterial() == Material.FIRE) world.setBlockState(pos.up(), Blocks.AIR.getDefaultState(), 11); | ||
itemStack.shrink(1); | ||
player.addItemStackToInventory(state.getMaterial() == Material.WATER ? new ItemStack(HSItems.spectral_potion_water) : new ItemStack(HSItems.spectral_potion_flame)); | ||
world.playSound(null, player.getPosition(), state.getMaterial() == Material.WATER ? SoundEvents.ITEM_BOTTLE_FILL : SoundEvents.ITEM_BOTTLE_FILL_DRAGONBREATH, SoundCategory.PLAYERS, 1.0F, 1.0F); | ||
player.addStat(StatList.getObjectUseStats(this)); | ||
return new ActionResult<>(EnumActionResult.SUCCESS, player.getHeldItem(hand)); | ||
} | ||
} | ||
} | ||
return new ActionResult<>(EnumActionResult.PASS, player.getHeldItem(hand)); | ||
} | ||
} |
71 changes: 71 additions & 0 deletions
71
src/main/java/mod/emt/harkenscythe/items/HSItemSpectralPotion.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
package mod.emt.harkenscythe.items; | ||
|
||
import mod.emt.harkenscythe.entities.HSEntitySpectralPotion; | ||
import net.minecraft.client.renderer.color.IItemColor; | ||
import net.minecraft.entity.player.EntityPlayer; | ||
import net.minecraft.init.SoundEvents; | ||
import net.minecraft.item.EnumRarity; | ||
import net.minecraft.item.ItemStack; | ||
import net.minecraft.potion.Potion; | ||
import net.minecraft.potion.PotionEffect; | ||
import net.minecraft.stats.StatList; | ||
import net.minecraft.util.ActionResult; | ||
import net.minecraft.util.EnumActionResult; | ||
import net.minecraft.util.EnumHand; | ||
import net.minecraft.util.SoundCategory; | ||
import net.minecraft.world.World; | ||
import net.minecraftforge.fml.relauncher.Side; | ||
import net.minecraftforge.fml.relauncher.SideOnly; | ||
|
||
public class HSItemSpectralPotion extends HSItem implements IItemColor | ||
{ | ||
private final PotionEffect potionEffect; | ||
|
||
public HSItemSpectralPotion(EnumRarity rarity, Potion potion) | ||
{ | ||
super(rarity); | ||
this.setMaxStackSize(1); | ||
this.potionEffect = new PotionEffect(potion, 600); | ||
} | ||
|
||
public PotionEffect getPotionEffect() | ||
{ | ||
return potionEffect; | ||
} | ||
|
||
@Override | ||
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) | ||
{ | ||
ItemStack itemStack = player.getHeldItem(hand); | ||
|
||
if (!player.isCreative()) | ||
{ | ||
itemStack.shrink(1); | ||
} | ||
|
||
world.playSound(null, player.posX, player.posY, player.posZ, SoundEvents.ENTITY_LINGERINGPOTION_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F)); | ||
|
||
if (!world.isRemote) | ||
{ | ||
HSEntitySpectralPotion spectralPotion = new HSEntitySpectralPotion(world, player, itemStack); | ||
spectralPotion.shoot(player, player.rotationPitch, player.rotationYaw, -20.0F, 0.7F, 1.0F); | ||
world.spawnEntity(spectralPotion); | ||
} | ||
|
||
player.addStat(StatList.getObjectUseStats(this)); | ||
return new ActionResult<>(EnumActionResult.SUCCESS, itemStack); | ||
} | ||
|
||
@SideOnly(Side.CLIENT) | ||
@Override | ||
public boolean hasEffect(ItemStack stack) | ||
{ | ||
return true; | ||
} | ||
|
||
@Override | ||
public int colorMultiplier(ItemStack stack, int tintIndex) | ||
{ | ||
return tintIndex > 0 ? -1 : getPotionEffect().getPotion().getLiquidColor(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.