Skip to content

Commit

Permalink
3 bugfixes
Browse files Browse the repository at this point in the history
- Running a dedicated server doesn't crash anymore! I've moved the offending client-side code to the client proxy.
- Some bows were missing mirrored recipes. These have now been added.
- I acidentaly made all bows have the common rarity while tidying up code before. This is now fixed.
  • Loading branch information
NeRdTheNed committed Oct 29, 2020
1 parent d65c672 commit 3ae06bd
Show file tree
Hide file tree
Showing 8 changed files with 112 additions and 121 deletions.
50 changes: 21 additions & 29 deletions src/main/java/iDiamondhunter/morebows/MoreBows.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ public class MoreBows {
/* This is super janky. */
private final static String modSeperator = "morebows:";

public final static Item DiamondBow = new CustomBow(1016, (byte) 0, new byte[] {8, 4}, 2.2F, 6F, 140, 2.25, 36000).setUnlocalizedName(DiamondBowName).setTextureName(modSeperator + DiamondBowName);
public final static Item GoldBow = new CustomBow(550, (byte) 0, new byte[] {8, 4}, 2.4F, 5F, 100, 1.5D).setUnlocalizedName(GoldBowName).setTextureName(modSeperator + GoldBowName);
public final static Item DiamondBow = new CustomBow(1016, (byte) 2, new byte[] {8, 4}, 2.2F, 6F, 140, 2.25, 36000).setUnlocalizedName(DiamondBowName).setTextureName(modSeperator + DiamondBowName);
public final static Item GoldBow = new CustomBow(550, (byte) 1, new byte[] {8, 4}, 2.4F, 5F, 100, 1.5D).setUnlocalizedName(GoldBowName).setTextureName(modSeperator + GoldBowName);
public final static Item EnderBow = new EnderBow().setUnlocalizedName(EnderBowName).setTextureName(modSeperator + EnderBowName);
public final static Item StoneBow = new CustomBow(484, (byte) 0, null, 17F, 1.15D, true).setUnlocalizedName(StoneBowName).setTextureName(modSeperator + StoneBowName);
public final static Item IronBow = new CustomBow(550, (byte) 0, new byte[] {16, 11}, 2.1F, 17F, 105, 1.5D).setUnlocalizedName(IronBowName).setTextureName(modSeperator + IronBowName);
Expand All @@ -68,7 +68,7 @@ public void init(FMLInitializationEvent event) {
registerItems();
registerEntities();
proxy.register();
MinecraftForge.EVENT_BUS.register(new Util());
MinecraftForge.EVENT_BUS.register(proxy);
}

/** TODO Remove before release? */
Expand Down Expand Up @@ -120,34 +120,26 @@ private void registerItems() {
GameRegistry.registerItem(FlameBow, FlameBowName);
GameRegistry.registerItem(FrostBow, FrostBowName);
/** Recipes */
GameRegistry.addRecipe(new ItemStack(StoneBow, 1), " Ss", "TBs", " Ss", 'T', Items.stick, 's', Items.string, 'S',
Blocks.stone, 'B', Items.bow);
GameRegistry.addRecipe(new ItemStack(StoneBow, 1), "sS ", "sBT", "sS ", 'T', Items.stick, 's', Items.string, 'S',
Blocks.stone, 'B', Items.bow);
GameRegistry.addRecipe(new ItemStack(IronBow, 1), " Is", "IBs", " Is", 's', Items.string, 'I', Items.iron_ingot, 'B',
Items.bow);
GameRegistry.addRecipe(new ItemStack(IronBow, 1), "sI ", "sBI", "sI ", 's', Items.string, 'I', Items.iron_ingot, 'B',
Items.bow);
GameRegistry.addRecipe(new ItemStack(GoldBow, 1), " Gs", "GBs", " Gs", 's', Items.string, 'G', Items.gold_ingot, 'B',
Items.bow);
GameRegistry.addRecipe(new ItemStack(GoldBow, 1), "sG ", "sBG", "sG ", 's', Items.string, 'G', Items.gold_ingot, 'B',
Items.bow);
GameRegistry.addRecipe(new ItemStack(DiamondBow, 1), " Ds", "IBs", " Ds", 's', Items.string, 'D', Items.diamond, 'I',
Items.iron_ingot, 'B', Items.bow);
GameRegistry.addRecipe(new ItemStack(DiamondBow, 1), "sD ", "sBI", "sD ", 's', Items.string, 'D', Items.diamond, 'I',
Items.iron_ingot, 'B', Items.bow);
GameRegistry.addRecipe(new ItemStack(StoneBow, 1), " Ss", "TBs", " Ss", 'T', Items.stick, 's', Items.string, 'S', Blocks.stone, 'B', Items.bow);
GameRegistry.addRecipe(new ItemStack(StoneBow, 1), "sS ", "sBT", "sS ", 'T', Items.stick, 's', Items.string, 'S', Blocks.stone, 'B', Items.bow);
GameRegistry.addRecipe(new ItemStack(IronBow, 1), " Is", "IBs", " Is", 's', Items.string, 'I', Items.iron_ingot, 'B', Items.bow);
GameRegistry.addRecipe(new ItemStack(IronBow, 1), "sI ", "sBI", "sI ", 's', Items.string, 'I', Items.iron_ingot, 'B', Items.bow);
GameRegistry.addRecipe(new ItemStack(GoldBow, 1), " Gs", "GBs", " Gs", 's', Items.string, 'G', Items.gold_ingot, 'B', Items.bow);
GameRegistry.addRecipe(new ItemStack(GoldBow, 1), "sG ", "sBG", "sG ", 's', Items.string, 'G', Items.gold_ingot, 'B', Items.bow);
GameRegistry.addRecipe(new ItemStack(DiamondBow, 1), " Ds", "IBs", " Ds", 's', Items.string, 'D', Items.diamond, 'I', Items.iron_ingot, 'B', Items.bow);
GameRegistry.addRecipe(new ItemStack(DiamondBow, 1), "sD ", "sBI", "sD ", 's', Items.string, 'D', Items.diamond, 'I', Items.iron_ingot, 'B', Items.bow);
GameRegistry.addRecipe(new ItemStack(MultiBow, 1), " Bs", "I s", " Bs", 's', Items.string, 'I', Items.iron_ingot, 'B', IronBow);
GameRegistry.addRecipe(new ItemStack(MultiBow, 1), "sB ", "s I", "sB ", 's', Items.string, 'I', Items.iron_ingot, 'B', IronBow);
GameRegistry.addRecipe(new ItemStack(FlameBow, 1), "NB ", "GI ", "NB ", 'G', Items.gold_ingot, 'B', Items.blaze_rod, 'I', IronBow, 'N',
Blocks.netherrack);
GameRegistry.addRecipe(new ItemStack(FlameBow, 1), " NB", " GI", " NB", 'G', Items.gold_ingot, 'B', Items.blaze_rod, 'I', IronBow, 'N',
Blocks.netherrack);
GameRegistry.addRecipe(new ItemStack(EnderBow, 1), "GP ", "EI ", "GP ", 'G', Items.gold_ingot, 'P', Items.ender_pearl, 'I', IronBow, 'E',
Items.ender_eye);
GameRegistry.addRecipe(new ItemStack(EnderBow, 1), " GP", " EI", " GP", 'G', Items.gold_ingot, 'P', Items.ender_pearl, 'I', IronBow, 'E',
Items.ender_eye);
GameRegistry.addRecipe(new ItemStack(FrostBow, 1), " IR", "SER", " IR", 'R', Items.string, 'I', Blocks.ice, 'S',
Items.snowball, 'E', IronBow);
GameRegistry.addRecipe(new ItemStack(FlameBow, 1), "NB ", "GI ", "NB ", 'G', Items.gold_ingot, 'B', Items.blaze_rod, 'I', IronBow, 'N', Blocks.netherrack);
GameRegistry.addRecipe(new ItemStack(FlameBow, 1), " NB", " GI", " NB", 'G', Items.gold_ingot, 'B', Items.blaze_rod, 'I', IronBow, 'N', Blocks.netherrack);
GameRegistry.addRecipe(new ItemStack(FlameBow, 1), "BN ", "IG ", "BN ", 'G', Items.gold_ingot, 'B', Items.blaze_rod, 'I', IronBow, 'N', Blocks.netherrack);
GameRegistry.addRecipe(new ItemStack(FlameBow, 1), " BN", " IG", " BN", 'G', Items.gold_ingot, 'B', Items.blaze_rod, 'I', IronBow, 'N', Blocks.netherrack);
GameRegistry.addRecipe(new ItemStack(EnderBow, 1), "GP ", "EI ", "GP ", 'G', Items.gold_ingot, 'P', Items.ender_pearl, 'I', IronBow, 'E', Items.ender_eye);
GameRegistry.addRecipe(new ItemStack(EnderBow, 1), " GP", " EI", " GP", 'G', Items.gold_ingot, 'P', Items.ender_pearl, 'I', IronBow, 'E', Items.ender_eye);
GameRegistry.addRecipe(new ItemStack(EnderBow, 1), "PG ", "IE ", "PG ", 'G', Items.gold_ingot, 'P', Items.ender_pearl, 'I', IronBow, 'E', Items.ender_eye);
GameRegistry.addRecipe(new ItemStack(EnderBow, 1), " PG", " IE", " PG", 'G', Items.gold_ingot, 'P', Items.ender_pearl, 'I', IronBow, 'E', Items.ender_eye);
GameRegistry.addRecipe(new ItemStack(FrostBow, 1), " IR", "SER", " IR", 'R', Items.string, 'I', Blocks.ice, 'S', Items.snowball, 'E', IronBow);
GameRegistry.addRecipe(new ItemStack(FrostBow, 1), "RI ", "RES", "RI ", 'R', Items.string, 'I', Blocks.ice, 'S', Items.snowball, 'E', IronBow);
}

}
84 changes: 0 additions & 84 deletions src/main/java/iDiamondhunter/morebows/Util.java

