mirror of
https://github.com/GTNewHorizons/TinkersConstruct.git
synced 2026-11-21 04:32:26 +00:00
Fix JABBA-related issues with crafting station slots (#54)
* Fix shift-merging tools voiding items fixes <https://github.com/GTNewHorizons/GT-New-Horizons-Modpack/issues/11392> * Change 0-sized ItemStacks into null stacks in crafting station attached slots Fixes <https://github.com/GTNewHorizons/GT-New-Horizons-Modpack/issues/10425> * Update buildscript * spotlessApply
This commit is contained in:
1 parent
18bfeaff32
commit
39be06c23b
571 files changed
+25959
-28223
No files matched your search
@@ -1,14 +1,10 @@
|
||||
package tconstruct.gadgets;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import cpw.mods.fml.common.event.FMLInitializationEvent;
|
||||
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
|
||||
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import java.util.Locale;
|
||||
import mantle.pulsar.pulse.Handler;
|
||||
import mantle.pulsar.pulse.Pulse;
|
||||
import net.minecraft.init.Items;
|
||||
@@ -16,6 +12,8 @@ import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.oredict.ShapedOreRecipe;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import tconstruct.TConstruct;
|
||||
import tconstruct.gadgets.item.ItemSlimeBoots;
|
||||
import tconstruct.gadgets.item.ItemSlimeSling;
|
||||
@@ -25,58 +23,54 @@ import tconstruct.library.TConstructRegistry;
|
||||
@Pulse(id = "Tinkers' Gadgets", description = "All the fun toys.")
|
||||
public class TinkerGadgets {
|
||||
|
||||
public static final String PulseId = "TinkerGadgets";
|
||||
public static final Logger log = LogManager.getLogger(PulseId);
|
||||
public static final String PulseId = "TinkerGadgets";
|
||||
public static final Logger log = LogManager.getLogger(PulseId);
|
||||
|
||||
// Gadgets
|
||||
public static ItemSlimeSling slimeSling;
|
||||
public static ItemSlimeBoots slimeBoots;
|
||||
// Gadgets
|
||||
public static ItemSlimeSling slimeSling;
|
||||
public static ItemSlimeBoots slimeBoots;
|
||||
|
||||
@Handler
|
||||
public void preInit(FMLPreInitializationEvent event) {
|
||||
@Handler
|
||||
public void preInit(FMLPreInitializationEvent event) {
|
||||
|
||||
SlimeBounceHandler.init();
|
||||
slimeSling = registerItem(new ItemSlimeSling(), "slimesling");
|
||||
slimeBoots = registerItem(new ItemSlimeBoots(), "slime_boots");
|
||||
SlimeBounceHandler.init();
|
||||
slimeSling = registerItem(new ItemSlimeSling(), "slimesling");
|
||||
slimeBoots = registerItem(new ItemSlimeBoots(), "slime_boots");
|
||||
}
|
||||
|
||||
}
|
||||
@Handler
|
||||
public void init(FMLInitializationEvent event) {
|
||||
String ore = "blockSlime";
|
||||
|
||||
@Handler
|
||||
public void init(FMLInitializationEvent event) {
|
||||
String ore = "blockSlime";
|
||||
GameRegistry.addRecipe(
|
||||
new ShapedOreRecipe(new ItemStack(slimeBoots), " ", "s s", "b b", 's', "slimeball", 'b', ore));
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(
|
||||
new ItemStack(slimeSling), "fbf", "s s", " s ", 'f', Items.string, 's', "slimeball", 'b', ore));
|
||||
TConstructRegistry.gadgetsTab.init(new ItemStack(slimeBoots));
|
||||
}
|
||||
|
||||
GameRegistry.addRecipe(
|
||||
new ShapedOreRecipe(new ItemStack(slimeBoots), " ", "s s", "b b", 's', "slimeball", 'b', ore));
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(slimeSling), "fbf", "s s", " s ", 'f', Items.string,
|
||||
's', "slimeball", 'b', ore));
|
||||
TConstructRegistry.gadgetsTab.init(new ItemStack(slimeBoots));
|
||||
@Handler
|
||||
public void postInit(FMLPostInitializationEvent evt) {}
|
||||
|
||||
}
|
||||
public static String resource(String res) {
|
||||
return String.format("%s:%s", "tinker", res);
|
||||
}
|
||||
|
||||
@Handler
|
||||
public void postInit(FMLPostInitializationEvent evt) {
|
||||
public static ResourceLocation getResource(String res) {
|
||||
return new ResourceLocation("tinker", res);
|
||||
}
|
||||
|
||||
}
|
||||
public static String prefix(String name) {
|
||||
return String.format("%s.%s", TConstruct.modID, name.toLowerCase(Locale.US));
|
||||
}
|
||||
|
||||
public static String resource(String res) {
|
||||
return String.format("%s:%s", "tinker", res);
|
||||
}
|
||||
|
||||
public static ResourceLocation getResource(String res) {
|
||||
return new ResourceLocation("tinker", res);
|
||||
}
|
||||
|
||||
public static String prefix(String name) {
|
||||
return String.format("%s.%s", TConstruct.modID, name.toLowerCase(Locale.US));
|
||||
}
|
||||
|
||||
protected static <T extends Item> T registerItem(T item, String name) {
|
||||
if (!name.equals(name.toLowerCase(Locale.US))) {
|
||||
throw new IllegalArgumentException(
|
||||
String.format("Unlocalized names need to be all lowercase! Item: %s", name));
|
||||
}
|
||||
item.setUnlocalizedName(prefix(name));
|
||||
GameRegistry.registerItem(item, name);
|
||||
return item;
|
||||
}
|
||||
protected static <T extends Item> T registerItem(T item, String name) {
|
||||
if (!name.equals(name.toLowerCase(Locale.US))) {
|
||||
throw new IllegalArgumentException(
|
||||
String.format("Unlocalized names need to be all lowercase! Item: %s", name));
|
||||
}
|
||||
item.setUnlocalizedName(prefix(name));
|
||||
GameRegistry.registerItem(item, name);
|
||||
return item;
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,10 @@
|
||||
package tconstruct.gadgets.item;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.vecmath.Vector3d;
|
||||
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import java.util.List;
|
||||
import javax.vecmath.Vector3d;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
@@ -32,208 +30,208 @@ import tconstruct.tools.entity.FancyEntityItem;
|
||||
|
||||
public class ItemSlimeBoots extends ItemArmor implements ISpecialArmor {
|
||||
|
||||
public static ArmorMaterial SLIME_MATERIAL = EnumHelper.addArmorMaterial("SLIME", 100, new int[] { 0, 0, 0, 0 }, 0);
|
||||
public static ArmorMaterial SLIME_MATERIAL = EnumHelper.addArmorMaterial("SLIME", 100, new int[] {0, 0, 0, 0}, 0);
|
||||
|
||||
public final ArmorPart armorPart;
|
||||
protected final String textureFolder;
|
||||
protected final String textureName;
|
||||
public final ArmorPart armorPart;
|
||||
protected final String textureFolder;
|
||||
protected final String textureName;
|
||||
|
||||
public ItemSlimeBoots() {
|
||||
super(SLIME_MATERIAL, 0, 3);
|
||||
this.setCreativeTab(TConstructRegistry.gadgetsTab);
|
||||
this.setMaxStackSize(1);
|
||||
this.setMaxDamage(100);
|
||||
SLIME_MATERIAL.customCraftingMaterial = Items.slime_ball;
|
||||
armorPart = ArmorPart.Feet;
|
||||
textureFolder = "armor";
|
||||
textureName = "slime";
|
||||
SlimeBounceHandler.registerEvent(this);
|
||||
}
|
||||
public ItemSlimeBoots() {
|
||||
super(SLIME_MATERIAL, 0, 3);
|
||||
this.setCreativeTab(TConstructRegistry.gadgetsTab);
|
||||
this.setMaxStackSize(1);
|
||||
this.setMaxDamage(100);
|
||||
SLIME_MATERIAL.customCraftingMaterial = Items.slime_ball;
|
||||
armorPart = ArmorPart.Feet;
|
||||
textureFolder = "armor";
|
||||
textureName = "slime";
|
||||
SlimeBounceHandler.registerEvent(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValidArmor(ItemStack stack, int armorType1, Entity entity) {
|
||||
// can be worn as boots
|
||||
return armorType1 == 3;
|
||||
}
|
||||
@Override
|
||||
public boolean isValidArmor(ItemStack stack, int armorType1, Entity entity) {
|
||||
// can be worn as boots
|
||||
return armorType1 == 3;
|
||||
}
|
||||
|
||||
// equipping with rightclick
|
||||
@Override
|
||||
public ItemStack onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn) {
|
||||
int slot = 1; // 0 = current item, 1 = feet
|
||||
ItemStack itemstack = playerIn.getEquipmentInSlot(slot);
|
||||
if (itemstack == null) {
|
||||
playerIn.setCurrentItemOrArmor(slot, itemStackIn.copy());
|
||||
itemStackIn.stackSize--;
|
||||
}
|
||||
else {
|
||||
itemstack = itemstack.copy();
|
||||
playerIn.setCurrentItemOrArmor(1, itemStackIn.copy());
|
||||
//playerIn.setCurrentItemOrArmor(0, itemstack);
|
||||
playerIn.entityDropItem(itemstack, 0);
|
||||
itemStackIn.stackSize--;
|
||||
}
|
||||
return itemStackIn;
|
||||
}
|
||||
|
||||
/** Called when an entity lands to handle the event */
|
||||
@SubscribeEvent
|
||||
// RUBBERY BOUNCY BOUNCERY WOOOOO
|
||||
public void onFall(LivingFallEvent event) {
|
||||
EntityLivingBase living = event.entityLiving;
|
||||
//TinkerGadgets.log.info("Fall event.");
|
||||
// using fall distance as the event distance could be reduced by jump boost
|
||||
if (living == null || living.fallDistance <= 2f) {
|
||||
//TinkerGadgets.log.info("Invalid event.");
|
||||
return;
|
||||
}
|
||||
// can the entity bounce?
|
||||
if (!SlimeBounceHandler.hasSlimeBoots(living)) {
|
||||
//TinkerGadgets.log.info("No Boots.");
|
||||
return;
|
||||
}
|
||||
// equipping with rightclick
|
||||
@Override
|
||||
public ItemStack onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn) {
|
||||
int slot = 1; // 0 = current item, 1 = feet
|
||||
ItemStack itemstack = playerIn.getEquipmentInSlot(slot);
|
||||
if (itemstack == null) {
|
||||
playerIn.setCurrentItemOrArmor(slot, itemStackIn.copy());
|
||||
itemStackIn.stackSize--;
|
||||
} else {
|
||||
itemstack = itemstack.copy();
|
||||
playerIn.setCurrentItemOrArmor(1, itemStackIn.copy());
|
||||
// playerIn.setCurrentItemOrArmor(0, itemstack);
|
||||
playerIn.entityDropItem(itemstack, 0);
|
||||
itemStackIn.stackSize--;
|
||||
}
|
||||
return itemStackIn;
|
||||
}
|
||||
|
||||
// reduced fall damage when crouching
|
||||
if (living.isSneaking()) {
|
||||
//TinkerGadgets.log.info("Sneaking");
|
||||
event.distance = 1;
|
||||
return;
|
||||
}
|
||||
/** Called when an entity lands to handle the event */
|
||||
@SubscribeEvent
|
||||
// RUBBERY BOUNCY BOUNCERY WOOOOO
|
||||
public void onFall(LivingFallEvent event) {
|
||||
EntityLivingBase living = event.entityLiving;
|
||||
// TinkerGadgets.log.info("Fall event.");
|
||||
// using fall distance as the event distance could be reduced by jump boost
|
||||
if (living == null || living.fallDistance <= 2f) {
|
||||
// TinkerGadgets.log.info("Invalid event.");
|
||||
return;
|
||||
}
|
||||
// can the entity bounce?
|
||||
if (!SlimeBounceHandler.hasSlimeBoots(living)) {
|
||||
// TinkerGadgets.log.info("No Boots.");
|
||||
return;
|
||||
}
|
||||
|
||||
// thing is wearing slime boots. let's get bouncyyyyy
|
||||
event.setCanceled(true);
|
||||
// skip further client processing on players
|
||||
if (living.worldObj.isRemote) {
|
||||
//TinkerGadgets.log.info("Client Fall Handler.");
|
||||
living.playSound("mob.slime.small", 1f, 1f);
|
||||
SlimeBounceHandler.addBounceHandler(living);
|
||||
//TConstruct.packetPipeline.sendToServer(new BouncedPacket(living));
|
||||
return;
|
||||
}
|
||||
// reduced fall damage when crouching
|
||||
if (living.isSneaking()) {
|
||||
// TinkerGadgets.log.info("Sneaking");
|
||||
event.distance = 1;
|
||||
return;
|
||||
}
|
||||
|
||||
// server players behave differently than non-server players, they have no
|
||||
// velocity during the event, so we need to reverse engineer it
|
||||
Vector3d motion = SlimeBounceHandler.getMotion(living);
|
||||
if (living instanceof EntityPlayerMP) {
|
||||
// velocity is lost on server players, but we dont have to defer the bounce
|
||||
double gravity = 0.2353455252;
|
||||
double time = Math.sqrt(living.fallDistance / gravity);
|
||||
double velocity = gravity * time;
|
||||
living.setVelocity(motion.x / 0.95f, velocity, motion.z / 0.95f);
|
||||
living.velocityChanged = true;
|
||||
// preserve momentum
|
||||
SlimeBounceHandler.addBounceHandler(living);
|
||||
//TinkerGadgets.log.info("Player");
|
||||
}
|
||||
else {
|
||||
// for non-players, need to defer the bounce
|
||||
// only slow down half as much when bouncing
|
||||
living.setVelocity(motion.x / 0.95f, motion.y * -0.9, motion.z / 0.95f);
|
||||
SlimeBounceHandler.addBounceHandler(living, SlimeBounceHandler.getMotion(living).y);
|
||||
//TinkerGadgets.log.info("Not Player");
|
||||
}
|
||||
//TinkerGadgets.log.info("Server Fall Handler.");
|
||||
// update airborn status
|
||||
living.isAirBorne = true;
|
||||
living.onGround = false;
|
||||
event.distance = 0f;
|
||||
living.playSound("mob.slime.small", 1f, 1f);
|
||||
}
|
||||
// thing is wearing slime boots. let's get bouncyyyyy
|
||||
event.setCanceled(true);
|
||||
// skip further client processing on players
|
||||
if (living.worldObj.isRemote) {
|
||||
// TinkerGadgets.log.info("Client Fall Handler.");
|
||||
living.playSound("mob.slime.small", 1f, 1f);
|
||||
SlimeBounceHandler.addBounceHandler(living);
|
||||
// TConstruct.packetPipeline.sendToServer(new BouncedPacket(living));
|
||||
return;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getArmorDisplay(EntityPlayer player, ItemStack armor, int slot) {
|
||||
return 2;
|
||||
}
|
||||
// server players behave differently than non-server players, they have no
|
||||
// velocity during the event, so we need to reverse engineer it
|
||||
Vector3d motion = SlimeBounceHandler.getMotion(living);
|
||||
if (living instanceof EntityPlayerMP) {
|
||||
// velocity is lost on server players, but we dont have to defer the bounce
|
||||
double gravity = 0.2353455252;
|
||||
double time = Math.sqrt(living.fallDistance / gravity);
|
||||
double velocity = gravity * time;
|
||||
living.setVelocity(motion.x / 0.95f, velocity, motion.z / 0.95f);
|
||||
living.velocityChanged = true;
|
||||
// preserve momentum
|
||||
SlimeBounceHandler.addBounceHandler(living);
|
||||
// TinkerGadgets.log.info("Player");
|
||||
} else {
|
||||
// for non-players, need to defer the bounce
|
||||
// only slow down half as much when bouncing
|
||||
living.setVelocity(motion.x / 0.95f, motion.y * -0.9, motion.z / 0.95f);
|
||||
SlimeBounceHandler.addBounceHandler(living, SlimeBounceHandler.getMotion(living).y);
|
||||
// TinkerGadgets.log.info("Not Player");
|
||||
}
|
||||
// TinkerGadgets.log.info("Server Fall Handler.");
|
||||
// update airborn status
|
||||
living.isAirBorne = true;
|
||||
living.onGround = false;
|
||||
event.distance = 0f;
|
||||
living.playSound("mob.slime.small", 1f, 1f);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public String getArmorTexture(ItemStack stack, Entity entity, int slot, String type) {
|
||||
return "tinker:textures/armor/" + textureName + "_" + 1 + ".png";
|
||||
}
|
||||
@Override
|
||||
public int getArmorDisplay(EntityPlayer player, ItemStack armor, int slot) {
|
||||
return 2;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
protected IIcon[] modifiers;
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public String getArmorTexture(ItemStack stack, Entity entity, int slot, String type) {
|
||||
return "tinker:textures/armor/" + textureName + "_" + 1 + ".png";
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons(IIconRegister iconRegister) {
|
||||
this.itemIcon = iconRegister.registerIcon("tinker:" + textureFolder + "/" + textureName + "_boots");
|
||||
@SideOnly(Side.CLIENT)
|
||||
protected IIcon[] modifiers;
|
||||
|
||||
}
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons(IIconRegister iconRegister) {
|
||||
this.itemIcon = iconRegister.registerIcon("tinker:" + textureFolder + "/" + textureName + "_boots");
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIcon(ItemStack stack, int renderPass) {
|
||||
return itemIcon;
|
||||
}
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIcon(ItemStack stack, int renderPass) {
|
||||
return itemIcon;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public boolean requiresMultipleRenderPasses() {
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public boolean requiresMultipleRenderPasses() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public boolean hasEffect(ItemStack par1ItemStack) {
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public boolean hasEffect(ItemStack par1ItemStack) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// ISpecialArmor overrides
|
||||
@Override
|
||||
public ArmorProperties getProperties(EntityLivingBase player, ItemStack armor, DamageSource source, double damage,
|
||||
int slot) {
|
||||
return new ArmorProperties(0, armor.getItemDamage() / 100, 100);
|
||||
}
|
||||
// ISpecialArmor overrides
|
||||
@Override
|
||||
public ArmorProperties getProperties(
|
||||
EntityLivingBase player, ItemStack armor, DamageSource source, double damage, int slot) {
|
||||
return new ArmorProperties(0, armor.getItemDamage() / 100, 100);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void damageArmor(EntityLivingBase entity, ItemStack armor, DamageSource source, int damage, int slot) {
|
||||
if (source == DamageSource.fall) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void damageArmor(EntityLivingBase entity, ItemStack armor, DamageSource source, int damage, int slot) {
|
||||
if (source == DamageSource.fall) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void getSubItems(Item par1, CreativeTabs par2CreativeTabs, List par3List) {
|
||||
par3List.add(new ItemStack(par1));
|
||||
}
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void getSubItems(Item par1, CreativeTabs par2CreativeTabs, List par3List) {
|
||||
par3List.add(new ItemStack(par1));
|
||||
}
|
||||
|
||||
// Vanilla overrides
|
||||
@Override
|
||||
public boolean isItemTool(ItemStack par1ItemStack) {
|
||||
return false;
|
||||
}
|
||||
// Vanilla overrides
|
||||
@Override
|
||||
public boolean isItemTool(ItemStack par1ItemStack) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRepairable() {
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public boolean isRepairable() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemEnchantability() {
|
||||
return 0;
|
||||
}
|
||||
@Override
|
||||
public int getItemEnchantability() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFull3D() {
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public boolean isFull3D() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean par4) {
|
||||
list.add("Boooounce!");
|
||||
list.add("Hold "+(I18n.format(Minecraft.getMinecraft().gameSettings.keyBindSneak.getKeyDescription(), new Object[0]))+" to stop bouncing.");
|
||||
}
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean par4) {
|
||||
list.add("Boooounce!");
|
||||
list.add("Hold "
|
||||
+ (I18n.format(
|
||||
Minecraft.getMinecraft().gameSettings.keyBindSneak.getKeyDescription(), new Object[0]))
|
||||
+ " to stop bouncing.");
|
||||
}
|
||||
|
||||
/* Prevent armor from dying */
|
||||
@Override
|
||||
public boolean hasCustomEntity(ItemStack stack) {
|
||||
return true;
|
||||
}
|
||||
/* Prevent armor from dying */
|
||||
@Override
|
||||
public boolean hasCustomEntity(ItemStack stack) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Entity createEntity(World world, Entity location, ItemStack itemstack) {
|
||||
return new FancyEntityItem(world, location, itemstack);
|
||||
}
|
||||
@Override
|
||||
public Entity createEntity(World world, Entity location, ItemStack itemstack) {
|
||||
return new FancyEntityItem(world, location, itemstack);
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,8 @@
|
||||
package tconstruct.gadgets.item;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import java.util.List;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
@@ -24,85 +22,85 @@ import tconstruct.util.network.MovementUpdatePacket;
|
||||
|
||||
public class ItemSlimeSling extends Item {
|
||||
|
||||
public ItemSlimeSling() {
|
||||
this.setMaxStackSize(1);
|
||||
this.setCreativeTab(TConstructRegistry.gadgetsTab);
|
||||
}
|
||||
public ItemSlimeSling() {
|
||||
this.setMaxStackSize(1);
|
||||
this.setCreativeTab(TConstructRegistry.gadgetsTab);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called whenever this item is equipped and the right mouse button is pressed.
|
||||
* Args: itemStack, world, entityPlayer
|
||||
*/
|
||||
@Override
|
||||
public ItemStack onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn) {
|
||||
playerIn.setItemInUse(itemStackIn, this.getMaxItemUseDuration(itemStackIn));
|
||||
return itemStackIn;
|
||||
}
|
||||
/**
|
||||
* Called whenever this item is equipped and the right mouse button is pressed.
|
||||
* Args: itemStack, world, entityPlayer
|
||||
*/
|
||||
@Override
|
||||
public ItemStack onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn) {
|
||||
playerIn.setItemInUse(itemStackIn, this.getMaxItemUseDuration(itemStackIn));
|
||||
return itemStackIn;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIconFromDamage(int meta) {
|
||||
return this.itemIcon;
|
||||
}
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIconFromDamage(int meta) {
|
||||
return this.itemIcon;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons(IIconRegister iconRegister) {
|
||||
this.itemIcon = iconRegister.registerIcon("tinker:gadgets/slimesling");
|
||||
}
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons(IIconRegister iconRegister) {
|
||||
this.itemIcon = iconRegister.registerIcon("tinker:gadgets/slimesling");
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumAction getItemUseAction(ItemStack stack) {
|
||||
return EnumAction.bow;
|
||||
}
|
||||
@Override
|
||||
public EnumAction getItemUseAction(ItemStack stack) {
|
||||
return EnumAction.bow;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxItemUseDuration(ItemStack stack) {
|
||||
return 72000;
|
||||
}
|
||||
@Override
|
||||
public int getMaxItemUseDuration(ItemStack stack) {
|
||||
return 72000;
|
||||
}
|
||||
|
||||
// sling logic
|
||||
@Override
|
||||
public void onPlayerStoppedUsing(ItemStack stack, World world, EntityPlayer player, int timeLeft) {
|
||||
// has to be on ground to do something
|
||||
if (!player.onGround) {
|
||||
return;
|
||||
}
|
||||
// sling logic
|
||||
@Override
|
||||
public void onPlayerStoppedUsing(ItemStack stack, World world, EntityPlayer player, int timeLeft) {
|
||||
// has to be on ground to do something
|
||||
if (!player.onGround) {
|
||||
return;
|
||||
}
|
||||
|
||||
// copy chargeup code from bow \o/
|
||||
int i = this.getMaxItemUseDuration(stack) - timeLeft;
|
||||
float f = i / 20.0F;
|
||||
f = (f * f + f * 2.0F) / 3.0F;
|
||||
f *= 4f;
|
||||
// copy chargeup code from bow \o/
|
||||
int i = this.getMaxItemUseDuration(stack) - timeLeft;
|
||||
float f = i / 20.0F;
|
||||
f = (f * f + f * 2.0F) / 3.0F;
|
||||
f *= 4f;
|
||||
|
||||
if (f > 6f) {
|
||||
f = 6f;
|
||||
}
|
||||
if (f > 6f) {
|
||||
f = 6f;
|
||||
}
|
||||
|
||||
// check if player was targeting a block
|
||||
MovingObjectPosition mop = getMovingObjectPositionFromPlayer(world, player, false);
|
||||
// check if player was targeting a block
|
||||
MovingObjectPosition mop = getMovingObjectPositionFromPlayer(world, player, false);
|
||||
|
||||
if (mop != null && mop.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) {
|
||||
// we fling the inverted player look vector
|
||||
Vec3 vec = player.getLookVec().normalize();
|
||||
if (mop != null && mop.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK) {
|
||||
// we fling the inverted player look vector
|
||||
Vec3 vec = player.getLookVec().normalize();
|
||||
|
||||
player.addVelocity(vec.xCoord * -f, vec.yCoord * -f / 3f, vec.zCoord * -f);
|
||||
player.addVelocity(vec.xCoord * -f, vec.yCoord * -f / 3f, vec.zCoord * -f);
|
||||
|
||||
if (player instanceof EntityPlayerMP) {
|
||||
EntityPlayerMP playerMP = (EntityPlayerMP) player;
|
||||
TConstruct.packetPipeline.sendTo(new MovementUpdatePacket(player), playerMP);
|
||||
playerMP.playerNetServerHandler.sendPacket(new S12PacketEntityVelocity(player));
|
||||
}
|
||||
player.playSound(TinkerGadgets.resource("slimesling"), 1f, 1f);
|
||||
SlimeBounceHandler.addBounceHandler(player);
|
||||
// TinkerCommons.potionSlimeBounce.apply(player);
|
||||
}
|
||||
}
|
||||
if (player instanceof EntityPlayerMP) {
|
||||
EntityPlayerMP playerMP = (EntityPlayerMP) player;
|
||||
TConstruct.packetPipeline.sendTo(new MovementUpdatePacket(player), playerMP);
|
||||
playerMP.playerNetServerHandler.sendPacket(new S12PacketEntityVelocity(player));
|
||||
}
|
||||
player.playSound(TinkerGadgets.resource("slimesling"), 1f, 1f);
|
||||
SlimeBounceHandler.addBounceHandler(player);
|
||||
// TinkerCommons.potionSlimeBounce.apply(player);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean par4) {
|
||||
list.add("Aim at a block behind you to get thrown into the air.");
|
||||
list.add(player.onGround ? "Shoot for the moon!" : "Must be on the ground to use.");
|
||||
}
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean par4) {
|
||||
list.add("Aim at a block behind you to get thrown into the air.");
|
||||
list.add(player.onGround ? "Shoot for the moon!" : "Must be on the ground to use.");
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user