added the shockwave amulet

This commit is contained in:
Ellpeck 2018-11-06 19:02:56 +01:00
parent 1b0df8272f
commit 7146262381
10 changed files with 169 additions and 5 deletions

View file

@ -177,15 +177,17 @@ public final class Helper {
} }
public static boolean extractAuraFromPlayer(EntityPlayer player, int amount, boolean simulate) { public static boolean extractAuraFromPlayer(EntityPlayer player, int amount, boolean simulate) {
if (player.capabilities.isCreativeMode)
return true;
if (Compat.baubles) { if (Compat.baubles) {
IItemHandler baubles = BaublesApi.getBaublesHandler(player); IItemHandler baubles = BaublesApi.getBaublesHandler(player);
for (int i = 0; i < baubles.getSlots(); i++) { for (int i = 0; i < baubles.getSlots(); i++) {
ItemStack stack = baubles.getStackInSlot(i); ItemStack stack = baubles.getStackInSlot(i);
if (!stack.isEmpty() && stack.hasCapability(Capabilities.auraContainer, null)) { if (!stack.isEmpty() && stack.hasCapability(Capabilities.auraContainer, null)) {
amount -= stack.getCapability(Capabilities.auraContainer, null).drainAura(amount, simulate); amount -= stack.getCapability(Capabilities.auraContainer, null).drainAura(amount, simulate);
if (amount <= 0) { if (amount <= 0)
return true; return true;
}
} }
} }
} }
@ -194,9 +196,8 @@ public final class Helper {
ItemStack stack = player.inventory.getStackInSlot(i); ItemStack stack = player.inventory.getStackInSlot(i);
if (!stack.isEmpty() && stack.hasCapability(Capabilities.auraContainer, null)) { if (!stack.isEmpty() && stack.hasCapability(Capabilities.auraContainer, null)) {
amount -= stack.getCapability(Capabilities.auraContainer, null).drainAura(amount, simulate); amount -= stack.getCapability(Capabilities.auraContainer, null).drainAura(amount, simulate);
if (amount <= 0) { if (amount <= 0)
return true; return true;
}
} }
} }

View file

@ -37,6 +37,17 @@ public class BaublesCompat {
return true; return true;
} }
}; };
private final IBauble shockwaveCreator = new IBauble() {
@Override
public BaubleType getBaubleType(ItemStack itemstack) {
return BaubleType.AMULET;
}
@Override
public void onWornTick(ItemStack stack, EntityLivingBase player) {
stack.getItem().onUpdate(stack, player.world, player, -1, false);
}
};
@SubscribeEvent @SubscribeEvent
public void onCapabilitiesAttach(AttachCapabilitiesEvent<ItemStack> event) { public void onCapabilitiesAttach(AttachCapabilitiesEvent<ItemStack> event) {
@ -45,6 +56,8 @@ public class BaublesCompat {
this.addCap(event, this.eye); this.addCap(event, this.eye);
} else if (item == ModItems.AURA_CACHE) { } else if (item == ModItems.AURA_CACHE) {
this.addCap(event, this.cache); this.addCap(event, this.cache);
} else if (item == ModItems.SHOCKWAVE_CREATOR) {
this.addCap(event, this.shockwaveCreator);
} }
} }

View file

