Salis changes

This commit is contained in:
John Yorke committed 2021-12-21 19:10:58 -04:00
1 parent ffd6452063
commit 525649b0af
3 files changed
+69 -20

No files matched your search

@@ -1,18 +1,21 @@
package taintedmagic.common.items;
import java.util.List;
import java.util.Random;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.item.EnumRarity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import net.minecraft.world.World;
import taintedmagic.common.TaintedMagic;
import thaumcraft.client.fx.ParticleEngine;
import thaumcraft.client.fx.particles.FXSparkle;
public class ItemSalis extends Item {
@@ -58,25 +61,67 @@ public class ItemSalis extends Item {
}
@Override
public ItemStack onItemRightClick (final ItemStack stack, final World world, final EntityPlayer player) {
final int meta = stack.getItemDamage();
switch (meta) {
// Weather
case 0 : {
world.getWorldInfo().setRainTime(world.isRaining() ? 24000 : 0);
world.getWorldInfo().setRaining(!world.isRaining());
player.playSound("thaumcraft:wind", 0.3F, 1.0F + world.rand.nextFloat() * 0.5F);
player.inventory.decrStackSize(player.inventory.currentItem, 1);
return stack;
public boolean onEntityItemUpdate (final EntityItem entity) {
super.onEntityItemUpdate(entity);
final World world = entity.worldObj;
final int meta = entity.getEntityItem().getItemDamage();
if (entity.ticksExisted == 100) {
switch (meta) {
// Weather
case 0 : {
world.getWorldInfo().setRainTime(world.isRaining() ? 24000 : 0);
world.getWorldInfo().setRaining(!world.isRaining());
if (world.isRaining() && world.rand.nextInt(10) == 0) {
world.getWorldInfo().setThundering(true);
}
break;
}
// Time
case 1 : {
world.setWorldTime(world.isDaytime() ? 14000 : 24000);
break;
}
}
world.playSoundAtEntity(entity, "thaumcraft:ice", 0.3F, 1.0F + world.rand.nextFloat() * 0.25F);
entity.setDead();
if (world.isRemote) {
for (int i = 0; i < 200; i++) {
spawnParticles(entity, meta, true);
}
}
return false;
}
// Time
case 1 : {
world.setWorldTime(world.isDaytime() ? 14000 : 24000);
player.playSound("thaumcraft:wind", 0.3F, 1.0F + world.rand.nextFloat() * 0.5F);
player.inventory.decrStackSize(player.inventory.currentItem, 1);
return stack;
if (entity.ticksExisted % 30 == 1) {
world.playSoundAtEntity(entity, "thaumcraft:wind", 0.1F, 1.0F + world.rand.nextFloat() * 0.5F);
}
if (world.isRemote) {
spawnParticles(entity, meta, false);
}
return stack;
return false;
}
@SideOnly (Side.CLIENT)
private void spawnParticles (final EntityItem entity, final int meta, final boolean death) {
final Random rand = entity.worldObj.rand;
final double theta = Math.random() * Math.PI;
final double phi = Math.random() * Math.PI * 2d;
final double x = Math.cos(phi) * Math.sin(theta) * 0.25d;
final double y = Math.sin(phi) * Math.sin(theta) * 0.25d;
final double z = Math.cos(theta) * 0.25d;
final FXSparkle fx = new FXSparkle(entity.worldObj, entity.posX + x, entity.boundingBox.maxY + y, entity.posZ + z,
1.75f, meta == 0 ? 7 : 6, death ? 30 + rand.nextInt(5) : 3 + rand.nextInt(2));
fx.setGravity(death ? 0f : -0.1f);
fx.noClip = true;
if (death) {
fx.motionX = x * 3d;
fx.motionY = y * 3d;
fx.motionZ = z * 3d;
}
ParticleEngine.instance.addEffect(entity.worldObj, fx);
}
}