Skip to content

Commit

Permalink
McCree done
Browse files Browse the repository at this point in the history
  • Loading branch information
2piradians committed Jun 18, 2017
1 parent ab4b798 commit 78fc389
Show file tree
Hide file tree
Showing 12 changed files with 70 additions and 26 deletions.
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
package twopiradians.minewatch.common.item.weapon;

import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumHand;
import net.minecraft.util.SoundCategory;
import net.minecraft.world.World;
import twopiradians.minewatch.common.Minewatch;
import twopiradians.minewatch.common.entity.EntityMcCreeBullet;
import twopiradians.minewatch.common.item.ModItems;
import twopiradians.minewatch.common.item.armor.ModArmor;
import twopiradians.minewatch.common.sound.ModSoundEvents;

public class ItemMcCreeGun extends ModWeapon
Expand All @@ -17,13 +22,46 @@ public ItemMcCreeGun() {
this.material = ModItems.mccree;
this.cooldown = 10;
}


/** How long it takes to use or consume an item*/
@Override
public int getMaxItemUseDuration(ItemStack stack) {
return 20;
}

@Override
public void onShoot(World worldIn, EntityPlayer playerIn, EnumHand hand) {
if (!worldIn.isRemote) {
worldIn.spawnEntity(new EntityMcCreeBullet(worldIn));
EntityMcCreeBullet bullet = new EntityMcCreeBullet(worldIn, playerIn);
bullet.setAim(playerIn, playerIn.rotationPitch, playerIn.rotationYaw, 2.0F, 0.3F);
worldIn.spawnEntity(bullet);
worldIn.playSound(null, playerIn.posX, playerIn.posY, playerIn.posZ,
ModSoundEvents.mccreeGun, SoundCategory.PLAYERS, 1.0f, worldIn.rand.nextFloat()/2+0.75f);
}
}

