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

Commit

Permalink
Fixed multiple bugs
Browse files Browse the repository at this point in the history
Fixed alt-right click crashing game; Fixed animations not displaying correctly in right hand; Fixed left hand food animation; Removed access to the now useless Battlegear tab through TConstruct; Fixed items not disappearing when there is only one of them left; Fixed main hand not being able to place blocks when playing on a dedicated server;
  • Loading branch information
TCLProject committed Sep 28, 2021
1 parent 0eed693 commit 1d0765c
Show file tree
Hide file tree
Showing 14 changed files with 96 additions and 72 deletions.
6 changes: 2 additions & 4 deletions src/main/java/mods/battlegear2/Battlegear.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.config.Configuration;
import net.minecraftforge.common.util.EnumHelper;
import net.tclproject.theoffhandmod.OffhandConfig;

import java.util.Map;

Expand Down Expand Up @@ -53,7 +54,7 @@ public void preInit(FMLPreInitializationEvent event) {

@Mod.EventHandler
public void init(FMLInitializationEvent event) {
BattlegearConfig.registerRecipes();
if (OffhandConfig.btgearItems) BattlegearConfig.registerRecipes();
QuiverArrowRegistry.addArrowToRegistry(Items.arrow, EntityArrow.class);
packetHandler = new BattlegearPacketHandeler();
packetHandler.register();
Expand All @@ -62,9 +63,6 @@ public void init(FMLInitializationEvent event) {

@Mod.EventHandler
public void postInit(FMLPostInitializationEvent event) {
if(Loader.isModLoaded("TConstruct")){//Tinker's Construct support for tabs in main inventory
proxy.tryUseTConstruct();
}
if(Loader.isModLoaded("DynamicLights_thePlayer")){//Dynamic Light support for held light in left hand
proxy.tryUseDynamicLight(null, null);
}
Expand Down
3 changes: 0 additions & 3 deletions src/main/java/mods/battlegear2/CommonProxy.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,6 @@ public void startFlash(EntityPlayer player, float damage) {

public void doSpecialAction(EntityPlayer entityPlayer, ItemStack item) {}

public void tryUseTConstruct() {
}

public void tryUseDynamicLight(EntityPlayer player, ItemStack stack){
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ else if(isWeapon(off))//A generic weapon
*/
public static boolean usagePriorAttack(ItemStack itemStack){
boolean result = false;
if(itemStack == null) return false;
if(itemStack.getItem() instanceof IUsableItem)
return ((IUsableItem) itemStack.getItem()).isUsedOverAttack(itemStack);
else if(itemStack.getItemUseAction()==EnumAction.drink || itemStack.getItemUseAction()==EnumAction.eat)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,8 @@
import mods.battlegear2.api.core.IBattlePlayer;
import mods.battlegear2.api.core.InventoryPlayerBattle;
import mods.battlegear2.client.gui.BattlegearInGameGUI;
import mods.battlegear2.client.gui.controls.GuiBGInventoryButton;
import mods.battlegear2.client.gui.controls.GuiPlaceableButton;
import mods.battlegear2.client.utils.BattlegearRenderHelper;
import mods.battlegear2.packet.PickBlockPacket;
import net.minecraft.block.Block;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.gui.inventory.GuiContainerCreative;
import net.minecraft.client.model.ModelBiped;
Expand All @@ -28,7 +24,6 @@
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World;
import net.minecraftforge.client.event.GuiScreenEvent;
import net.minecraftforge.client.event.MouseEvent;
import net.minecraftforge.client.event.RenderGameOverlayEvent;
import net.minecraftforge.client.event.RenderLivingEvent;
import net.minecraftforge.client.event.RenderPlayerEvent;
Expand Down
41 changes: 12 additions & 29 deletions src/main/java/mods/battlegear2/client/ClientProxy.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
package mods.battlegear2.client;

import java.lang.reflect.Method;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;

import cpw.mods.fml.client.FMLClientHandler;
import cpw.mods.fml.client.registry.ClientRegistry;
import cpw.mods.fml.common.FMLCommonHandler;
Expand All @@ -12,8 +17,13 @@
import mods.battlegear2.api.core.InventoryPlayerBattle;
import mods.battlegear2.api.heraldry.IHeraldryItem;
import mods.battlegear2.api.shield.IShield;
import mods.battlegear2.client.gui.BattlegearGuiKeyHandler;
import mods.battlegear2.client.renderer.*;
import mods.battlegear2.client.renderer.FlagPoleItemRenderer;
import mods.battlegear2.client.renderer.FlagPoleTileRenderer;
import mods.battlegear2.client.renderer.HeraldryCrestItemRenderer;
import mods.battlegear2.client.renderer.HeraldryItemRenderer;
import mods.battlegear2.client.renderer.QuiverItremRenderer;
import mods.battlegear2.client.renderer.ShieldRenderer;
import mods.battlegear2.client.renderer.SpearRenderer;
import mods.battlegear2.client.utils.BattlegearClientUtils;
import mods.battlegear2.heraldry.TileEntityFlagPole;
import mods.battlegear2.packet.BattlegearAnimationPacket;
Expand All @@ -26,7 +36,6 @@
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.AxisAlignedBB;
Expand All @@ -36,11 +45,6 @@
import net.minecraftforge.client.MinecraftForgeClient;
import net.minecraftforge.common.MinecraftForge;

import java.lang.reflect.Method;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;

public final class ClientProxy extends CommonProxy {

public static boolean tconstructEnabled = false;
Expand All @@ -53,9 +57,6 @@ public final class ClientProxy extends CommonProxy {

@Override
public void registerKeyHandelers() {
if(BattlegearConfig.enableGUIKeys){
FMLCommonHandler.instance().bus().register(BattlegearGuiKeyHandler.INSTANCE);
}
}

@Override
Expand Down Expand Up @@ -218,24 +219,6 @@ else if (movingobjectposition != null)
}
return null;
}

@Override
public void tryUseTConstruct() {
try {
Class tabRegistry = Class.forName("tconstruct.client.tabs.TabRegistry");
Class abstractTab = Class.forName("tconstruct.client.tabs.AbstractTab");
Method registerTab = tabRegistry.getMethod("registerTab", abstractTab);
updateTab = tabRegistry.getMethod("updateTabValues", int.class, int.class, Class.class);
addTabs = tabRegistry.getMethod("addTabsToList", List.class);
registerTab.invoke(null, Class.forName("mods.battlegear2.client.gui.controls.EquipGearTab").newInstance());
if(Battlegear.debug){
registerTab.invoke(null, Class.forName("mods.battlegear2.client.gui.controls.SigilTab").newInstance());
}
} catch (Exception e) {
return;
}
tconstructEnabled = true;
}

@Override
public void tryUseDynamicLight(EntityPlayer player, ItemStack stack){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,10 +227,10 @@ public static void renderItemInFirstPerson(float frame, Minecraft mc, ItemRender
var11 = var11 * var11 * var11;
var12 = 1.0F - var11;
GL11.glTranslatef(0.0F, MathHelper.abs(MathHelper.cos(var21 / 4.0F * (float) Math.PI) * 0.1F) * (float) ((double) var10 > 0.2D ? 1 : 0), 0.0F);
GL11.glTranslatef(var12 * 0.6F, -var12 * 0.5F, 0.0F);
GL11.glRotatef(var12 * 90.0F, 0.0F, 1.0F, 0.0F);
GL11.glRotatef(var12 * 10.0F, 1.0F, 0.0F, 0.0F);
GL11.glRotatef(var12 * 30.0F, 0.0F, 0.0F, 1.0F);
GL11.glTranslatef(var12 * 0.1F, -var12 * 0.1F, 0.0F);
GL11.glRotatef(var12 * 2.0F, 0.0F, 1.0F, 0.0F);
GL11.glRotatef(var12 * 5.0F, 1.0F, 0.0F, 0.0F);
GL11.glRotatef(var12 * 3.0F, 0.0F, 0.0F, 1.0F);
}
} else {
var20 = ((IBattlePlayer)player).getOffSwingProgress(frame);
Expand Down
6 changes: 0 additions & 6 deletions src/main/java/mods/battlegear2/gui/BattlegearGUIHandeler.java
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
package mods.battlegear2.gui;

import cpw.mods.fml.common.network.IGuiHandler;
import mods.battlegear2.client.gui.BattleEquipGUI;
import net.minecraft.client.gui.inventory.GuiInventory;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.ContainerPlayer;
import net.minecraft.world.World;

public final class BattlegearGUIHandeler implements IGuiHandler {
public static final int mainID = 0;
public static final int equipID = 1;
public static final int sigilEditor = 2;
public static final int flagEditor = 3;

Expand All @@ -19,8 +17,6 @@ public Object getServerGuiElement(int ID, EntityPlayer player, World world,
switch (ID) {
case mainID:
return new ContainerPlayer(player.inventory, !world.isRemote, player);
case equipID:
return new ContainerBattle(player.inventory, !world.isRemote, player);
default:
return null;
}
Expand All @@ -33,8 +29,6 @@ public Object getClientGuiElement(int ID, EntityPlayer player, World world,
switch (ID) {
case mainID:
return new GuiInventory(player);
case equipID:
return new BattleEquipGUI(player, world.isRemote);
default:
return null;
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/mods/battlegear2/items/ItemKnightArmour.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package mods.battlegear2.items;

import java.util.List;

import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
Expand Down Expand Up @@ -30,8 +32,6 @@
import net.minecraft.world.World;
import net.minecraftforge.common.ISpecialArmor;

import java.util.List;

public class ItemKnightArmour extends ItemArmor implements IHeraldyArmour, ISpecialArmor{

private IIcon baseIcon[];
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/mods/battlegear2/items/ItemShield.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package mods.battlegear2.items;

import java.util.List;

import cpw.mods.fml.common.IFuelHandler;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.relauncher.Side;
Expand Down Expand Up @@ -28,8 +30,6 @@
import net.minecraft.util.IIcon;
import net.minecraft.util.StatCollector;

import java.util.List;

public class ItemShield extends Item implements IShield, IDyable, IEnchantable, ISheathed, IArrowCatcher, IArrowDisplay, IFuelHandler{

public ShieldType enumShield;
Expand Down
9 changes: 5 additions & 4 deletions src/main/java/mods/battlegear2/items/ItemWeapon.java
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
package mods.battlegear2.items;

import java.util.Iterator;
import java.util.Locale;

import com.google.common.collect.HashMultimap;
import com.google.common.collect.Multimap;

import mods.battlegear2.api.weapons.Attributes;
import mods.battlegear2.api.weapons.IBattlegearWeapon;
import mods.battlegear2.utils.BattlegearConfig;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.ai.attributes.AttributeModifier;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemSword;

import java.util.Iterator;
import java.util.Locale;
//Made this extend the sword class (allows them to be enchanted)
public abstract class ItemWeapon extends ItemSword implements IBattlegearWeapon, Attributes {

Expand All @@ -23,7 +24,7 @@ public ItemWeapon(ToolMaterial material, String named) {
super(material);
//May be unsafe, but will allow others to add weapons using custom materials (also more efficient)
this.material = material;
this.setCreativeTab(BattlegearConfig.customTab);
this.setCreativeTab(BattlegearConfig.customTab);

if(material == ToolMaterial.EMERALD){
this.name = named+".diamond";
Expand Down
7 changes: 4 additions & 3 deletions src/main/java/mods/battlegear2/utils/BattlegearConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import net.minecraftforge.oredict.OreDictionary;
import net.minecraftforge.oredict.RecipeSorter;
import net.minecraftforge.oredict.ShapedOreRecipe;
import net.tclproject.theoffhandmod.OffhandConfig;

import java.lang.reflect.Field;
import java.util.Arrays;
Expand Down Expand Up @@ -122,18 +123,18 @@ public static void getConfig(Configuration config) {
comments[0] = sb.toString();
disabledItems = config.get(config.CATEGORY_GENERAL, "Disabled Items", new String[0], comments[0]).setRequiresMcRestart(true).getStringList();

if(Arrays.deepEquals(disabledItems, itemNames)){
if(Arrays.deepEquals(disabledItems, itemNames) || !(OffhandConfig.btgearItems)){
return;//No point in going further if all items are disabled
}
Arrays.sort(disabledItems);
customTab=new CreativeTabMB_B_2("Battlegear2");

if(Arrays.binarySearch(disabledItems, itemNames[0]) < 0){
heradricItem = new HeraldryCrest().setCreativeTab(customTab).setUnlocalizedName(MODID+itemNames[0]).setTextureName(MODID+"bg-icon");
heradricItem = new HeraldryCrest().setCreativeTab(customTab).setUnlocalizedName(MODID+itemNames[0]).setTextureName(MODID+"bg-icon");
}

if(Arrays.binarySearch(disabledItems, itemNames[10]) < 0){
banner = (BlockFlagPole)new BlockFlagPole().setCreativeTab(customTab).setBlockName(MODID+itemNames[10]);
banner = (BlockFlagPole)new BlockFlagPole().setCreativeTab(customTab).setBlockName(MODID+itemNames[10]);
GameRegistry.registerBlock(banner, ItemBlockFlagPole.class, itemNames[10]);
GameRegistry.registerTileEntity(TileEntityFlagPole.class, MODID+itemNames[10]);
}
Expand Down
Loading

0 comments on commit 1d0765c

Please sign in to comment.