@ -22,7 +22,7 @@ public class ItemEye extends ItemImpl implements ITrinketItem {
public void render(ItemStack stack, EntityPlayer player, RenderType type, boolean isHolding) { public void render(ItemStack stack, EntityPlayer player, RenderType type, boolean isHolding) {
if (type == RenderType.BODY && !isHolding) { if (type == RenderType.BODY && !isHolding) {
boolean armor = !player.inventory.armorInventory.get(EntityEquipmentSlot.CHEST.getIndex()).isEmpty(); boolean armor = !player.inventory.armorInventory.get(EntityEquipmentSlot.CHEST.getIndex()).isEmpty();
GlStateManager.translate(0.1F, 0.19F, armor ? -0.195F : -0.13F); GlStateManager.translate(0.1F, 0.225F, armor ? -0.195F : -0.13F);
GlStateManager.scale(0.15F, 0.15F, 0.15F); GlStateManager.scale(0.15F, 0.15F, 0.15F);
GlStateManager.rotate(180F, 1F, 0F, 0F); GlStateManager.rotate(180F, 1F, 0F, 0F);
Helper.renderItemInWorld(stack); Helper.renderItemInWorld(stack);

View file

@ -0,0 +1,130 @@
package de.ellpeck.naturesaura.items;
import de.ellpeck.naturesaura.Helper;
import de.ellpeck.naturesaura.NaturesAura;
import de.ellpeck.naturesaura.packet.PacketHandler;
import de.ellpeck.naturesaura.packet.PacketParticles;
import de.ellpeck.naturesaura.renderers.ITrinketItem;
import de.ellpeck.naturesaura.renderers.PlayerLayerTrinkets;
import net.minecraft.block.Block;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Gui;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.EntityEquipmentSlot;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.DamageSource;
import net.minecraft.util.EnumParticleTypes;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.SoundCategory;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraft.world.WorldServer;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import java.util.List;
public class ItemShockwaveCreator extends ItemImpl implements ITrinketItem {
@SideOnly(Side.CLIENT)
private static final ResourceLocation RES_WORN = new ResourceLocation(NaturesAura.MOD_ID, "textures/items/shockwave_creator_player.png");
public ItemShockwaveCreator() {
super("shockwave_creator");
this.setMaxStackSize(1);
}
@Override
public void onUpdate(ItemStack stack, World worldIn, Entity entityIn, int itemSlot, boolean isSelected) {
if (worldIn.isRemote || !(entityIn instanceof EntityLivingBase))
return;
EntityLivingBase living = (EntityLivingBase) entityIn;
if (!living.onGround) {
if (!stack.hasTagCompound())
stack.setTagCompound(new NBTTagCompound());
NBTTagCompound compound = stack.getTagCompound();
if (compound.getBoolean("air"))
return;
compound.setBoolean("air", true);
compound.setDouble("x", living.posX);
compound.setDouble("y", living.posY);
compound.setDouble("z", living.posZ);
} else {
if (!stack.hasTagCompound())
return;
NBTTagCompound compound = stack.getTagCompound();
if (!compound.getBoolean("air"))
return;
compound.setBoolean("air", false);
if (!living.isSneaking())
return;
if (living.getDistanceSq(compound.getDouble("x"), compound.getDouble("y"), compound.getDouble("z")) > 0.75F)
return;
if (living instanceof EntityPlayer && !Helper.extractAuraFromPlayer((EntityPlayer) living, 10, false))
return;
int range = 5;
List<EntityLiving> mobs = worldIn.getEntitiesWithinAABB(EntityLiving.class, new AxisAlignedBB(
living.posX - range, living.posY - 0.5, living.posZ - range,
living.posX + range, living.posY + 0.5, living.posZ + range));
for (EntityLiving mob : mobs) {
if (mob.isDead || mob == living)
continue;
if (living.getDistanceSq(mob) > range * range)
continue;
if (living instanceof EntityPlayer && !Helper.extractAuraFromPlayer((EntityPlayer) living, 5, false))
break;
mob.attackEntityFrom(DamageSource.MAGIC, 4F);
}
BlockPos pos = living.getPosition();
BlockPos down = pos.down();
IBlockState downState = worldIn.getBlockState(down);
if (downState.getMaterial() != Material.AIR) {
SoundType type = downState.getBlock().getSoundType(downState, worldIn, down, null);
worldIn.playSound(null, pos, type.getBreakSound(), SoundCategory.BLOCKS, type.getVolume() * 0.5F, type.getPitch() * 0.8F);
}
if (worldIn instanceof WorldServer)
((WorldServer) worldIn).spawnParticle(EnumParticleTypes.BLOCK_DUST,
living.posX, living.posY + 0.01F, living.posZ,
15, 0F, 0F, 0F, 0.15F, Block.getStateId(downState));
PacketHandler.sendToAllAround(worldIn, pos, 32,
new PacketParticles((float) living.posX, (float) living.posY, (float) living.posZ, 11));
}
}
@Override
@SideOnly(Side.CLIENT)
public void render(ItemStack stack, EntityPlayer player, PlayerLayerTrinkets.RenderType type, boolean isHolding) {
if (type == PlayerLayerTrinkets.RenderType.BODY && !isHolding) {
boolean armor = !player.inventory.armorInventory.get(EntityEquipmentSlot.CHEST.getIndex()).isEmpty();
GlStateManager.translate(-0.1675F, -0.05F, armor ? -0.195F : -0.13F);
GlStateManager.scale(0.021F, 0.021F, 0.021F);
GlStateManager.pushMatrix();
GlStateManager.disableLighting();
GlStateManager.pushAttrib();
RenderHelper.enableStandardItemLighting();
Minecraft.getMinecraft().getTextureManager().bindTexture(RES_WORN);
Gui.drawModalRectWithCustomSizedTexture(0, 0, 0, 0, 16, 16, 16, 16);
RenderHelper.disableStandardItemLighting();
GlStateManager.popAttrib();
GlStateManager.enableLighting();
GlStateManager.popMatrix();
}
}
}

View file

@ -16,6 +16,7 @@ public final class ModItems {
public static final Item ANCIENT_STICK = new ItemImpl("ancient_stick"); public static final Item ANCIENT_STICK = new ItemImpl("ancient_stick");
public static final Item COLOR_CHANGER = new ItemColorChanger(); public static final Item COLOR_CHANGER = new ItemColorChanger();
public static final Item AURA_CACHE = new ItemAuraCache(); public static final Item AURA_CACHE = new ItemAuraCache();
public static final Item SHOCKWAVE_CREATOR = new ItemShockwaveCreator();
public static final Item.ToolMaterial TOOL_MATERIAL_INFUSED_IRON = public static final Item.ToolMaterial TOOL_MATERIAL_INFUSED_IRON =
EnumHelper.addToolMaterial(NaturesAura.MOD_ID.toUpperCase(Locale.ROOT) + "_INFUSED_IRON", 3, 300, 6.25F, 2.25F, 16); EnumHelper.addToolMaterial(NaturesAura.MOD_ID.toUpperCase(Locale.ROOT) + "_INFUSED_IRON", 3, 300, 6.25F, 2.25F, 16);

View file

@ -196,6 +196,18 @@ public class PacketParticles implements IMessage {
world.rand.nextGaussian() * 0.015F, world.rand.nextGaussian() * 0.015F,
world.rand.nextGaussian() * 0.015F, world.rand.nextGaussian() * 0.015F,
0xdde7ff, world.rand.nextFloat() + 1F, 30, -0.06F, true, true); 0xdde7ff, world.rand.nextFloat() + 1F, 30, -0.06F, true, true);
break;
case 11: // Shockwave creator particles
for (int i = 0; i < 360; i += 2) {
double rad = Math.toRadians(i);
NaturesAura.proxy.spawnMagicParticle(world,
message.posX, message.posY + 0.01F, message.posZ,
(float) Math.sin(rad) * 0.65F,
0F,
(float) Math.cos(rad) * 0.65F,
0x911b07, 3F, 10, 0F, false, true);
}
break;
} }
} }
}); });

View file

@ -42,6 +42,7 @@ item.naturesaura.ancient_stick.name=Ancient Wood Rod
item.naturesaura.aura_cache.name=Aura Cache item.naturesaura.aura_cache.name=Aura Cache
item.naturesaura.color_changer.name=Bucket of Infinite Color item.naturesaura.color_changer.name=Bucket of Infinite Color
item.naturesaura.book.name=Book of Natural Aura item.naturesaura.book.name=Book of Natural Aura
item.naturesaura.shockwave_creator.name=Amulet of Wrath
container.naturesaura.tree_ritual.name=Ritual of the Forest container.naturesaura.tree_ritual.name=Ritual of the Forest
container.naturesaura.altar.name=Natural Altar Infusion container.naturesaura.altar.name=Natural Altar Infusion

View file

@ -0,0 +1,6 @@
{
"parent": "item/generated",
"textures": {
"layer0": "naturesaura:items/shockwave_creator"
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 679 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 515 B