so I'm trying to make a ichigo that can switch between bankai and shikai. To do this I made a packet (code below) that causes the characters to switch. The problem is that it will say the text but it will stay bankai. It will also automatically do this without pressing of a key button. It will switch armors and it might switch the weapon it just happens so fast that I can't tell. The only reason I know it switches the armors is becuase it is stuck in bankai mode. Help is much appreciated. also if you try to delete it from your inventory it says there is a fatal error and the game shuts down. the crash report will also be there
error:
java.lang.NullPointerException
at com.BearOfDoom.Packets.BankaiIchigoPacket.onMessage(BankaiIchigoPacket.java:66) ~[BankaiIchigoPacket.class:?]
at com.BearOfDoom.Packets.BankaiIchigoPacket.onMessage(BankaiIchigoPacket.java:1) ~[BankaiIchigoPacket.class:?]
at cpw.mods.fml.common.network.simpleimpl.SimpleChannelHandlerWrapper.channelRead0(SimpleChannelHandlerWrapper.java:37) ~[SimpleChannelHandlerWrapper.class:?]
at cpw.mods.fml.common.network.simpleimpl.SimpleChannelHandlerWrapper.channelRead0(SimpleChannelHandlerWrapper.java:17) ~[SimpleChannelHandlerWrapper.class:?]
at io.netty.channel.SimpleChannelInboundHandler.channelRead(SimpleChannelInboundHandler.java:98) ~[SimpleChannelInboundHandler.class:?]
at io.netty.channel.DefaultChannelHandlerContext.invokeChannelRead(DefaultChannelHandlerContext.java:337) ~[DefaultChannelHandlerContext.class:?]
at io.netty.channel.DefaultChannelHandlerContext.fireChannelRead(DefaultChannelHandlerContext.java:323) ~[DefaultChannelHandlerContext.class:?]
at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:103) ~[MessageToMessageDecoder.class:?]
at io.netty.handler.codec.MessageToMessageCodec.channelRead(MessageToMessageCodec.java:111) ~[MessageToMessageCodec.class:?]
at io.netty.channel.DefaultChannelHandlerContext.invokeChannelRead(DefaultChannelHandlerContext.java:337) ~[DefaultChannelHandlerContext.class:?]
at io.netty.channel.DefaultChannelHandlerContext.fireChannelRead(DefaultChannelHandlerContext.java:323) ~[DefaultChannelHandlerContext.class:?]
at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:785) ~[DefaultChannelPipeline.class:?]
at io.netty.channel.embedded.EmbeddedChannel.writeInbound(EmbeddedChannel.java:169) ~[EmbeddedChannel.class:?]
at cpw.mods.fml.common.network.internal.FMLProxyPacket.processPacket(FMLProxyPacket.java:86) [FMLProxyPacket.class:?]
at net.minecraft.network.NetworkManager.processReceivedPackets(NetworkManager.java:241) [NetworkManager.class:?]
at net.minecraft.network.NetworkSystem.networkTick(NetworkSystem.java:182) [NetworkSystem.class:?]
at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:726) [MinecraftServer.class:?]
at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:614) [MinecraftServer.class:?]
at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:118) [IntegratedServer.class:?]
at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:485) [MinecraftServer.class:?]
at net.minecraft.server.MinecraftServer$2.run(MinecraftServer.java:752) [MinecraftServer$2.class:?]
Main:
[/p]
[p]import net.minecraft.item.Item.ToolMaterial;
import net.minecraft.item.ItemArmor.ArmorMaterial;
import net.minecraftforge.common.config.Configuration;
import net.minecraftforge.common.util.EnumHelper;[/p]
[p]import com.BearOfDoom.Armor.animeArmor;
import com.BearOfDoom.CreativeTabs.animeTabs;
import com.BearOfDoom.EntityProjectiles.EntityBgetsugaTensho;
import com.BearOfDoom.EntityProjectiles.EntitygetsugaTensho;
import com.BearOfDoom.Items.animeItems;
import com.BearOfDoom.Packets.PacketHandler;
import com.BearOfDoom.Proxy.CommonProxy;[/p]
[p]import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.EventHandler;
import cpw.mods.fml.common.Mod.Instance;
import cpw.mods.fml.common.SidedProxy;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.network.NetworkRegistry;
import cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper;
import cpw.mods.fml.common.registry.EntityRegistry;[/p]
[p]@Mod(modid = Main.MODID, version = Main.VERSION, name = Main.NAME)
public class Main {[/p]
[p]public static final String MODID = "anime";
public static final String VERSION = "1.0";
public static final String NAME = "Ichigo Mod";
public static ArmorMaterial Ichigo = EnumHelper.addArmorMaterial("Ichigo", 2000, new int[] {4, 7, 5, 4} , 0);
public static ArmorMaterial BIchigo = EnumHelper.addArmorMaterial("BIchigo", 4000, new int[] {6, 8, 6, 5} , 0);
public static ToolMaterial zangetsu = EnumHelper.addToolMaterial("zangetsu", 3, 1984, 16.0F, 4.0F, 0);
public static ToolMaterial tensazangetsu = EnumHelper.addToolMaterial("tensazangetsu", 3, 1984, 18.0F, 7.0F, 0);
@Instance(MODID)
public static Main modInstance;
@SidedProxy(clientSide = "com.BearOfDoom.Proxy.ClientProxy", serverSide = "com.BearOfDoom.Proxy.CommonProxy")
public static CommonProxy proxy;
public static final SimpleNetworkWrapper NETWORK;
@EventHandler
public void PreLoad(FMLPreInitializationEvent event) {
int modEntityID = 0;
ConfigOptions.config = new Configuration(event.getSuggestedConfigurationFile());
ConfigOptions.loadConfig();
animeTabs.initialiseTabs();
animeArmor.mainRegistry();
animeItems.mainRegistry();
proxy.registerRenderers();
//PacketHandler.init();
EntityRegistry.registerModEntity(EntitygetsugaTensho.class, "Getsuga Tensho", ++modEntityID, this, 64, 10, true);
EntityRegistry.registerModEntity(EntityBgetsugaTensho.class, "Getsuga Tensho", ++modEntityID, this, 64, 10, true);
}
@EventHandler
public void Load(FMLInitializationEvent event) {
}
@EventHandler
public void PostLoad(FMLPostInitializationEvent event) {
}
static {
NETWORK = NetworkRegistry.INSTANCE.newSimpleChannel("anime");
};
}[/p]
[p]
anime key handler
import net.minecraft.client.Minecraft;
import net.minecraft.entity.player.EntityPlayer;
import cpw.mods.fml.common.eventhandler.EventPriority;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.gameevent.TickEvent;
import cpw.mods.fml.common.network.simpleimpl.IMessage;
import cpw.mods.fml.relauncher.Side;
import org.lwjgl.input.Keyboard;
import com.BearOfDoom.Packets.BankaiIchigoPacket;
import com.BearOfDoom.Packets.PacketHandler;
public class animeKeyHandler {
public static double shoulderguntimer;
public static double miniguntimer;
@SubscribeEvent(priority = EventPriority.NORMAL, receiveCanceled = true) public void onKeyInput(final TickEvent.PlayerTickEvent event) {
final EntityPlayer player = event.player;
if(event.side == Side.SERVER) {
return;
}
final int key = Keyboard.getEventKey();
final boolean isDown = Keyboard.getEventKeyState();
if(isDown && KeyHandler.rKeyPressed && !Minecraft.getMinecraft().ingameGUI.getChatGUI().getChatOpen() && Minecraft.getMinecraft().currentScreen == null);
PacketHandler.NETWORK.sendToServer((IMessage)new BankaiIchigoPacket(player));
}
static {
animeKeyHandler.shoulderguntimer = 30.0;
animeKeyHandler.miniguntimer = 50.0;
}
}
okay solved! its pretty simple the last part actually I forgot to make it check to make sure the key was pressed before doing it! sorry about that guys!
error:
Main:
anime key handler
key handler
packet handler
bankai ichigo packet
tell me if you need any more classes. Thanks in advance!
In bankai ichigo packet class what's in the line 66?
the code is pretty damaged because of forum editor. the next time use gist to post your code and link it there.
sorry for my bad english I'm Italian
okay thanks for the advice! this is line 66 though
if (player.getCurrentArmor(3).getItem() instanceof ItemichigoArmor && player.getCurrentArmor(2).getItem() instanceof ItemichigoArmor && player.getCurrentArmor(1).getItem() instanceof ItemichigoArmor && player.getCurrentArmor(0).getItem() instanceof ItemichigoArmor && player.getCurrentEquippedItem().getItem() == animeItems.zangetsu) {
which is bassically checking for all those items.
You are not checking for null value in the last condition:
you have to put a check before like this:
obviously you put the other conditions before but i don't want to copy all the whole part and you need to do this in the elseif part too
sorry for my bad english I'm Italian
okay so now it doesnt crash... but now it just spamms it the text and doesnt do anything.
EDIT: I put a timer and it works! well except for working via the keybind
Im guessing I have to do more than what I have done so far XD ill keep working and post if it doesnt get fixed
also whats elseif?
okay solved! its pretty simple the last part actually I forgot to make it check to make sure the key was pressed before doing it! sorry about that guys!