Skip to content

Commit

Permalink
Fix some internal rendering discrepancies with loaded crossbow ammo a…
Browse files Browse the repository at this point in the history
…nd prevent possible crashes from corrupt NBT/worlds/whatever
  • Loading branch information
bonii-xx committed Feb 27, 2015
1 parent 478052b commit 4b240ac
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
Expand Up @@ -13,6 +13,7 @@
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import org.lwjgl.opengl.GL11;
import tconstruct.weaponry.entity.BoltEntity;

public class BowRenderer extends FlexibleToolRenderer {
private static final ArrowEntity dummy = new ArrowEntity(null);
Expand Down Expand Up @@ -84,7 +85,7 @@ else if(type == ItemRenderType.EQUIPPED && player.isUsingItem())
// we're crazy, so.. render the arrow =D
ItemStack ammo = ((ProjectileWeapon) item.getItem()).searchForAmmo(player, item); // we know it's a projectile weapon, it's a bow!
if(ammo != null) {
if(ammo.getItem() == Items.arrow)
if(ammo.getItem() == Items.arrow || !(ammo.getItem() instanceof ArrowAmmo))
dummy.returnStack = ArrowAmmo.vanillaArrow;
else
dummy.returnStack = ammo;
Expand Down
@@ -1,6 +1,8 @@
package tconstruct.weaponry.client.item;

import tconstruct.client.FlexibleToolRenderer;
import tconstruct.weaponry.TinkerWeaponry;
import tconstruct.weaponry.ammo.BoltAmmo;
import tconstruct.weaponry.entity.ArrowEntity;
import tconstruct.weaponry.entity.BoltEntity;
import tconstruct.weaponry.weapons.Crossbow;
Expand Down Expand Up @@ -45,7 +47,10 @@ protected void specialAnimation(ItemRenderType type, ItemStack item) {
//float progress = crossbow.getWindupProgress(item, player);
float progress = 1f;
dummy.returnStack = ammo;
Render renderer = RenderManager.instance.getEntityClassRenderObject(ArrowEntity.class);
if(!(ammo.getItem() instanceof BoltAmmo))
dummy.returnStack = TinkerWeaponry.creativeBolt;

Render renderer = RenderManager.instance.getEntityClassRenderObject(BoltEntity.class);

GL11.glPushMatrix();
// adjust position
Expand Down

0 comments on commit 4b240ac

Please sign in to comment.