Jump to content

[SOLVED][1.8]Keybindings crash server


blfngl

Recommended Posts

Hey, I've been searching for a solution for a few days now but haven't been able to find anything that fixes my problem. My keybindings crash the server version of the mod, and setting them up in my client proxy doesn't seem to fix it. Help?

 

Client Proxy:

package blfngl.fallout.proxy;

import net.minecraft.client.Minecraft;
import net.minecraft.client.model.ModelBiped;
import net.minecraft.client.model.ModelSpider;
import net.minecraft.client.renderer.entity.RenderSnowball;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.client.registry.ClientRegistry;
import net.minecraftforge.fml.client.registry.RenderingRegistry;
import net.minecraftforge.fml.common.FMLCommonHandler;
import net.minecraftforge.fml.common.eventhandler.EventBus;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import blfngl.fallout.Fallout;
import blfngl.fallout.entity.EntityAnt;
import blfngl.fallout.entity.EntityFeralGhoul;
import blfngl.fallout.entity.EntityGhoulReaver;
import blfngl.fallout.entity.EntityGhoulRoamer;
import blfngl.fallout.entity.projectile.EntityGrenade;
import blfngl.fallout.gui.GuiRadBar;
import blfngl.fallout.render.RenderAnt;
import blfngl.fallout.render.RenderFeralGhoul;
import blfngl.fallout.render.RenderGhoulReaver;
import blfngl.fallout.render.RenderGhoulRoamer;
import blfngl.fallout.util.FalloutKeyBinding;

public class ClientProxy extends CommonProxy
{
@Override
@SideOnly(Side.CLIENT)
public void initRender()
{
	EventBus eventBus = FMLCommonHandler.instance().bus();
	eventBus.register(new FalloutKeyBinding());

	//FMLCommonHandler.instance().bus().register(new KeyInputHandler());

	MinecraftForge.EVENT_BUS.register(new GuiRadBar(Minecraft.getMinecraft()));
	RenderingRegistry.registerEntityRenderingHandler(EntityGrenade.class, new RenderSnowball(Minecraft.getMinecraft().getRenderManager(), Fallout.grenade, Minecraft.getMinecraft().getRenderItem()));

	RenderingRegistry.registerEntityRenderingHandler(EntityFeralGhoul.class, new RenderFeralGhoul(Minecraft.getMinecraft().getRenderManager(), new ModelBiped(), 0.5F));
	RenderingRegistry.registerEntityRenderingHandler(EntityGhoulRoamer.class, new RenderGhoulRoamer(Minecraft.getMinecraft().getRenderManager(), new ModelBiped(), 0.5F));
	RenderingRegistry.registerEntityRenderingHandler(EntityGhoulReaver.class, new RenderGhoulReaver(Minecraft.getMinecraft().getRenderManager(), new ModelBiped(), 0.5F));
	RenderingRegistry.registerEntityRenderingHandler(EntityAnt.class, new RenderAnt(Minecraft.getMinecraft().getRenderManager(), new ModelSpider(), 0.5F));

	/**RenderingRegistry.registerEntityRenderingHandler(EntityBullet.class, new RenderSnowball(Fallout.emptySyringe));
	LanguageRegistry.instance().addStringLocalization("entity.bullet.fallout.name", "fallout");

	RenderingRegistry.registerEntityRenderingHandler(EntityMissile.class, new RenderSnowball(Fallout.emptySyringe));
	LanguageRegistry.instance().addStringLocalization("entity.rocket.fallout.name", "fallout");

	RenderingRegistry.registerEntityRenderingHandler(EntityLaser.class, new RenderSnowball(Fallout.emptySyringe));
	LanguageRegistry.instance().addStringLocalization("entity.missile.fallout.name", "fallout");

	RenderingRegistry.registerEntityRenderingHandler(EntityPellet.class, new RenderSnowball(Fallout.emptySyringe));
	LanguageRegistry.instance().addStringLocalization("entity.pellet.fallout.name", "fallout");

	RenderingRegistry.registerEntityRenderingHandler(EntitySpear.class, new RenderSnowball(Items.arrow));
	LanguageRegistry.instance().addStringLocalization("entity.spear.fallout.name", "fallout");

	RenderingRegistry.registerEntityRenderingHandler(EntityPlasma.class, new RenderSnowball(Items.slime_ball));*/
}
}

 

 

FalloutKeyBinding:

package blfngl.fallout.util;

import net.minecraft.client.Minecraft;
import net.minecraft.client.settings.KeyBinding;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraftforge.fml.client.registry.ClientRegistry;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.gameevent.InputEvent.KeyInputEvent;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

import org.lwjgl.input.Keyboard;

import blfngl.fallout.player.FalloutPlayer;

public class FalloutKeyBinding
{
public static int keyReload = Keyboard.KEY_R;

@SideOnly(Side.CLIENT)
public KeyBinding reloadKey = new KeyBinding("Reload", keyReload, "key.categories.fallout");

public FalloutKeyBinding()
{
	ClientRegistry.registerKeyBinding(reloadKey);
}

@SubscribeEvent
@SideOnly(Side.CLIENT)
public void KeyInputEvent(KeyInputEvent event)
{
	EntityPlayer player = Minecraft.getMinecraft().thePlayer;

	if (reloadKey.isKeyDown())
	{
		FalloutPlayer props = FalloutPlayer.get(player);
		props.setReloadingState(1);
		System.out.println(player.getName() + " is reloading!");
	}
}
}

 

 

I also register my client proxy in the event bus within the preInit method of my main file.

 

preInit()