This file was deleted.

10 changes: 7 additions & 3 deletions src/main/java/iDiamondhunter/morebows/bows/CustomBow.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,17 +54,21 @@ public CustomBow(int maxDamage, byte rarity, byte[] iconTimes) {
EnumRarity detRare;

switch (rarity) {
case 0:
case (byte) 1:
detRare = EnumRarity.uncommon;
break;

case 1:
case (byte) 2:
detRare = EnumRarity.rare;
break;

case 2:
case (byte) 3:
detRare = EnumRarity.epic;
break;

default:
detRare = EnumRarity.common;
break;
}

this.rarity = detRare;
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/iDiamondhunter/morebows/bows/EnderBow.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package iDiamondhunter.morebows.bows;

import iDiamondhunter.morebows.Util;
import iDiamondhunter.morebows.entities.ArrowSpawner;
import iDiamondhunter.morebows.entities.CustomArrow;
import iDiamondhunter.morebows.proxy.Common;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.projectile.EntityArrow;
Expand All @@ -14,15 +14,15 @@
public class EnderBow extends CustomBow {

public EnderBow() {
super(384, (byte) 0, null, 22F);
super(384, (byte) 3, null, 22F);
MinecraftForge.EVENT_BUS.register(this);
}

/** TODO Document */
@Override
public boolean onEntitySwing(EntityLivingBase entityLiving, ItemStack stack) {
if (!entityLiving.worldObj.isRemote) {
Util.spawnParticle((WorldServer) entityLiving.worldObj, entityLiving, "portal");
Common.spawnParticle((WorldServer) entityLiving.worldObj, entityLiving, "portal");
}

return false;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/iDiamondhunter/morebows/bows/FlameBow.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

public class FlameBow extends CustomBow {
public FlameBow() {
super(576, (byte) 0, new byte[] {14, 9}, 15F, 2.0D);
super(576, (byte) 1, new byte[] {14, 9}, 15F, 2.0D);
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/iDiamondhunter/morebows/bows/MultiBow.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public class MultiBow extends CustomBow {
protected boolean thirdArrow = false;

public MultiBow() {
super(550, (byte) 0, new byte[] {12, 7}, 13F);
super(550, (byte) 2, new byte[] {12, 7}, 13F);
}

@Override
Expand Down
20 changes: 20 additions & 0 deletions src/main/java/iDiamondhunter/morebows/proxy/Client.java
Original file line number Diff line number Diff line change
@@ -1,15 +1,35 @@
package iDiamondhunter.morebows.proxy;

import cpw.mods.fml.client.registry.RenderingRegistry;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import iDiamondhunter.morebows.bows.CustomBow;
import iDiamondhunter.morebows.client.NoRender;
import iDiamondhunter.morebows.entities.ArrowSpawner;
import iDiamondhunter.morebows.entities.FrostArrow;
import net.minecraft.client.renderer.entity.RenderSnowball;
import net.minecraft.init.Items;
import net.minecraftforge.client.event.FOVUpdateEvent;

/** TODO Remove if not needed */
public class Client extends Common {

@SubscribeEvent
public void FOVUpdate(FOVUpdateEvent event) {
if ((event.entity.getItemInUse() != null) && (event.entity.getItemInUse().getItem() instanceof CustomBow)) {
// See net.minecraft.client.entity.EntityPlayerSP.getFOVMultiplier()
final CustomBow bow = (CustomBow) event.entity.getItemInUse().getItem();
float f1 = (float) event.entity.getItemInUseDuration() / (float) (bow.iconTimes[0] * (10 / 9));

if (f1 > 1.0F) {
f1 = 1.0F;
} else {
f1 *= f1;
}

event.newfov *= 1.0F - (f1 * 0.15F);
}
}

@Override
public void register() {
RenderingRegistry.registerEntityRenderingHandler(ArrowSpawner.class, new NoRender());
Expand Down
Loading

0 comments on commit 3ae06bd

Please sign in to comment.