-
Posts
785 -
Joined
-
Last visited
Everything posted by ItsAMysteriousYT
-
Spawning my entity causes gamecrash[STILL UNSOLVED]
ItsAMysteriousYT replied to ItsAMysteriousYT's topic in Modder Support
Yes, while i tried out the onItemUse stuff - Well it does not work somehow. Did i make everything correct with this`? @Override public boolean onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ) { EntityVehicle vehicle = new EntityVehicle(worldIn, f, hitX, hitY + 1, hitZ); if(!worldIn.isRemote){ worldIn.spawnEntityInWorld(vehicle); } return true; } EDIT: the entity does not spawn -
Spawning my entity causes gamecrash[STILL UNSOLVED]
ItsAMysteriousYT replied to ItsAMysteriousYT's topic in Modder Support
I create an item for every VehicleFIle i loaded from textfiles. With this method i only add them to the itemList, so they are being registered with the other items later on. -
Spawning my entity causes gamecrash[STILL UNSOLVED]
ItsAMysteriousYT replied to ItsAMysteriousYT's topic in Modder Support
Anybody? I just cant find a reason for that bug. The packet works, it is being send, just the world does not hold an entity under that id -
Spawning my entity causes gamecrash[STILL UNSOLVED]
ItsAMysteriousYT replied to ItsAMysteriousYT's topic in Modder Support
Maybe i have to add the entityID to the datawatcher in entityinit somehow? -
Spawning my entity causes gamecrash[STILL UNSOLVED]
ItsAMysteriousYT replied to ItsAMysteriousYT's topic in Modder Support
Okay, i corrected that, no rendering crashes anymore. But the bug with the entity still exists. This is the spawn item class. Anything wrong about that? class newItem extends Item { public newItem() { setUnlocalizedName(f.vehicleName); setCreativeTab(RealLifeMod.Cars); } @Override public ItemStack onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn) { System.out.println("Placing " + f.vehicleName); BlockPos pos = Minecraft.getMinecraft().objectMouseOver.getBlockPos(); if (worldIn.getBlockState(pos).getBlock() != Blocks.air) { EntityVehicle vehicle = new EntityVehicle(worldIn, f, pos.getX(), pos.getY() + 1, pos.getZ()); worldIn.spawnEntityInWorld(vehicle); } return itemStackIn; } } Item i = new newItem(); RealLifeMod_Items.carItems.add(i); -
Spawning my entity causes gamecrash[STILL UNSOLVED]
ItsAMysteriousYT replied to ItsAMysteriousYT's topic in Modder Support
Can i register the Blocks/Items in their constructor? -
Spawning my entity causes gamecrash[STILL UNSOLVED]
ItsAMysteriousYT replied to ItsAMysteriousYT's topic in Modder Support
Its still crashes - anything wrong with this method? public void setupTile(Class<? extends RLMTileEntity> class1, TileEntitySpecialRenderer render, Side side) { GameRegistry.registerTileEntity(class1, class1.getName()); if(side==Side.CLIENT){ try { ClientRegistry.bindTileEntitySpecialRenderer(class1, render.getClass().newInstance()); } catch (Exception e) { } } } This bug does appear for SOME tileentities, but i register them all the same way. -
Spawning my entity causes gamecrash[STILL UNSOLVED]
ItsAMysteriousYT replied to ItsAMysteriousYT's topic in Modder Support
Yes, that was caused by the fact that i registered the TileEntities and the renderers in the same method on both sides i think. And also i had registered the baseclass of the electric tileentities, but without applying a renderer too it. Im starting the game in background, if it works ill post it here. -
Spawning my entity causes gamecrash[STILL UNSOLVED]
ItsAMysteriousYT replied to ItsAMysteriousYT's topic in Modder Support
WTF? Something with the initmethod of my entitiy : -
Spawning my entity causes gamecrash[STILL UNSOLVED]
ItsAMysteriousYT replied to ItsAMysteriousYT's topic in Modder Support
I still think the id is correct, but it is not known on the server because the entity does not spawn correctly which would explain the fact, that i can't rightclick on it. Doesn't it? -
Spawning my entity causes gamecrash[STILL UNSOLVED]
ItsAMysteriousYT replied to ItsAMysteriousYT's topic in Modder Support
When i register something in preInit, is that correct? (Sorry if i ask so basic questions) -
Spawning my entity causes gamecrash[STILL UNSOLVED]
ItsAMysteriousYT replied to ItsAMysteriousYT's topic in Modder Support
Okay, so i put the register methods into another class and call them from the MainClass. But it still does return null in the packethandler. -
Spawning my entity causes gamecrash[STILL UNSOLVED]
ItsAMysteriousYT replied to ItsAMysteriousYT's topic in Modder Support
Okay then ill put it in an other class. -
Spawning my entity causes gamecrash[STILL UNSOLVED]
ItsAMysteriousYT replied to ItsAMysteriousYT's topic in Modder Support
Okay, corrected that, but still it does not work. Entityregistration also has to be on both sides. Does that mean i just have to write the code in the commonproxy or as an example in the Main class? -
Spawning my entity causes gamecrash[STILL UNSOLVED]
ItsAMysteriousYT replied to ItsAMysteriousYT's topic in Modder Support
Okay, i think the spawning thing is the issue. Might it be possible, that it does not spawn correctly, cuz i generate the item in the clientproxy? -
Spawning my entity causes gamecrash[STILL UNSOLVED]
ItsAMysteriousYT replied to ItsAMysteriousYT's topic in Modder Support
Like this? public class MountHandler implements IMessageHandler<MountVehicleMessage, MountVehicleMessage>{ @Override public MountVehicleMessage onMessage(final MountVehicleMessage message, final MessageContext ctx) { IThreadListener mainThread = (WorldServer) ctx.getServerHandler().playerEntity.worldObj; // or Minecraft.getMinecraft() on the client mainThread.addScheduledTask( new Runnable() { @Override public void run() { EntityPlayer player = ctx.getServerHandler().playerEntity; World world = ctx.getServerHandler().playerEntity.worldObj; Entity v=ctx.getServerHandler().playerEntity.worldObj.getEntityByID(message.vehicleId); System.out.println(message.vehicleId); if(v!=null){ player.mountEntity(v); }else System.out.println("Still null!"); } }); return null; } } This doesn't work either -
Spawning my entity causes gamecrash[STILL UNSOLVED]
ItsAMysteriousYT replied to ItsAMysteriousYT's topic in Modder Support
Does anybody know why the Entity is null? The id from the packet is being sent correctly but somehow in the packethandler it does not get the correct entity. This is my code: package itsamysterious.mods.reallifemod.core.packets; import java.util.UUID; import itsamysterious.mods.reallifemod.RealLifeMod; import itsamysterious.mods.reallifemod.core.lifesystem.RLMPlayerProps; import itsamysterious.mods.reallifemod.core.vehicles.EntityVehicle; import net.minecraft.client.Minecraft; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.util.IThreadListener; import net.minecraft.world.World; import net.minecraft.world.WorldServer; import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler; import net.minecraftforge.fml.common.network.simpleimpl.MessageContext; public class MountHandler implements IMessageHandler<MountVehicleMessage, MountVehicleMessage>{ @Override public MountVehicleMessage onMessage(final MountVehicleMessage message, final MessageContext ctx) { final EntityPlayer player = ctx.getServerHandler().playerEntity; final World world = ctx.getServerHandler().playerEntity.worldObj; final EntityVehicle v=(EntityVehicle)world.getEntityByID(message.vehicleId); IThreadListener mainThread = (WorldServer) ctx.getServerHandler().playerEntity.worldObj; // or Minecraft.getMinecraft() on the client mainThread.addScheduledTask( new Runnable() { @Override public void run() { System.out.println(message.vehicleId); if(v!=null){ player.mountEntity(v); }else System.out.println("Still null!"); } }); return null; } } -
Spawning my entity causes gamecrash[STILL UNSOLVED]
ItsAMysteriousYT replied to ItsAMysteriousYT's topic in Modder Support
The method does not return null, so the problem must be in the PacketHandler if the packet is okay: package itsamysterious.mods.reallifemod.core.packets; import java.util.UUID; import itsamysterious.mods.reallifemod.RealLifeMod; import itsamysterious.mods.reallifemod.core.lifesystem.RLMPlayerProps; import itsamysterious.mods.reallifemod.core.vehicles.EntityVehicle; import net.minecraft.client.Minecraft; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.util.IThreadListener; import net.minecraft.world.World; import net.minecraft.world.WorldServer; import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler; import net.minecraftforge.fml.common.network.simpleimpl.MessageContext; public class MountHandler implements IMessageHandler<MountVehicleMessage, MountVehicleMessage>{ @Override public MountVehicleMessage onMessage(final MountVehicleMessage message, final MessageContext ctx) { final EntityPlayer player = ctx.getServerHandler().playerEntity; IThreadListener mainThread = (WorldServer) ctx.getServerHandler().playerEntity.worldObj; // or Minecraft.getMinecraft() on the client mainThread.addScheduledTask( new Runnable() { @Override public void run() { World world = ctx.getServerHandler().playerEntity.worldObj; EntityVehicle v=(EntityVehicle)world.getEntityByID(message.vehicleId); if(v!=null){ ctx.getServerHandler().playerEntity.mountEntity(v); }else System.out.println("Still null!"); } }); return null; } } -
Spawning my entity causes gamecrash[STILL UNSOLVED]
ItsAMysteriousYT replied to ItsAMysteriousYT's topic in Modder Support
I chose the vehicle based on the players position (in my forloop i look which getDistanceSquaredToEntity is the smallest and then return this entity). The problem is, that the entity that is being sent in the packet is null if i get it from the id that was send. And here is the NBT stuff: -
Spawning my entity causes gamecrash[STILL UNSOLVED]
ItsAMysteriousYT replied to ItsAMysteriousYT's topic in Modder Support
Thanks for your help diesieben07, you really know how to code mods So now, i tried saving these entities through worldSave, but somehow it does not work the way i want it to. In the textfile in which i define the entitie's name and values i also set an ID for it(internal, not the entity.setEntityID()-stuff), which i then save to the NBT-Data. But somehow when the entity is being loaded, it is not able to read the specific data from the global list of vehiclefiles. Am i using the right methods? EDIT: The keybinding still wont run somehow The method in the packethandler that gets the vehicle from the ID send by the packet returns null -
Spawning my entity causes gamecrash[STILL UNSOLVED]
ItsAMysteriousYT replied to ItsAMysteriousYT's topic in Modder Support
Or can i just do it in the entities update method? OH - damn, im thinking to complicated. I can just do it in the onUpdate method. It does not matter if the returning VehicleENtity is the same class as the one the method was called from -
Spawning my entity causes gamecrash[STILL UNSOLVED]
ItsAMysteriousYT replied to ItsAMysteriousYT's topic in Modder Support
Yes what i did now is i made a KeyHandler class in which i get the closest VehicleEntity to the player from the entity list. And in there i have this method. I registered this class to the EVENT_BUS, but the event isn't called. @SubscribeEvent public void onKeyInput(KeyInputEvent event) { if(Keybindings.EnterVehicleKey.isPressed()){ System.out.println("Pressed Enter"); if(getClosestEntity()!=null){ RealLifeMod.network.sendToServer(new MountVehicleMessage(getClosestEntity().getEntityId())); } } } I do this cuz otherwise i would have to edit the entityplayerclass or not? -
Spawning my entity causes gamecrash[STILL UNSOLVED]
ItsAMysteriousYT replied to ItsAMysteriousYT's topic in Modder Support
Oh, that was nonsense Keybindings are registered to the ClientRegistry anyway, what i meant is where i have to register the InputEvent. -
Spawning my entity causes gamecrash[STILL UNSOLVED]
ItsAMysteriousYT replied to ItsAMysteriousYT's topic in Modder Support
Heres is the updated packetCode: package itsamysterious.mods.reallifemod.core.packets; import java.util.UUID; import io.netty.buffer.ByteBuf; import itsamysterious.mods.reallifemod.core.vehicles.EntityVehicle; import net.minecraft.entity.player.EntityPlayer; import net.minecraftforge.fml.common.network.ByteBufUtils; import net.minecraftforge.fml.common.network.simpleimpl.IMessage; import net.minecraftforge.fml.common.registry.EntityRegistry; import sun.awt.image.ByteBandedRaster; public class MountVehicleMessage implements IMessage { public int vehicleId; public MountVehicleMessage(){ } public MountVehicleMessage(int id){ this.vehicleId=id; } @Override public void fromBytes(ByteBuf buf) { this.vehicleId = buf.readInt(); } @Override public void toBytes(ByteBuf buf) { buf.writeInt(this.vehicleId); } } I created a keybinding now and registered it. I get the nearest entity from the client world(is that ok?) and then send the packet to mount the entity on the server. Anything wrong about this? Since you can't enter the vehicle while its driving, the client and server pos should be different right? -
Spawning my entity causes gamecrash[STILL UNSOLVED]
ItsAMysteriousYT replied to ItsAMysteriousYT's topic in Modder Support
Everything alright with that stuff? Its in the onUpdate method: if (worldObj.isRemote) { if (Keyboard.isKeyDown(Keyboard.KEY_RETURN)) { RealLifeMod.network.sendToServer(new MountVehicleMessage(this.getEntityId())); } }