@EventHandler
public void preInit(FMLPreInitializationEvent event)
{
	System.out.println("Blfngl's Fallout mod loading...");

	FMLCommonHandler.instance().bus().register(new FalloutConfig());
	config = new Configuration(event.getSuggestedConfigurationFile());
	config.load();
	FalloutConfig.syncConfig();
	FalloutConfig.createModInfo(event);

	ChemEffectHandler.init();

	MinecraftForge.EVENT_BUS.register(new FalloutEventHandler());
	MinecraftForge.EVENT_BUS.register(new VanillaBlockDrops());
	FMLCommonHandler.instance().bus().register(new FalloutEventHandler());
	FMLCommonHandler.instance().bus().register(new VanillaBlockDrops());

	FMLCommonHandler.instance().bus().register(new ClientProxy());
	Entities.init();
}

 

Link to comment
Share on other sites

You can ONLY ever access client input (keyboard, mouse, etc.) on the CLIENT side - ANY attempt to do so on the server, i.e. when the world is not remote, will crash your game.

 

This includes things like inline initializations:

@SideOnly(Side.CLIENT)
public KeyBinding reloadKey = new KeyBinding("Reload", keyReload, "key.categories.fallout");

It doesn't matter that you put @SideOnly there, because that can only remove the reference, but you also try to assign it and that part is not removed, thus it crashes.

 

You CAN, however, put the @SideOnly annotation above your entire KeyBinding class, and that's what you should do, as well as make sure you only ever reference it on the client side.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • As the title says i keep on crashing on forge 1.20.1 even without any mods downloaded, i have the latest drivers (nvidia) and vanilla minecraft works perfectly fine for me logs: https://pastebin.com/5UR01yG9
    • Hello everyone, I'm making this post to seek help for my modded block, It's a special block called FrozenBlock supposed to take the place of an old block, then after a set amount of ticks, it's supposed to revert its Block State, Entity, data... to the old block like this :  The problem I have is that the system breaks when handling multi blocks (I tried some fix but none of them worked) :  The bug I have identified is that the function "setOldBlockFields" in the item's "setFrozenBlock" function gets called once for the 1st block of multiblock getting frozen (as it should), but gets called a second time BEFORE creating the first FrozenBlock with the data of the 1st block, hence giving the same data to the two FrozenBlock :   Old Block Fields set BlockState : Block{minecraft:black_bed}[facing=east,occupied=false,part=head] BlockEntity : net.minecraft.world.level.block.entity.BedBlockEntity@73681674 BlockEntityData : id:"minecraft:bed",x:3,y:-60,z:-6} Old Block Fields set BlockState : Block{minecraft:black_bed}[facing=east,occupied=false,part=foot] BlockEntity : net.minecraft.world.level.block.entity.BedBlockEntity@6d1aa3da BlockEntityData : {id:"minecraft:bed",x:2,y:-60,z:-6} Frozen Block Entity set BlockState : Block{minecraft:black_bed}[facing=east,occupied=false,part=foot] BlockPos{x=3, y=-60, z=-6} BlockEntity : net.minecraft.world.level.block.entity.BedBlockEntity@6d1aa3da BlockEntityData : {id:"minecraft:bed",x:2,y:-60,z:-6} Frozen Block Entity set BlockState : Block{minecraft:black_bed}[facing=east,occupied=false,part=foot] BlockPos{x=2, y=-60, z=-6} BlockEntity : net.minecraft.world.level.block.entity.BedBlockEntity@6d1aa3da BlockEntityData : {id:"minecraft:bed",x:2,y:-60,z:-6} here is the code inside my custom "freeze" item :    @Override     public @NotNull InteractionResult useOn(@NotNull UseOnContext pContext) {         if (!pContext.getLevel().isClientSide() && pContext.getHand() == InteractionHand.MAIN_HAND) {             BlockPos blockPos = pContext.getClickedPos();             BlockPos secondBlockPos = getMultiblockPos(blockPos, pContext.getLevel().getBlockState(blockPos));             if (secondBlockPos != null) {                 createFrozenBlock(pContext, secondBlockPos);             }             createFrozenBlock(pContext, blockPos);             return InteractionResult.SUCCESS;         }         return super.useOn(pContext);     }     public static void createFrozenBlock(UseOnContext pContext, BlockPos blockPos) {         BlockState oldState = pContext.getLevel().getBlockState(blockPos);         BlockEntity oldBlockEntity = oldState.hasBlockEntity() ? pContext.getLevel().getBlockEntity(blockPos) : null;         CompoundTag oldBlockEntityData = oldState.hasBlockEntity() ? oldBlockEntity.serializeNBT() : null;         if (oldBlockEntity != null) {             pContext.getLevel().removeBlockEntity(blockPos);         }         BlockState FrozenBlock = setFrozenBlock(oldState, oldBlockEntity, oldBlockEntityData);         pContext.getLevel().setBlockAndUpdate(blockPos, FrozenBlock);     }     public static BlockState setFrozenBlock(BlockState blockState, @Nullable BlockEntity blockEntity, @Nullable CompoundTag blockEntityData) {         BlockState FrozenBlock = BlockRegister.FROZEN_BLOCK.get().defaultBlockState();         ((FrozenBlock) FrozenBlock.getBlock()).setOldBlockFields(blockState, blockEntity, blockEntityData);         return FrozenBlock;     }  
    • It is an issue with quark - update it to this build: https://www.curseforge.com/minecraft/mc-mods/quark/files/3642325
    • Remove Instant Massive Structures Mod from your server     Add new crash-reports with sites like https://paste.ee/  
  • Topics

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.