Skip to content
This repository has been archived by the owner on Jan 25, 2020. It is now read-only.

Master #6

Closed
wants to merge 10 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion assets/modtutoriel/lang/en_US.lang
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ item.TutorialAxe.name=Tutorial Axe
item.TutorialShovel.name=Tutorial Shovel
item.TutorialHoe.name=Tutorial Hoe
item.bucketTutorial.name=Tutorial Bucket
item.Tuto_Bow.name=Bow tutorial

item.record.cd.desc=Tutorial record

Expand All @@ -65,4 +66,4 @@ container.bigchest=Big Chest
container.cupboard=Cupboard

#Other
last.users=Last users : %s
last.users=Last users : %s
3 changes: 2 additions & 1 deletion assets/modtutoriel/lang/fr_FR.lang
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ item.TutorialAxe.name=Hache tutoriel
item.TutorialShovel.name=Pelle tutoriel
item.TutorialHoe.name=Houe tutoriel
item.bucketTutorial.name=Seau tutoriel
item.Tuto_Bow.name=Arc tutoriel

item.record.cd.desc=Cd disque

Expand All @@ -65,4 +66,4 @@ container.bigchest=Grand coffre
container.cupboard=Placard

#Other
last.users=Derniers utilisateurs : %s
last.users=Derniers utilisateurs : %s
Binary file added assets/modtutoriel/textures/items/tuto_bow.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/modtutoriel/textures/items/tuto_bow_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/modtutoriel/textures/items/tuto_bow_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/modtutoriel/textures/items/tuto_bow_3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 5 additions & 3 deletions tutoriel/common/ModTutoriel.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public class ModTutoriel

// declaration des blocs - blocks statement
public static Block BlockTutorial, TutorialMetadata, StairsTutorial, DoubleSlabTuto, SingleSlabTuto, BlockTutorialCake, BlockNewFenceTutorial, BlockNewWallTutorial, blockFluidTutorial, blockTable, blockSculpture;
public static Item ItemTutorial, ItemWithMetadata, TutorialHelmet, TutorialChestPlate, TutorialLeggings, TutorialBoots, TutorialEgg, TutorialSword, TutorialPickaxe, TutorialAxe, TutorialShovel, TutorialHoe, ItemTutorialCake, ItemCdTutorial, bucketTutorial;
public static Item ItemTutorial, ItemWithMetadata, TutorialHelmet, TutorialChestPlate, TutorialLeggings, TutorialBoots, TutorialEgg, TutorialSword, TutorialPickaxe, TutorialAxe, TutorialShovel, TutorialHoe, ItemTutorialCake, ItemCdTutorial, bucketTutorial, Tuto_Bow;
public static Fluid fluidTutorial;

static ArmorMaterial TutorialArmor = EnumHelper.addArmorMaterial("Tutorial", 20, new int[] {2, 8, 4, 2}, 15);
Expand Down Expand Up @@ -110,7 +110,8 @@ public void PreInit(FMLPreInitializationEvent event)
ItemTutorialCake = new ItemTutorialCake().setUnlocalizedName("TurorialGateauItem").setTextureName("modtutoriel:TutorialCake");
ItemCdTutorial = new ItemCdTutorial("cd").setUnlocalizedName("record").setCreativeTab(ModTutoriel.TutorialCreativeTabs);
bucketTutorial = new ItemBucketTutorial(blockFluidTutorial).setUnlocalizedName("bucketTutorial").setTextureName("modtutoriel:bucketTutorial");

Tuto_Bow = new Tuto_Bow().setUnlocalizedName("Tuto_Bow").setTextureName("modtutoriel:tuto_bow");

// Enregistrement des items - Item registry
GameRegistry.registerItem(ItemTutorial, "ItemTutorial", "ModTutoriel");
GameRegistry.registerItem(ItemWithMetadata, "ItemWithMetadata", "ModTutoriel");
Expand All @@ -127,6 +128,7 @@ public void PreInit(FMLPreInitializationEvent event)
GameRegistry.registerItem(ItemTutorialCake, "TutorialGateauItem", "ModTutoriel");
GameRegistry.registerItem(ItemCdTutorial, "item_cd_tutoriel");
GameRegistry.registerItem(bucketTutorial, "BucketTutorial", "ModTutoriel");
GameRegistry.registerItem(Tuto_Bow, "Tuto_Bow", "ModTutoriel");

FluidContainerRegistry.registerFluidContainer(FluidRegistry.getFluidStack("tutorial", FluidContainerRegistry.BUCKET_VOLUME), new ItemStack(bucketTutorial), FluidContainerRegistry.EMPTY_BUCKET);

Expand Down Expand Up @@ -182,4 +184,4 @@ public void serverStarting(FMLServerStartingEvent event)
{
event.registerServerCommand(new CommandTutoriel());
}
}
}
188 changes: 188 additions & 0 deletions tutoriel/common/Tuto_Bow.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,188 @@
package tutoriel.common;