@Override
public void onUsingTick(ItemStack stack, EntityLivingBase player, int count) {
if (!player.world.isRemote && player instanceof EntityPlayer) {
if (Minewatch.keyMode.isKeyDown((EntityPlayer) player) && count % 3 == 0 && player.getHeldItemMainhand() != null && player.getHeldItemMainhand().getItem() != Items.AIR && player.getHeldItemMainhand().getItem() instanceof ItemMcCreeGun) {
EntityMcCreeBullet bullet = new EntityMcCreeBullet(player.world, player);
bullet.setAim(player, player.rotationPitch, player.rotationYaw, 2.0F, 0.3F);
player.world.spawnEntity(bullet);
player.world.playSound(null, player.posX, player.posY, player.posZ, ModSoundEvents.mccreeGun, SoundCategory.PLAYERS, 1.0f, player.world.rand.nextFloat()/20+0.95f);
if (!ModArmor.isSet((EntityPlayer)player, ModItems.mccree))
player.getHeldItemMainhand().damageItem(1, player);
}
else if (Minewatch.keyMode.isKeyDown((EntityPlayer) player) && count % 3 == 0 && player.getHeldItemOffhand() != null && player.getHeldItemOffhand().getItem() != Items.AIR && player.getHeldItemOffhand().getItem() instanceof ItemMcCreeGun) {
EntityMcCreeBullet bullet = new EntityMcCreeBullet(player.world, player);
bullet.setAim(player, player.rotationPitch, player.rotationYaw, 2.0F, 0.3F);
player.world.spawnEntity(bullet);
player.world.playSound(null, player.posX, player.posY, player.posZ, ModSoundEvents.mccreeGun, SoundCategory.PLAYERS, 1.0f, player.world.rand.nextFloat()/20+0.95f);
if (!ModArmor.isSet((EntityPlayer)player, ModItems.mccree))
player.getHeldItemOffhand().damageItem(1, player);
}

if (count <= 1)
doCooldown((EntityPlayer)player, player.getActiveHand());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer play
&& !playerIn.getCooldownTracker().hasCooldown(playerIn.getHeldItem(hand).getItem())
&& (!hasOffhand || (playerIn.getHeldItem(hand).hasTagCompound() && playerIn.getHeldItem(hand).getTagCompound().getInteger("cooldown") <= 0))) {

//McCree
if (playerIn.getHeldItem(hand).getItem() instanceof ItemMcCreeGun && Minewatch.keyMode.isKeyDown( playerIn)) {
playerIn.setActiveHand(hand);
return new ActionResult<ItemStack>(EnumActionResult.PASS, playerIn.getHeldItem(hand));
}

//Genji Shuriken onUsingTick
if (!worldIn.isRemote && playerIn.getHeldItem(hand).getItem() instanceof ItemGenjiShuriken && !Minewatch.keyMode.isKeyDown(playerIn)) {
((ItemGenjiShuriken)playerIn.getHeldItem(hand).getItem()).onUsingTick(playerIn.getHeldItem(hand), playerIn, ++((ItemGenjiShuriken)playerIn.getHeldItem(hand).getItem()).multiShot);
Expand Down
40 changes: 20 additions & 20 deletions src/main/resources/assets/minewatch/blockstates/mccree_gun_3d.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,39 +8,39 @@
{
"transform": {
"thirdperson_lefthand": {
"rotation": [ { "x": -108 }, { "y": 90 }, { "z": 180 } ],
"translation": [ 0.04, 0.25, -0.15 ],
"scale": [ 0.09, 0.09, 0.09 ]
"rotation": [ { "x": 75 }, { "y": 180 }, { "z": 0 } ],
"translation": [ 0.3, 0.3, 0.4 ],
"scale": [ 0.6, 0.6, 0.6 ]
},
"thirdperson_righthand": {
"rotation": [ { "x": -108 }, { "y": 270 }, { "z": 180 } ],
"translation": [ -0.04, 0.31, -0.15 ],
"scale": [ 0.09, 0.09, 0.09 ]
"rotation": [ { "x": 75 }, { "y": 180 }, { "z": 0 } ],
"translation": [ -0.3, 0.3, 0.4 ],
"scale": [ 0.6, 0.6, 0.6 ]
},
"gui": {
"rotation": [ { "x": -167 }, { "y": -25 }, { "z": -180 } ],
"translation": [ 0.02, -0.33, 0.00 ],
"scale": [ 0.13, 0.13, 0.13 ]
"rotation": [ { "x": -167 }, { "y": -90 }, { "z": -180 } ],
"translation": [ 0.0, 0.2, 0.0 ],
"scale": [ 0.6, 0.6, 0.6 ]
},
"firstperson_righthand": {
"rotation": [ { "x": 180 }, { "y": 285 }, { "z": 180 } ],
"translation": [ -0.09, 0.15, 0.05 ],
"scale": [ 0.07, 0.07, 0.07 ]
"rotation": [ { "x": 0 }, { "y": 180 }, { "z": 0 } ],
"translation": [ -0.3, 0.5, 0.0 ],
"scale": [ 0.5, 0.5, 0.5 ]
},
"firstperson_lefthand": {
"rotation": [ { "x": 180 }, { "y": 105 }, { "z": 180 } ],
"translation": [ -0.0, 0.15, 0.05 ],
"scale": [ 0.07, 0.07, 0.07 ]
"rotation": [ { "x": 0 }, { "y": 180 }, { "z": 0 } ],
"translation": [ 0.2, 0.5, 0.0 ],
"scale": [ 0.5, 0.5, 0.5 ]
},
"ground": {
"rotation": [ { "x": 0 }, { "y": 0 }, { "z": 0 } ],
"translation": [ 0, 0.08, 0.075 ],
"scale": [ 0.07, 0.07, 0.07 ]
"translation": [ 0, 0.5, 0 ],
"scale": [ 0.5, 0.5, 0.5 ]
},
"fixed": {
"rotation": [ { "x": 0 }, { "y": 0 }, { "z": 0 } ],
"translation": [ -0.06, -0.33, 0 ],
"scale": [ 0.13, 0.13, 0.13 ]
"rotation": [ { "x": 0 }, { "y": 90 }, { "z": 0 } ],
"translation": [ 0.0, 0.2, -0.4 ],
"scale": [ 0.7, 0.7, 0.7 ]
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
},
"display": {
"thirdperson_righthand": {
"rotation": [ 45, -90, 0 ],
"translation": [ 0, 6, 2 ],
"rotation": [ 75, -90, 0 ],
"translation": [ 0, 5, 3 ],
"scale": [ 1, 1, 1 ]
},
"thirdperson_lefthand": {
"rotation": [ 45, 90, 0 ],
"translation": [ 0, 6, 2 ],
"rotation": [ 75, 90, 0 ],
"translation": [ 0, 5, 3 ],
"scale": [ 1, 1, 1 ]
},
"firstperson_righthand": {
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/main/resources/assets/minewatch/textures/items/mccree_gun.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 78fc389

Please sign in to comment.