Skip to content

Commit

Permalink
Endrod trait reduces inaccuracy because of rounding now
Browse files Browse the repository at this point in the history
  • Loading branch information
bonii-xx committed Nov 27, 2016
1 parent 8291b44 commit ec65e5e
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -138,22 +138,24 @@ public static class OnBowShoot extends TinkerToolEvent {
public final BowCore bowCore;
public final ItemStack ammo;
public final int useTime;
private float baseInaccuracy;

public int projectileCount = 1;
public boolean consumeAmmoPerProjectile = true;
public boolean consumeDurabilityPerProjectile = true;
public float bonusInaccuracy = 0;

public OnBowShoot(ItemStack bow, ItemStack ammo, EntityPlayer entityPlayer, int useTime) {
public OnBowShoot(ItemStack bow, ItemStack ammo, EntityPlayer entityPlayer, int useTime, float baseInaccuracy) {
super(bow);
this.bowCore = (BowCore) bow.getItem();
this.ammo = ammo;
this.entityPlayer = entityPlayer;
this.useTime = useTime;
this.baseInaccuracy = baseInaccuracy;
}

public static OnBowShoot fireEvent(ItemStack bow, ItemStack ammo, EntityPlayer entityPlayer , int useTime) {
OnBowShoot event = new OnBowShoot(bow, ammo, entityPlayer, useTime);
public static OnBowShoot fireEvent(ItemStack bow, ItemStack ammo, EntityPlayer entityPlayer, int useTime, float baseInaccuracy) {
OnBowShoot event = new OnBowShoot(bow, ammo, entityPlayer, useTime, baseInaccuracy);
MinecraftForge.EVENT_BUS.post(event);
return event;
}
Expand All @@ -173,5 +175,13 @@ public void setConsumeDurabilityPerProjectile(boolean consumeDurabilityPerProjec
public void setBonusInaccuracy(float bonusInaccuracy) {
this.bonusInaccuracy = bonusInaccuracy;
}

public float getBaseInaccuracy() {
return baseInaccuracy;
}

public void setBaseInaccuracy(float baseInaccuracy) {
this.baseInaccuracy = baseInaccuracy;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -186,14 +186,14 @@ public void shootProjectile(ItemStack ammo, ItemStack bow, World worldIn, Entity
power *= ProjectileLauncherNBT.from(bow).range;

if(!worldIn.isRemote) {
TinkerToolEvent.OnBowShoot event = TinkerToolEvent.OnBowShoot.fireEvent(bow, ammo, player, useTime);
TinkerToolEvent.OnBowShoot event = TinkerToolEvent.OnBowShoot.fireEvent(bow, ammo, player, useTime, baseInaccuracy());

for(int i = 0; i < event.projectileCount; i++) {
boolean usedAmmo = false;
if(i == 0 || event.consumeAmmoPerProjectile) {
usedAmmo = consumeAmmo(ammo, player);
}
float inaccuracy = baseInaccuracy();
float inaccuracy = event.getBaseInaccuracy();
if(i > 0) {
inaccuracy += event.bonusInaccuracy;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,34 @@
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;

import javax.annotation.Nullable;

import slimeknights.tconstruct.library.client.particle.Particles;
import slimeknights.tconstruct.library.entity.EntityProjectileBase;
import slimeknights.tconstruct.library.events.TinkerToolEvent;
import slimeknights.tconstruct.library.traits.AbstractProjectileTrait;
import slimeknights.tconstruct.library.utils.TagUtil;
import slimeknights.tconstruct.library.utils.TinkerUtil;
import slimeknights.tconstruct.tools.ranged.TinkerRangedWeapons;

public class TraitEndspeed extends AbstractProjectileTrait {

public TraitEndspeed() {
super("endspeed", 0xffffff);

MinecraftForge.EVENT_BUS.register(this);
}



@SubscribeEvent
public void onBowShooting(TinkerToolEvent.OnBowShoot event) {
if(TinkerUtil.hasTrait(TagUtil.getTagSafe(event.ammo), this.getModifierIdentifier())) {
event.setBaseInaccuracy(event.getBaseInaccuracy()*2f/3f);
}
}

@Override
Expand Down

0 comments on commit ec65e5e

Please sign in to comment.