import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.enchantment.Enchantment;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.projectile.EntityArrow;
import net.minecraft.init.Items;
import net.minecraft.item.EnumAction;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBow;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import net.minecraft.world.World;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.entity.player.ArrowLooseEvent;
import net.minecraftforge.event.entity.player.ArrowNockEvent;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;

public class Tuto_Bow extends Item
{
public static final String[] bowPullIconNameArray = new String[] {"1", "2", "3"};
@SideOnly(Side.CLIENT)
private IIcon[] iconArray;


public Tuto_Bow()
{
this.maxStackSize = 1;
this.setMaxDamage(700);
this.setFull3D();
}

/**
* called when the player releases the use item button. Args: itemstack, world, entityplayer, itemInUseCount
*/

public void onPlayerStoppedUsing(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer, int par4)
{
int j = this.getMaxItemUseDuration(par1ItemStack) - par4;

ArrowLooseEvent event = new ArrowLooseEvent(par3EntityPlayer, par1ItemStack, j);
MinecraftForge.EVENT_BUS.post(event);
if (event.isCanceled())
{
return;
}
j = event.charge;

boolean flag = par3EntityPlayer.capabilities.isCreativeMode || EnchantmentHelper.getEnchantmentLevel(Enchantment.infinity.effectId, par1ItemStack) > 0;

if (flag || par3EntityPlayer.inventory.hasItem(Items.arrow))
{
float f = (float)j / 20.0F;
f = (f * f + f * 2.0F) / 3.0F;

if ((double)f < 0.1D)
{
return;
}

if (f > 1.0F)
{
f = 1.0F;
}

EntityArrow entityarrow = new EntityArrow(par2World, par3EntityPlayer, f * 3.0F);

if (f == 1.0F)
{
entityarrow.setIsCritical(true);
}

int k = EnchantmentHelper.getEnchantmentLevel(Enchantment.power.effectId, par1ItemStack);

if (k > 0)
{
entityarrow.setDamage(entityarrow.getDamage() + (double)k * 1D + 1D);
}

int l = EnchantmentHelper.getEnchantmentLevel(Enchantment.punch.effectId, par1ItemStack);

if (l > 0)
{
entityarrow.setKnockbackStrength(0);
}

if (EnchantmentHelper.getEnchantmentLevel(Enchantment.flame.effectId, par1ItemStack) > 0)
{
entityarrow.setFire(130);
}

par1ItemStack.damageItem(1, par3EntityPlayer);
par2World.playSoundAtEntity(par3EntityPlayer, "random.bow", 1.0F, 1.0F / (itemRand.nextFloat() * 0.4F + 1.2F) + f * 0.5F);

if (flag)
{
entityarrow.canBePickedUp = 2;
}
else
{
par3EntityPlayer.inventory.consumeInventoryItem(Items.arrow);
}

if (!par2World.isRemote)
{
par2World.spawnEntityInWorld(entityarrow);
}
}
}
/**
* How long it takes to use or consume an item
*/

public int getMaxItemUseDuration(ItemStack par1ItemStack)
{
return 8000; //temps avant chaque utilisation
}

/**
* returns the action that specifies what animation to play when the items is being used
*/

public EnumAction getItemUseAction(ItemStack par1ItemStack)
{
return EnumAction.bow;
}
/**
* Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer
*/
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
{
ArrowNockEvent event = new ArrowNockEvent(par3EntityPlayer, par1ItemStack);
MinecraftForge.EVENT_BUS.post(event);
if (event.isCanceled())
{
return event.result;
}

if (par3EntityPlayer.capabilities.isCreativeMode || par3EntityPlayer.inventory.hasItem(Items.arrow))
{
par3EntityPlayer.setItemInUse(par1ItemStack, this.getMaxItemUseDuration(par1ItemStack));
}

return par1ItemStack;
}

/**
* Return the enchantability factor of the item, most of the time is based on material.
*/
public int getItemEnchantability()
{
return 1;
}

@SideOnly(Side.CLIENT)
public void registerIcons(IIconRegister par1IconRegister)
{
this.itemIcon = par1IconRegister.registerIcon(this.getIconString());
this.iconArray = new IIcon[bowPullIconNameArray.length];

for (int i = 0; i < this.iconArray.length; ++i)
{
this.iconArray[i] = par1IconRegister.registerIcon(this.getIconString() + "_" + bowPullIconNameArray[i]);
}
}

/**
* used to cycle through icons based on their used duration, i.e. for the bow
*/
@Override
public IIcon getIcon(ItemStack stack, int renderPass, EntityPlayer player, ItemStack usingItem, int useRemaining)
{
if(usingItem != null && usingItem.getItem().equals(this))
{
int k = usingItem.getMaxItemUseDuration() - useRemaining;
if(k >= 18)
return iconArray[2];
if(k > 13)
return iconArray[1];
if(k > 0)
return iconArray[0];
}
return getIconIndex(stack);
}
}