Working potion launcher
This commit is contained in:
parent
e2ecb66ef2
commit
b5f61b5367
BIN
mods/tinker/resources/sounds/frypan_hit.ogg
Normal file
BIN
mods/tinker/resources/sounds/frypan_hit.ogg
Normal file
Binary file not shown.
BIN
mods/tinker/resources/sounds/little_saw.ogg
Normal file
BIN
mods/tinker/resources/sounds/little_saw.ogg
Normal file
Binary file not shown.
@ -332,7 +332,7 @@ public class TContent implements IFuelHandler
|
||||
//longbow = new RangedWeapon(PHConstruct.longbow);
|
||||
mattock = new Mattock(PHConstruct.mattock);
|
||||
//lumberaxe = new LumberAxe(PHConstruct.lumberaxe, lumberaxeTexture);
|
||||
potionLauncher = new PotionLauncher(PHConstruct.potionLauncher);
|
||||
potionLauncher = new PotionLauncher(PHConstruct.potionLauncher).setUnlocalizedName("tconstruct.PotionLauncher");
|
||||
|
||||
pickaxeHead = new ToolPart(PHConstruct.pickaxeHead, "PickaxeHead", "_pickaxe_head").setUnlocalizedName("tconstruct.PickaxeHead");
|
||||
shovelHead = new ToolPart(PHConstruct.shovelHead, "ShovelHead", "_shovel_head").setUnlocalizedName("tconstruct.ShovelHead");
|
||||
|
@ -1,21 +1,16 @@
|
||||
package mods.tinker.tconstruct;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Random;
|
||||
|
||||
import mods.tinker.tconstruct.crafting.PatternBuilder;
|
||||
import mods.tinker.tconstruct.crafting.Smeltery;
|
||||
import mods.tinker.tconstruct.logic.LiquidTextureLogic;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.enchantment.Enchantment;
|
||||
import net.minecraft.enchantment.EnchantmentHelper;
|
||||
import net.minecraft.entity.projectile.EntityArrow;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumMovingObjectType;
|
||||
import net.minecraftforge.client.event.sound.SoundLoadEvent;
|
||||
import net.minecraftforge.event.Event.Result;
|
||||
import net.minecraftforge.event.ForgeSubscribe;
|
||||
import net.minecraftforge.event.entity.player.ArrowLooseEvent;
|
||||
import net.minecraftforge.event.entity.player.FillBucketEvent;
|
||||
import net.minecraftforge.liquids.LiquidStack;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
@ -23,6 +18,22 @@ import net.minecraftforge.oredict.OreDictionary.OreRegisterEvent;
|
||||
|
||||
public class TEventHandler
|
||||
{
|
||||
/* Sounds */
|
||||
@ForgeSubscribe
|
||||
public void onSound(SoundLoadEvent event)
|
||||
{
|
||||
try
|
||||
{
|
||||
event.manager.soundPoolSounds.addSound("hit.frypan", TConstruct.class.getResource("/mods/tinker/resources/sounds/frypan_hit.ogg"));
|
||||
event.manager.soundPoolSounds.addSound("crafting.saw", TConstruct.class.getResource("/mods/tinker/resources/sounds/little_saw.ogg"));
|
||||
System.out.println("[TConstruct] Successfully loaded sounds.");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
System.err.println("[TConstruct] Failed to register one or more sounds");
|
||||
}
|
||||
}
|
||||
|
||||
/* Ore Dictionary */
|
||||
@ForgeSubscribe
|
||||
public void registerOre (OreRegisterEvent evt)
|
||||
|
43
mods/tinker/tconstruct/client/SuperSoakerRender.java
Normal file
43
mods/tinker/tconstruct/client/SuperSoakerRender.java
Normal file
@ -0,0 +1,43 @@
|
||||
package mods.tinker.tconstruct.client;
|
||||
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.entity.EntityLiving;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.client.IItemRenderer;
|
||||
|
||||
public class SuperSoakerRender implements IItemRenderer
|
||||
{
|
||||
|
||||
@Override
|
||||
public boolean handleRenderType (ItemStack item, ItemRenderType type)
|
||||
{
|
||||
return type != ItemRenderType.INVENTORY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldUseRenderHelper (ItemRenderType type, ItemStack item, ItemRendererHelper helper)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderItem (ItemRenderType type, ItemStack item, Object... data)
|
||||
{
|
||||
if (type == ItemRenderType.EQUIPPED)
|
||||
renderEquippedItem(item, (RenderBlocks) data[0], (EntityLiving) data[1]);
|
||||
if (type == ItemRenderType.ENTITY)
|
||||
renderEntityItem(item, (RenderBlocks) data[0], (EntityItem) data[1]);
|
||||
}
|
||||
|
||||
void renderEquippedItem (ItemStack item, RenderBlocks renderBlocks, EntityLiving entityLiving)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void renderEntityItem (ItemStack item, RenderBlocks renderBlocks, EntityItem entityItem)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -192,6 +192,7 @@ public class TProxyClient extends TProxyCommon
|
||||
LanguageRegistry.addName(TContent.frypan, "Frying Pan");
|
||||
LanguageRegistry.addName(TContent.battlesign, "Battlesign");
|
||||
LanguageRegistry.addName(TContent.mattock, "Mattock");
|
||||
LanguageRegistry.addName(TContent.potionLauncher, "Potion Launcher");
|
||||
//LanguageRegistry.addName(TContent.lumberaxe, "Lumber Axe");
|
||||
|
||||
addToolButtons();
|
||||
|
@ -1,5 +1,7 @@
|
||||
package mods.tinker.tconstruct.container;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import mods.tinker.tconstruct.library.ToolCore;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
@ -11,6 +13,7 @@ public class SlotTool extends Slot
|
||||
{
|
||||
/** The player that is using the GUI where this slot resides. */
|
||||
private EntityPlayer player;
|
||||
Random random = new Random();
|
||||
|
||||
public SlotTool(EntityPlayer entityplayer, IInventory builder, int par3, int par4, int par5)
|
||||
{
|
||||
@ -55,6 +58,7 @@ public class SlotTool extends Slot
|
||||
for (int i = 1; i <= 3; i++)
|
||||
inventory.decrStackSize(i, 1);
|
||||
if (!player.worldObj.isRemote)
|
||||
//player.worldObj.playSoundEffect(player.posX, player.posY, player.posZ, "crafting.saw", 0.5F, 0.4F / (random.nextFloat() * 0.4F + 0.8F));
|
||||
player.worldObj.playAuxSFX(1021, (int)player.posX, (int)player.posY, (int)player.posZ, 0);
|
||||
}
|
||||
}
|
||||
|
@ -25,10 +25,9 @@ public class FryingPan extends Weapon
|
||||
@Override
|
||||
public boolean hitEntity(ItemStack stack, EntityLiving mob, EntityLiving player)
|
||||
{
|
||||
//AbilityHelper.hitEntity(stack, mob, player, damageVsEntity);
|
||||
AbilityHelper.knockbackEntity(mob, 1.7f);
|
||||
mob.addPotionEffect(new PotionEffect(Potion.moveSlowdown.id, 100, 0)); //5 seconds of stun
|
||||
//Play "thunk" sfx
|
||||
player.worldObj.playSoundEffect(mob.posX, mob.posY, mob.posZ, "hit.frypan", 1.0F, (random.nextFloat() - random.nextFloat()) * 0.2F + 1.0F);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -39,6 +38,7 @@ public class FryingPan extends Weapon
|
||||
|
||||
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float clickX, float clickY, float clickZ)
|
||||
{
|
||||
player.worldObj.playSoundEffect(player.posX, player.posY, player.posZ, "hit.frypan", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));
|
||||
if (side == 0 || !player.isSneaking())
|
||||
{
|
||||
return false;
|
||||
|
@ -1,15 +1,16 @@
|
||||
package mods.tinker.tconstruct.tools;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import mods.tinker.tconstruct.entity.LaunchedPotion;
|
||||
import net.minecraft.client.renderer.texture.IconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.enchantment.Enchantment;
|
||||
import net.minecraft.enchantment.EnchantmentHelper;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.projectile.EntityArrow;
|
||||
import net.minecraft.item.EnumAction;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.Icon;
|
||||
import net.minecraft.world.World;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
@ -31,48 +32,47 @@ public class PotionLauncher extends Item
|
||||
|
||||
public ItemStack onEaten (ItemStack stack, World world, EntityPlayer player)
|
||||
{
|
||||
if (stack.getItemDamage() == 0)
|
||||
stack.setItemDamage(1);
|
||||
NBTTagCompound tags = stack.getTagCompound().getCompoundTag("InfiTool");
|
||||
boolean loaded = tags.getBoolean("Loaded");
|
||||
//boolean fired = tags.getBoolean("Fired");
|
||||
if (!loaded)
|
||||
{
|
||||
tags.setBoolean("Loaded", true);
|
||||
}
|
||||
/*else if (fired)
|
||||
{
|
||||
tags.setBoolean("Loaded", false);
|
||||
tags.setBoolean("Ready", false);
|
||||
tags.setBoolean("Fired", false);
|
||||
}*/
|
||||
return stack;
|
||||
}
|
||||
|
||||
public void onPlayerStoppedUsing(ItemStack stack, World world, EntityPlayer player, int time)
|
||||
{
|
||||
if (stack.getItemDamage() == 1)
|
||||
stack.setItemDamage(2);
|
||||
}
|
||||
|
||||
/**
|
||||
* How long it takes to use or consume an item
|
||||
*/
|
||||
public int getMaxItemUseDuration (ItemStack stack)
|
||||
public void onPlayerStoppedUsing (ItemStack stack, World world, EntityPlayer player, int time)
|
||||
{
|
||||
int meta = stack.getItemDamage();
|
||||
if (meta == 1)
|
||||
return 72000;
|
||||
else if (meta == 2)
|
||||
return 0;
|
||||
|
||||
return 30;
|
||||
/*NBTTagCompound tags = stack.getTagCompound().getCompoundTag("InfiTool");
|
||||
boolean loaded = tags.getBoolean("Loaded");
|
||||
boolean ready = tags.getBoolean("Ready");
|
||||
boolean fired = tags.getBoolean("Fired");
|
||||
if (loaded)
|
||||
{
|
||||
tags.setBoolean("Ready", true);
|
||||
}
|
||||
if (loaded && ready && fired)
|
||||
{
|
||||
tags.setBoolean("Loaded", false);
|
||||
tags.setBoolean("Ready", false);
|
||||
tags.setBoolean("Fired", false);
|
||||
}*/
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the action that specifies what animation to play when the items is being used
|
||||
*/
|
||||
public EnumAction getItemUseAction (ItemStack stack)
|
||||
{
|
||||
if (stack.getItemDamage() == 0)
|
||||
return EnumAction.bow;
|
||||
else
|
||||
return EnumAction.none;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer
|
||||
*/
|
||||
public ItemStack onItemRightClick (ItemStack stack, World world, EntityPlayer player)
|
||||
{
|
||||
if (stack.getItemDamage() == 2)
|
||||
/*NBTTagCompound tags = stack.getTagCompound().getCompoundTag("InfiTool");
|
||||
boolean loaded = tags.getBoolean("Loaded");
|
||||
boolean ready = tags.getBoolean("Ready");
|
||||
boolean fired = tags.getBoolean("Fired");
|
||||
if (loaded && ready && !fired)
|
||||
{
|
||||
world.playSoundAtEntity(player, "random.bow", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));
|
||||
|
||||
@ -80,27 +80,47 @@ public class PotionLauncher extends Item
|
||||
{
|
||||
world.spawnEntityInWorld(new LaunchedPotion(world, player, stack));
|
||||
}
|
||||
|
||||
stack.damageItem(1, player);
|
||||
System.out.println("Rawr! "+stack.getItemDamage());
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
if (player.capabilities.isCreativeMode)
|
||||
{
|
||||
player.setItemInUse(stack, this.getMaxItemUseDuration(stack));
|
||||
}
|
||||
tags.setBoolean("Fired", true);
|
||||
}
|
||||
player.setItemInUse(stack, this.getMaxItemUseDuration(stack));*/
|
||||
NBTTagCompound tags = stack.getTagCompound().getCompoundTag("InfiTool");
|
||||
if (!tags.getBoolean("Loaded"))
|
||||
player.setItemInUse(stack, this.getMaxItemUseDuration(stack));
|
||||
return stack;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the enchantability factor of the item, most of the time is based on material.
|
||||
*/
|
||||
public int getItemEnchantability ()
|
||||
public void onUpdate (ItemStack stack, World world, Entity entity, int slot, boolean equipped)
|
||||
{
|
||||
return 1;
|
||||
/*if (equipped && entity instanceof EntityPlayer)
|
||||
{
|
||||
EntityPlayer player = ((EntityPlayer) entity);
|
||||
if (!player.worldObj.isRemote)
|
||||
System.out.println(player.getItemInUse());
|
||||
NBTTagCompound tags = stack.getTagCompound().getCompoundTag("InfiTool");
|
||||
//System.out.println("useTime "+((EntityPlayer) entity).getItemInUseCount());
|
||||
}*/
|
||||
}
|
||||
|
||||
/**
|
||||
* How long it takes to use or consume an item
|
||||
*/
|
||||
public int getMaxItemUseDuration (ItemStack stack)
|
||||
{
|
||||
//if (!stack.getTagCompound().getCompoundTag("InfiTool").getBoolean("Loaded"))
|
||||
return 30;
|
||||
//else
|
||||
//return 72000;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the action that specifies what animation to play when the items is being used
|
||||
*/
|
||||
public EnumAction getItemUseAction (ItemStack stack)
|
||||
{
|
||||
if (!stack.getTagCompound().getCompoundTag("InfiTool").getBoolean("Loaded"))
|
||||
return EnumAction.bow;
|
||||
else
|
||||
return EnumAction.none;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@ -119,4 +139,38 @@ public class PotionLauncher extends Item
|
||||
{
|
||||
return icons[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubItems (int id, CreativeTabs tabs, List list)
|
||||
{
|
||||
ItemStack stack = new ItemStack(id, 1, 0);
|
||||
NBTTagCompound compound = new NBTTagCompound();
|
||||
NBTTagCompound tags = new NBTTagCompound();
|
||||
compound.setCompoundTag("InfiTool", tags);
|
||||
|
||||
tags.setBoolean("Loaded", false);
|
||||
|
||||
stack.setTagCompound(compound);
|
||||
|
||||
list.add(stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean swingItem (EntityPlayer player, ItemStack stack)
|
||||
{
|
||||
NBTTagCompound tags = stack.getTagCompound().getCompoundTag("InfiTool");
|
||||
if (tags.getBoolean("Loaded"))
|
||||
{
|
||||
World world = player.worldObj;
|
||||
world.playSoundAtEntity(player, "random.bow", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));
|
||||
|
||||
if (!world.isRemote)
|
||||
{
|
||||
world.spawnEntityInWorld(new LaunchedPotion(world, player, stack));
|
||||
}
|
||||
tags.setBoolean("Loaded", false);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 1015 B After Width: | Height: | Size: 1.0 KiB |
Loading…
x
Reference in New Issue
Block a user