Lambda Posted December 10, 2016 Posted December 10, 2016 Hey there, So I have this capability that created a mana value, and I'm displaying that via onRenderGameOverlay . When I add to the capability, the overlay updates fine. However, when I subtract it from the player by a TE it subtracts, but does not update the overlay. However, when I subtract the values, I get 2 values that are outputted from the log, the original and the after value. ex: 15000 8100 15000 8100 So maybe its something to do with the network? However, I dont really know how to packet my information. Maybe a tutorial I can look at? Here are the classes: ManaEvents: public class ManaEvent { protected FontRenderer fontRendererObj; @SubscribeEvent public static void onRenderGameOverlay(RenderGameOverlayEvent event) { Minecraft mc = Minecraft.getMinecraft(); if(!event.isCancelable() && event.getType() == RenderGameOverlayEvent.ElementType.TEXT) { // mc.renderEngine.bindTexture(new ResourceLocation(ModUtil.MOD_ID + ":" + "textures/gui/mana.png")); CapabilityManaData storage = mc.thePlayer.getCapability(CapabilityMagic.MANA, null); String string = "MANA: " + Integer.toString(storage.getManaStored()); mc.fontRendererObj.drawString(string, 50 + 1, 50, 50); } } @SubscribeEvent public static void onAddCapabilitiesEntity(AttachCapabilitiesEvent<Entity> e) { if (canHaveAttributes(e.getObject())) { EntityLivingBase ent = (EntityLivingBase) e.getObject(); if (ent instanceof EntityPlayer) e.addCapability(CapabilityMagicProvider.KEY, new CapabilityMagicProvider(ent)); } } public static boolean canHaveAttributes(Entity entity) { if (entity instanceof EntityLivingBase) return true; return false; } } Capability Stuff: CapabilityMagic: public class CapabilityMagic { @CapabilityInject(CapabilityManaData.class) public static Capability<CapabilityManaData> MANA = null; public static void register() { CapabilityManager.INSTANCE.register(CapabilityManaData.class, new StorageHelper(), new DefaultInstanceFactory()); } public static class StorageHelper implements Capability.IStorage<CapabilityManaData> { @Override public NBTBase writeNBT(Capability<CapabilityManaData> capability, CapabilityManaData instance, EnumFacing side) { return instance.writeData(); } @Override public void readNBT(Capability<CapabilityManaData> capability, CapabilityManaData instance, EnumFacing side, NBTBase nbt) { instance.readData(nbt); } } public static class DefaultInstanceFactory implements Callable<CapabilityManaData> { @Override public CapabilityManaData call() throws Exception { return new CapabilityManaData(); } } } CapabilityProvider: public class CapabilityMagicProvider implements ICapabilityProvider, ICapabilitySerializable<NBTTagCompound> { public static final ResourceLocation KEY = new ResourceLocation(ModUtil.MOD_ID, "mana"); private CapabilityManaData INSTANCE = new CapabilityManaData(); public CapabilityMagicProvider() {} public CapabilityMagicProvider(EntityLivingBase entity) { INSTANCE.setEntity(entity); } @Override public boolean hasCapability(Capability<?> capability, EnumFacing facing) { return capability == CapabilityMagic.MANA; } @Override public <T> T getCapability(Capability<T> capability, EnumFacing facing) { if (capability == CapabilityMagic.MANA) return (T) INSTANCE; return null; } @Override public NBTTagCompound serializeNBT() { return (NBTTagCompound) CapabilityMagic.MANA.writeNBT(INSTANCE, null); } @Override public void deserializeNBT(NBTTagCompound nbt) { CapabilityMagic.MANA.readNBT(INSTANCE, null, nbt); } } Lastly the data: public class CapabilityManaData extends ManaHandler { private EntityLivingBase entity; public CapabilityManaData(){ super(500000); } public CapabilityManaData(int capacity, int maxReceive, int maxExtract){ super(capacity, maxReceive, maxExtract); } public EntityLivingBase getEntity() { return entity; } public void setEntity(EntityLivingBase entity) { this.entity = entity; } public int extractManaInternal(int maxExtract, boolean simulate){ int before = this.maxExtract; this.maxExtract = Integer.MAX_VALUE; int toReturn = this.extractMana(maxExtract, simulate); this.maxExtract = before; return toReturn; } public int receiveManaInternal(int maxReceive, boolean simulate){ int before = this.maxReceive; this.maxReceive = Integer.MAX_VALUE; int toReturn = this.receiveMana(maxReceive, simulate); this.maxReceive = before; return toReturn; } @Override public int receiveMana(int maxReceive, boolean simulate){ if(!this.canReceive()){ return 0; } int mana = this.getManaStored(); int manaReceived = Math.min(this.capacity-mana, Math.min(this.maxReceive, maxReceive)); if(!simulate){ this.setManaStored(mana+manaReceived); } return manaReceived; } @Override public int extractMana(int maxExtract, boolean simulate){ if(!this.canExtract()){ return 0; } int mana = this.getManaStored(); int manaExtracted = Math.min(mana, Math.min(this.maxExtract, maxExtract)); if(!simulate){ this.setManaStored(mana-manaExtracted); } return manaExtracted; } public void readFromNBT(NBTTagCompound compound){ this.setManaStored(compound.getInteger("Mana")); } public NBTBase writeData() { NBTTagCompound tag = new NBTTagCompound(); tag.setInteger("Mana", mana); return tag; } public void readData(NBTBase nbt) { NBTTagCompound tag = (NBTTagCompound) nbt; this.setManaStored(tag.getInteger("Mana")); } public void writeToNBT(NBTTagCompound compound){ compound.setInteger("Mana", this.getManaStored()); } public void setManaStored(int energy){ this.mana = energy; } } The TE thats not updating the capability: if(!this.worldObj.isRemote){ List<StandRecipeHandler> recipes = getRecipesForInput(this.slots.getStackInSlot(0)); EntityPlayer entityPlayer = worldObj.getClosestPlayer(this.getPos().getX(), this.getPos().getY(), this.getPos().getZ(), 5, false); if(!recipes.isEmpty() && entityPlayer != null){ if(entityPlayer.hasCapability(CapabilityMagic.MANA, null)) { CapabilityManaData capabilityManaData = entityPlayer.getCapability(CapabilityMagic.MANA, null); for (StandRecipeHandler recipe : recipes) { TileEntityStand[] modifierStands = this.getFittingModifiers(recipe, recipe.time); if (modifierStands != null) { //Meaning the display stands around match all the criteria if (capabilityManaData.getManaStored() >= recipe.requiredMana) { this.recipeForRenderIndex = PlentifulMiscAPI.STAND_RECIPES.indexOf(recipe); this.processTime++; boolean done = this.processTime >= recipe.time; for (TileEntityStand stand : modifierStands) { if (done) { stand.slots.decrStackSize(0, 1); } } if (this.processTime % 5 == 0 && this.worldObj instanceof WorldServer) { this.shootParticles(this.pos.getX() + 3, this.pos.getY() + 0.5, this.pos.getZ(), recipe.particleColor); this.shootParticles(this.pos.getX(), this.pos.getY() + 0.5, this.pos.getZ() + 3, recipe.particleColor); this.shootParticles(this.pos.getX() - 3, this.pos.getY() + 0.5, this.pos.getZ(), recipe.particleColor); this.shootParticles(this.pos.getX(), this.pos.getY() + 0.5, this.pos.getZ() - 3, recipe.particleColor); } if (done) { ((WorldServer) this.worldObj).spawnParticle(EnumParticleTypes.PORTAL, false, this.pos.getX() + 0.5, this.pos.getY() + 1.1, this.pos.getZ() + 0.5, 2, 0, 0, 0, 0.1D); this.slots.setStackInSlot(0, recipe.output.copy()); this.markDirty(); capabilityManaData.extractManaInternal(recipe.requiredMana, false); this.processTime = 0; this.recipeForRenderIndex = -1; } break; } else { entityPlayer.addChatMessage(new TextComponentTranslation("chat." + ModUtil.MOD_ID + ".stand.notenoughmana.warn")); } } else { entityPlayer.addChatMessage(new TextComponentTranslation("chat." + ModUtil.MOD_ID + ".stand.invalid.warn")); } } } } else{ this.processTime = 0; this.recipeForRenderIndex = -1; } if(this.lastRecipe != this.recipeForRenderIndex){ this.lastRecipe = this.recipeForRenderIndex; this.sendUpdate(); } } And if needed, some captioned pictures to explain whats happening: Next, Finally, Thanks for reading. Quote Relatively new to modding. Currently developing: https://github.com/LambdaXV/DynamicGenerators
Animefan8888 Posted December 10, 2016 Posted December 10, 2016 It is indeed a networking thing, you will need to use packets. But don't worry packets are easy. Diesieben has a great tutorial on them and the network itself. http://www.minecraftforge.net/forum/index.php?topic=20135.0 Quote VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect. Forge and vanilla BlockState generator.
Lambda Posted December 11, 2016 Author Posted December 11, 2016 Okay, that was pretty easy:) , now would would I register it so that capability data is 'packet-ized?' :^) Quote Relatively new to modding. Currently developing: https://github.com/LambdaXV/DynamicGenerators
Animefan8888 Posted December 11, 2016 Posted December 11, 2016 Okay, that was pretty easy:) , now would would I register it so that capability data is 'packet-ized?' :^) Packet#toBytes() is your write and Packet#fromBytes() is your read. So ByteBufUtils.writeVarInt(to, toWrite, maxSize); ByteBufUtils.readVarInt(buf, maxSize); // OR buf.writeInt(value); buf.readInt(); Quote VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect. Forge and vanilla BlockState generator.
Lambda Posted December 11, 2016 Author Posted December 11, 2016 Okay so something like this? public class MessageHandler implements IMessageHandler<Messages, IMessage> { @Override public IMessage onMessage(Messages message, MessageContext ctx) { EntityPlayerMP serverPlayer = ctx.getServerHandler().playerEntity; int amount = message.mana; if(serverPlayer.hasCapability(CapabilityMagic.MANA, null)) { CapabilityManaData cap = serverPlayer.getCapability(CapabilityMagic.MANA, null); amount += cap.getManaStored(); } return null; } } If so how would I access ti and access the amount variable. Quote Relatively new to modding. Currently developing: https://github.com/LambdaXV/DynamicGenerators
Animefan8888 Posted December 11, 2016 Posted December 11, 2016 Okay so something like this? public class MessageHandler implements IMessageHandler<Messages, IMessage> { @Override public IMessage onMessage(Messages message, MessageContext ctx) { EntityPlayerMP serverPlayer = ctx.getServerHandler().playerEntity; int amount = message.mana; if(serverPlayer.hasCapability(CapabilityMagic.MANA, null)) { CapabilityManaData cap = serverPlayer.getCapability(CapabilityMagic.MANA, null); amount += cap.getManaStored(); } return null; } } If so how would I access ti and access the amount variable. No not like that if you look at the tutorials message handler implementation you will see he uses a IThreadListener. This is because the game has its own thread and the network has its own thread. Also you should have a setMana method in your capability somewhere to do this. One last thing did you really make a IMessage implementation called Messages? Quote VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect. Forge and vanilla BlockState generator.
Lambda Posted December 11, 2016 Author Posted December 11, 2016 Closer..? @Override public IMessage onMessage(PMMessages message, MessageContext ctx) { IThreadListener mainThread = (WorldServer) ctx.getServerHandler().playerEntity.worldObj; // or Minecraft.getMinecraft() on the client mainThread.addScheduledTask(new Runnable() { @Override public void run() { CapabilityManaData cap = ctx.getServerHandler().playerEntity.getCapability(CapabilityMagic.MANA, null); cap.setManaStored(mana); System.out.println(String.format("Received %s from %s", message.mana, ctx.getServerHandler().playerEntity.getDisplayName())); } }); return null; // no response in this case } Quote Relatively new to modding. Currently developing: https://github.com/LambdaXV/DynamicGenerators
Animefan8888 Posted December 11, 2016 Posted December 11, 2016 Closer..? @Override public IMessage onMessage(PMMessages message, MessageContext ctx) { IThreadListener mainThread = (WorldServer) ctx.getServerHandler().playerEntity.worldObj; // or Minecraft.getMinecraft() on the client mainThread.addScheduledTask(new Runnable() { @Override public void run() { CapabilityManaData cap = ctx.getServerHandler().playerEntity.getCapability(CapabilityMagic.MANA, null); cap.setManaStored(mana); System.out.println(String.format("Received %s from %s", message.mana, ctx.getServerHandler().playerEntity.getDisplayName())); } }); return null; // no response in this case } You should be sending the message to the client and you just copied the code diesieben made... Look at that nice comment he left // or Minecraft.getMinecraft() on the client Plus you never check if the player has your capability anymore. Last thing I would name your message something like ManaSyncMessageClient. This way you know that it is a client recieved message and what it does specifically. Quote VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect. Forge and vanilla BlockState generator.
Lambda Posted December 11, 2016 Author Posted December 11, 2016 Okay, steps closer, however, now I'm getting this crash: java.lang.RuntimeException: java.lang.InstantiationException: com.lambda.plentifulmisc.PlentifulMisc$ManaSyncMessageClient$MessageHandler at com.google.common.base.Throwables.propagate(Throwables.java:160) ~[guava-17.0.jar:?] at net.minecraftforge.fml.common.network.simpleimpl.SimpleNetworkWrapper.instantiate(SimpleNetworkWrapper.java:174) ~[forgeSrc-1.11-13.19.0.2180.jar:?] at net.minecraftforge.fml.common.network.simpleimpl.SimpleNetworkWrapper.registerMessage(SimpleNetworkWrapper.java:164) ~[forgeSrc-1.11-13.19.0.2180.jar:?] at com.lambda.plentifulmisc.PlentifulMisc.preInit(PlentifulMisc.java:84) ~[PlentifulMisc/:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_91] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_91] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_91] at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_91] at net.minecraftforge.fml.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:602) ~[forgeSrc-1.11-13.19.0.2180.jar:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_91] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_91] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_91] at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_91] at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74) ~[guava-17.0.jar:?] at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47) ~[guava-17.0.jar:?] at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322) ~[guava-17.0.jar:?] at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304) ~[guava-17.0.jar:?] at com.google.common.eventbus.EventBus.post(EventBus.java:275) ~[guava-17.0.jar:?] at net.minecraftforge.fml.common.LoadController.sendEventToModContainer(LoadController.java:243) ~[forgeSrc-1.11-13.19.0.2180.jar:?] at net.minecraftforge.fml.common.LoadController.propogateStateMessage(LoadController.java:221) ~[forgeSrc-1.11-13.19.0.2180.jar:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_91] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_91] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_91] at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_91] at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74) ~[guava-17.0.jar:?] at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47) ~[guava-17.0.jar:?] at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322) ~[guava-17.0.jar:?] at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304) ~[guava-17.0.jar:?] at com.google.common.eventbus.EventBus.post(EventBus.java:275) ~[guava-17.0.jar:?] at net.minecraftforge.fml.common.LoadController.distributeStateMessage(LoadController.java:145) [LoadController.class:?] at net.minecraftforge.fml.common.Loader.preinitializeMods(Loader.java:615) [Loader.class:?] at net.minecraftforge.fml.client.FMLClientHandler.beginMinecraftLoading(FMLClientHandler.java:264) [FMLClientHandler.class:?] at net.minecraft.client.Minecraft.startGame(Minecraft.java:476) [Minecraft.class:?] at net.minecraft.client.Minecraft.run(Minecraft.java:385) [Minecraft.class:?] at net.minecraft.client.main.Main.main(Main.java:118) [Main.class:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_91] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_91] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_91] at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_91] at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) [launchwrapper-1.12.jar:?] at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.12.jar:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_91] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_91] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_91] at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_91] at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97) [start/:?] at GradleStart.main(GradleStart.java:26) [start/:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_91] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_91] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_91] at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_91] at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147) [idea_rt.jar:?] Caused by: java.lang.InstantiationException: com.lambda.plentifulmisc.PlentifulMisc$ManaSyncMessageClient$MessageHandler at java.lang.Class.newInstance(Class.java:427) ~[?:1.8.0_91] at net.minecraftforge.fml.common.network.simpleimpl.SimpleNetworkWrapper.instantiate(SimpleNetworkWrapper.java:171) ~[forgeSrc-1.11-13.19.0.2180.jar:?] ... 50 more Caused by: java.lang.NoSuchMethodException: com.lambda.plentifulmisc.PlentifulMisc$ManaSyncMessageClient$MessageHandler.<init>() at java.lang.Class.getConstructor0(Class.java:3082) ~[?:1.8.0_91] at java.lang.Class.newInstance(Class.java:412) ~[?:1.8.0_91] at net.minecraftforge.fml.common.network.simpleimpl.SimpleNetworkWrapper.instantiate(SimpleNetworkWrapper.java:171) ~[forgeSrc-1.11-13.19.0.2180.jar:?] ... 50 more It crashes on the registration: network.registerMessage(ManaSyncMessageClient.MessageHandler.class, ManaSyncMessageClient.class, 0, Side.SERVER); Here is the updated packet: class ManaSyncMessageClient implements IMessage { private int mana; public ManaSyncMessageClient(){} public ManaSyncMessageClient(int toSend) { this.mana = toSend; } @Override public void toBytes(ByteBuf buf) { // Writes the int into the buf buf.writeInt(mana); } @Override public void fromBytes(ByteBuf buf) { // Reads the int back from the buf. Note that if you have multiple values, you must read in the same order you wrote. mana = buf.readInt(); } public class MessageHandler implements IMessageHandler<ManaSyncMessageClient, IMessage> { @Override public IMessage onMessage(ManaSyncMessageClient message, MessageContext ctx) { IThreadListener mainThread = Minecraft.getMinecraft(); // or Minecraft.getMinecraft() on the client mainThread.addScheduledTask(new Runnable() { @Override public void run() { if(Minecraft.getMinecraft().thePlayer.hasCapability(CapabilityMagic.MANA, null)) { CapabilityManaData cap = Minecraft.getMinecraft().thePlayer.getCapability(CapabilityMagic.MANA, null); cap.setManaStored(mana); } System.out.println(String.format("Received %s from %s", message.mana, ctx.getServerHandler().playerEntity.getDisplayName())); } }); return null; // no response in this case } } } Thanks for your help Quote Relatively new to modding. Currently developing: https://github.com/LambdaXV/DynamicGenerators
Animefan8888 Posted December 11, 2016 Posted December 11, 2016 Try adding a zero argument constructor to your MessageHandler. Quote VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect. Forge and vanilla BlockState generator.
Lambda Posted December 11, 2016 Author Posted December 11, 2016 Yeah I had one here: public ManaSyncMessageClient(){} Quote Relatively new to modding. Currently developing: https://github.com/LambdaXV/DynamicGenerators
Animefan8888 Posted December 11, 2016 Posted December 11, 2016 Yeah I had one here: public ManaSyncMessageClient(){} No your MessageHandler not your ManaSyncMessageClient. Quote VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect. Forge and vanilla BlockState generator.
Lambda Posted December 11, 2016 Author Posted December 11, 2016 Yeah, still the same error Quote Relatively new to modding. Currently developing: https://github.com/LambdaXV/DynamicGenerators
Animefan8888 Posted December 11, 2016 Posted December 11, 2016 Yeah, still the same error Try moving the handler to its own class file. Quote VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect. Forge and vanilla BlockState generator.
Lambda Posted December 11, 2016 Author Posted December 11, 2016 That seemed to fix my error, however Its still not updating my display, do I need to do something here?: CapabilityManaData storage = mc.thePlayer.getCapability(CapabilityMagic.MANA, null); String string = "MANA: " + Integer.toString(storage.getManaStored()); mc.fontRendererObj.drawString(string, 50 + 1, 50, 50); Quote Relatively new to modding. Currently developing: https://github.com/LambdaXV/DynamicGenerators
Animefan8888 Posted December 11, 2016 Posted December 11, 2016 That seemed to fix my error, however Its still not updating my display, do I need to do something here?: CapabilityManaData storage = mc.thePlayer.getCapability(CapabilityMagic.MANA, null); String string = "MANA: " + Integer.toString(storage.getManaStored()); mc.fontRendererObj.drawString(string, 50 + 1, 50, 50); Two things, when you register your packet it needs to be Side.CLIENT because the client should be receiving the packet and you will need to send this packet as shown in diesiebens tutorial everytime you change the mana. Quote VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect. Forge and vanilla BlockState generator.
Lambda Posted December 11, 2016 Author Posted December 11, 2016 Okay, this seemed to work better.. on logging in It was synced until I subtracted w/ the infusion recipe, in which it desynced again: CapabilityManaData storage = mc.thePlayer.getCapability(CapabilityMagic.MANA, null); PlentifulMisc.network.sendToServer(new ManaNetworkSyncClient(storage.getManaStored())); String string = "MANA: " + Integer.toString(storage.getManaStored()); mc.fontRendererObj.drawString(string, 50 + 1, 50, 50); the output: 8000 8000 8000 8000 8000 8000 8000 500 8000 500 8000 500 8000 8000 500 500 8000 500 Quote Relatively new to modding. Currently developing: https://github.com/LambdaXV/DynamicGenerators
Lambda Posted December 11, 2016 Author Posted December 11, 2016 Okay, this seemed to work better.. on logging in It was synced until I subtracted w/ the infusion recipe, in which it desynced again: CapabilityManaData storage = mc.thePlayer.getCapability(CapabilityMagic.MANA, null); PlentifulMisc.network.sendToServer(new ManaNetworkSyncClient(storage.getManaStored())); String string = "MANA: " + Integer.toString(storage.getManaStored()); mc.fontRendererObj.drawString(string, 50 + 1, 50, 50); the output: 8000 8000 8000 8000 8000 8000 8000 //where I subtracted 500 8000 500 8000 500 8000 8000 500 500 8000 500 Quote Relatively new to modding. Currently developing: https://github.com/LambdaXV/DynamicGenerators
Animefan8888 Posted December 11, 2016 Posted December 11, 2016 Okay, this seemed to work better.. on logging in It was synced until I subtracted w/ the infusion recipe, in which it desynced again: CapabilityManaData storage = mc.thePlayer.getCapability(CapabilityMagic.MANA, null); PlentifulMisc.network.sendToServer(new ManaNetworkSyncClient(storage.getManaStored())); String string = "MANA: " + Integer.toString(storage.getManaStored()); mc.fontRendererObj.drawString(string, 50 + 1, 50, 50); the output: 8000 8000 8000 8000 8000 8000 8000 500 8000 500 8000 500 8000 8000 500 500 8000 500 Why are you sending the packet there? You should be sending it after changing the value and did you update your registry to say Side.CLIENT instead of Side.SERVER? Quote VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect. Forge and vanilla BlockState generator.
Lambda Posted December 11, 2016 Author Posted December 11, 2016 Yes, the side is changed, and I made it so the packets updated when the mana is changed now, still the display isnt updating properly. and resets to 0 on relog Quote Relatively new to modding. Currently developing: https://github.com/LambdaXV/DynamicGenerators
Lambda Posted December 11, 2016 Author Posted December 11, 2016 Yes, the side is changed, and I made it so the packets updated when the mana is changed now, still the display isnt syncing properly. and resets to 0 on relog Quote Relatively new to modding. Currently developing: https://github.com/LambdaXV/DynamicGenerators
Draco18s Posted December 11, 2016 Posted December 11, 2016 Wait. Hold on. You're "updating the packet"? Please explain. Quote Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable. If you think this is the case, JUST REPORT ME. Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice. Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked. DO NOT PM ME WITH PROBLEMS. No help will be given.
Animefan8888 Posted December 11, 2016 Posted December 11, 2016 Yes, the side is changed, and I made it so the packets updated when the mana is changed now, still the display isnt updating properly. and resets to 0 on relog You also have to sync it when the player logs in. Quote VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect. Forge and vanilla BlockState generator.
Lambda Posted December 11, 2016 Author Posted December 11, 2016 Did that but, still no luck Wait. Hold on. You're "updating the packet"? Please explain. I'm trying to sync a cap between the client and server, however, I'm having a bit of a hard time doing so Quote Relatively new to modding. Currently developing: https://github.com/LambdaXV/DynamicGenerators
Animefan8888 Posted December 11, 2016 Posted December 11, 2016 Did that but, still no luck Wait. Hold on. You're "updating the packet"? Please explain. I'm trying to sync a cap between the client and server, however, I'm having a bit of a hard time doing so Show where you send the packet the whole method(s) and your packet and handler. Quote VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect. Forge and vanilla BlockState generator.
Recommended Posts
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.