Jump to content

Recommended Posts

Posted

Hey, i was updating from 1.8 with IEEP to 1.10 with Capabilities, but everything I've done seem to add a copy of my mana, an un usable version of it. I ran a debug system print of the mana value, it rejuvenates as you would expect it too over time, but a ghost value renders over my mana bar and not the value that keeps changing when i right click the item

 

The ghost value rejuvenates as well but it gets to 10, like the bar is supposed too but wont go down when i use the item, the main value does go down when i use it though, its like when i right click the item, the value gets used, then the ghost value is dominate as the bar rending code uses that value instead.

 

[spoiler=Item code]

@Override
public ActionResult<ItemStack> onItemRightClick(ItemStack stack, World world, EntityPlayer player, EnumHand hand) {  
        final IEssenceBar bar1 = player.getCapability(BarTickHandler.ESSENCE_CAP, null);
	if(!world.isRemote && bar1.useBar(usage)) {
		//ENTITY SPAWN CODE
	}
}

 

 

 

[spoiler=Bar tick code]

public class BarTickHandler {

private EntityPlayer player;
private int ticks = 10;

public static int darkAmount, powerAmount;
@CapabilityInject(IEssenceBar.class)
public static Capability<IEssenceBar> ESSENCE_CAP = null;

@SubscribeEvent
public void onEntityConstructing(AttachCapabilitiesEvent evt) {
	evt.addCapability(new ResourceLocation(SlayerAPI.MOD_ID, "IEssenceBar"), new ICapabilitySerializable<NBTPrimitive>() {
		IEssenceBar inst = ESSENCE_CAP.getDefaultInstance();
		@Override
		public boolean hasCapability(Capability<?> capability, EnumFacing facing) {
			return capability == ESSENCE_CAP;
		}

		@Override
		public <T> T getCapability(Capability<T> capability, EnumFacing facing) {
			return capability == ESSENCE_CAP ? ESSENCE_CAP.<T>cast(inst) : null;
		}

		@Override
		public NBTPrimitive serializeNBT() {
			return (NBTPrimitive)ESSENCE_CAP.getStorage().writeNBT(ESSENCE_CAP, inst, null);
		}

		@Override
		public void deserializeNBT(NBTPrimitive nbt) {
			ESSENCE_CAP.getStorage().readNBT(ESSENCE_CAP, inst, null, nbt);
		}
	});
}

@SubscribeEvent
public void onTick(PlayerTickEvent event) {
	if(event.phase == Phase.END) tickEnd(event.player);
}

@SubscribeEvent
@SideOnly(Side.CLIENT)
public void renderEvent(RenderTickEvent event) {
	onTickRender(Minecraft.getMinecraft().thePlayer);
}

@SideOnly(Side.CLIENT)
private void onTickRender(EntityPlayer player) {
	Minecraft mc = Minecraft.getMinecraft();
	if(mc.currentScreen == null) {
		if(!player.capabilities.isCreativeMode) {
			GL11.glPushMatrix();
			GlStateManager.enableBlend();
			GlStateManager.enableAlpha();
			GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
			GuiIngame gig = mc.ingameGUI;
			ScaledResolution scaledresolution = new ScaledResolution(mc);
			mc.getTextureManager().bindTexture(new ResourceLocation(SlayerAPI.MOD_ID, "textures/gui/misc.png"));
			int y = scaledresolution.getScaledHeight() - 30, x = 10, x1 = 10, x2 = 10;
			gig.drawTexturedModalRect(x - 10, y + 10, 0, 177, 117, 19);
			gig.drawTexturedModalRect(x - 10, y - 5, 0, 177, 117, 19);
			gig.drawTexturedModalRect(x - 10, y - 20, 0, 177, 117, 19);

			gig.drawTexturedModalRect(x - 6, y - 13, 0, 23, 109, 5);

			for(int i = 0; i < player.getCapability(ESSENCE_CAP, null).getBarValue(); i++) {
				x += 11;
				gig.drawTexturedModalRect(x - 17, y - 13, 0, 0, 10, 5);
			}
			y += 15;
			gig.drawTexturedModalRect(x1 - 6, y - 13, 0, 36, 109, 5);
			for(int i = 0; i < darkAmount; i++) {
				x1 += 11;
				gig.drawTexturedModalRect(x1 - 17, y - 13, 0, 5, 10, 5);
			}
			gig.drawTexturedModalRect(x2 - 6, y + 2, 0, 49, 109, 5);
			for(int i = 0; i < powerAmount; i++) {
				x2 += 11;
				gig.drawTexturedModalRect(x2 - 17, y + 2, 0, 10, 10, 5);
			}
			GlStateManager.disableAlpha();
			GlStateManager.disableBlend();
			GL11.glPopMatrix();
		}
	}
}

private void tickEnd(EntityPlayer player) {
	final IEssenceBar essence = player.getCapability(ESSENCE_CAP, null);
	if(ticks-- <= 0) ticks = 20;
	if(ticks >= 20) {
		essence.updateAllBars();
	}
	essence.mainUpdate();
}
}

 

 

 

[spoiler=Capability registry in common proxy]

CapabilityManager.INSTANCE.register(IEssenceBar.class, new EssenceStorage(), EssenceBar.class);

 

 

 

[spoiler=IEssenceBar]

public interface IEssenceBar {

boolean useBar(int mana);
int getBarValue();
void mainUpdate();
void setBarValue(int mana);
void removeBarPoints(int mana);
void updateAllBars();
}

 

 

 

[spoiler=EssenceBar]

@Override
public boolean useBar(int amount) {
	if(essence < amount) {
		regenDelay = 10;
		return false;
	}
	essence -= amount;
	regenDelay = 10;
	return true;
}

@Override
public int getBarValue() {
	return essence;
}

@Override
public void mainUpdate() {
	if(getBarValue() >= 10) essence = 10;
	System.out.println(essence);
}

@Override
public void setBarValue(int mana) {
	essence = mana;
}

@Override
public void removeBarPoints(int mana) {
	regenDelay = 10;
	essence -= mana;
}

@Override
public void updateAllBars() {
	essence += 1;
}
}

 

 

 

[spoiler=EssenceStorage]

public class EssenceStorage implements Capability.IStorage<IEssenceBar>{

@Override
public NBTBase writeNBT(Capability<IEssenceBar> capability, IEssenceBar instance, EnumFacing side) {
	return new NBTTagByte((byte)0);
}

@Override
public void readNBT(Capability<IEssenceBar> capability, IEssenceBar instance, EnumFacing side, NBTBase nbt) {

}
}

 

 

Former developer for DivineRPG, Pixelmon and now the maker of Essence of the Gods

Posted

Capabilities aren't automatically synced, do you ever sync the mana value from the server to the client?

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Posted

do you mean the read/write NBTBase method?

 

That is "save to disk" not "send packets" it's right there in the name. "Packets."

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.

Posted

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.

Posted

[spoiler=Journey]

public static SimpleNetworkWrapper wrapper;

@EventHandler
public static void preInit(FMLPreInitializationEvent event) {
	wrapper = NetworkRegistry.INSTANCE.newSimpleChannel("EssenceNetwork");
	wrapper.registerMessage(MessageEssenceBar.EssenceHandler.class, MessageEssenceBar.class, 0, Side.CLIENT);
         }

 

 

 

[spoiler=common/client proxy]

public void updateEssence(int amount) { }
-------------------------------------------------------------------
@Override
public void updateEssence(int amount) {
	final IEssenceBar essence = Minecraft.getMinecraft().thePlayer.getCapability(BarTickHandler.ESSENCE_CAP, null);
	essence.setBarValue(amount);
}

 

 

 

[spoiler=MessageEssenceBar]

public class MessageEssenceBar implements IMessage {

public int amount;
public boolean shouldRegen;

public MessageEssenceBar() { }

public MessageEssenceBar(int amount, boolean shouldRegen) {
	this.amount = amount;
	this.shouldRegen = shouldRegen;
}

@Override
public void fromBytes(ByteBuf buf) {
	amount = buf.readInt();
	shouldRegen = buf.readBoolean();
}

@Override
public void toBytes(ByteBuf buf) {
	buf.writeInt(amount);
	buf.writeBoolean(shouldRegen);
}

public static class EssenceHandler implements IMessageHandler<MessageEssenceBar, IMessage> {

	@Override
	public IMessage onMessage(MessageEssenceBar message, MessageContext ctx) {
		BarTickHandler.essenceAmount = message.amount;
		BarTickHandler.regenEssence = message.shouldRegen;
		Journey.proxy.updateEssence(message.amount);
		return null;
	}
}
}

 

 

Former developer for DivineRPG, Pixelmon and now the maker of Essence of the Gods

Posted

Looks like you've made some progress which is good. Do you have your project on a public repo? (GitHub, Bitbucket)

I'd be happy to assist the best I can, if you like you can have a look at my capability system https://bitbucket.org/hugo_the_dwarf/riseoftristram2016/src?at=master packages are named in meaningful ways

 

Was those 3 posted blocks of code you're only changes? or have you updated your bar tick code since then?

Posted

I've noticed in your Essence class you use Journey.wrapper.sendToAll() just curious if you mean to do that. Because you register your Capability on "Everything" not just players. But I don't see any "generic" entity tick so it rules out the fact that a random mob could be "sending" it's data to everyone.

 

However that sendToAll() will cause issues because you use your clientProxy to "handle" the data by getting the minecraft.thePlayer which If player 1 ticked and updated, server sends data to all, player 2 now thinks "player 1s" stats are his (then player 2 gets ticked, and server updates all players again player 1 now thinks player 2's stats are his)

 

if you make sure in the player tick event you can just use Journey.wrapper.sendTo(message,(EntityPlayerMP) player); and it will send it to the correct player rather than all players.

 

I'm still digging through some of your code.

Posted

The thing is i dont have a instance to EntityPlayer in the Essence class, i could make a constructor in the class getting one, but i dont create an instance for the  Essence class either, its constructed from the default instance method, and even if i wanted to change that, where i register my class in the BarTickHandler i dont have a player instance either so thats another problem, i could use Minecraft.getMinecraft().thePlayer but thats a SP instance and i want MP

Former developer for DivineRPG, Pixelmon and now the maker of Essence of the Gods

Posted

Update some of your methods that "send a packet" to include a EntityPlayer param, and in your PlayerTick events you can get the player from there

 

if (!player.worldObj.isRemote)

essence.mainUpdate(player);

 

^^^

 

Journey.wrapper.sendTo(new MessageEssenceBar(essence, regenDelay == 0),(EntityPlayerMP)player);

 

or you can just declare an Entity obj in the Essence class and give your provider a constructor or have it call capability.entity = event.entity

 

then in main updates you just check to see if the entities worldObj is not remote (server) and sendTo from there.

 

Since I can't physically see the ghosting or debug and step through (I might just do a pull and run it personally soon enough) to see what it really could be.

 

EDIT: looks like you have a Console.out somewhere sending out the values which is nice, as I can see numbers flying all over. If I can locate that spot I can try having the console also pump out hopefully any other helpful information.

Posted

I think its fixed now, i added a player parameter to the methods and seemed to fix it all

 

	if(player instanceof EntityPlayerMP) Journey.wrapper.sendTo(new MessageEssenceBar(essence, regenDelay == 0), (EntityPlayerMP)player);

 

also did that, thanks!

Former developer for DivineRPG, Pixelmon and now the maker of Essence of the Gods

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

    • But your Launcher does not find it   Java path is: /run/user/1000/doc/3f910b8/java Checking Java version... Java checker returned some invalid data we don't understand: Check the Azul Zulu site and select your OS and download the latest Java 8 build for Linux https://www.azul.com/downloads/?version=java-8-lts&package=jre#zulu After installation, check the path and put this path into your Launcher Java settings (Java Executable)
    • Try other builds of pehkui and origins++ until you find a working combination
    • Some Create addons are only compatible with Create 6 or Create 5 - so not both versions at the same time Try older builds of Create Stuff and Additions This is the last build before the Create 6 update: https://www.curseforge.com/minecraft/mc-mods/create-stuff-additions/files/6168370
    • ✅ Crobo Coupon Code: 51k3b0je — Get Your \$25 Amazon Gift Card Bonus! If you’re new to Crobo and want to make the most out of your first transaction, you’ve come to the right place. The **Crobo coupon code: 51k3b0je** is a fantastic way to get started. By using this code, you can unlock an exclusive **\$25 Amazon gift card** after completing your first eligible transfer. Let’s dive deep into how the **Crobo coupon code: 51k3b0je** works, why you should use it, and how to claim your reward. --- 🌟 What is Crobo? Crobo is a trusted, modern platform designed for **international money transfers**. It offers fast, secure, and low-cost transactions, making it a favorite choice for individuals and businesses alike. Crobo is committed to transparency, low fees, and competitive exchange rates. And with promo deals like the **Crobo coupon code: 51k3b0je**, it becomes even more attractive. Crobo focuses on providing customers with: * Quick transfer speeds * Minimal fees * Safe, encrypted transactions * Great referral and promo code rewards When you choose Crobo, you’re choosing a platform that values your time, money, and loyalty. And now with the **Crobo coupon code: 51k3b0je**, you can start your Crobo journey with a **bonus reward**! ---# 💥 What is the Crobo Coupon Code: 51k3b0je? The **Crobo coupon code: 51k3b0je** is a **special promotional code** designed for new users. By entering this code during signup, you’ll be eligible for: ✅ A **\$25 Amazon gift card** after your first qualifying transfer. ✅ Access to Crobo’s referral system to earn more rewards. ✅ The ability to combine with future seasonal Crobo discounts. Unlike generic promo codes that just offer small fee reductions, the **Crobo coupon code: 51k3b0je** directly gives you a tangible, valuable reward — perfect for online shopping or gifting. --- ### 🎯 Why Use Crobo Coupon Code: 51k3b0je? There are many reasons why users choose to apply the **Crobo coupon code: 51k3b0je**: 🌟 **Free bonus reward** — Your first transfer can instantly earn you a \$25 Amazon gift card. 🌟 **Trusted platform** — Crobo is known for secure, fast, and affordable transfers. 🌟 **Easy to apply** — Simply enter **Crobo coupon code: 51k3b0je** at signup — no complicated steps. 🌟 **Referral opportunities** — Once you’ve used **Crobo coupon code: 51k3b0je**, you can invite friends and earn more rewards. 🌟 **Stackable savings** — Pair **Crobo coupon code: 51k3b0je** with Crobo’s ongoing offers or holiday deals for even more benefits. --- ### 📝 How to Use Crobo Coupon Code: 51k3b0je Getting started with **Crobo coupon code: 51k3b0je** is quick and easy. Just follow these steps: 1️⃣ **Download the Crobo app** (available on Google Play Store and Apple App Store) or visit the official Crobo website. 2️⃣ **Start the sign-up process** by entering your basic details (name, email, phone number, etc.). 3️⃣ When prompted, enter **Crobo coupon code: 51k3b0je** in the promo code or coupon code field. 4️⃣ Complete your first transaction — be sure to meet the minimum amount required to qualify for the reward (usually specified in Crobo’s promo terms). 5️⃣ After the transaction is verified, receive your **\$25 Amazon gift card** directly via email or within your Crobo account. --- ### 💡 Tips to Maximize Your Crobo Coupon Code: 51k3b0je Bonus 👉 **Transfer the minimum qualifying amount or more** — this ensures you meet the conditions for the gift card. 👉 **Refer friends after your signup** — Crobo allows users who’ve signed up with codes like **Crobo coupon code: 51k3b0je** to share their own code for extra bonuses. 👉 **Check for additional Crobo promotions** — sometimes Crobo offers seasonal or regional deals that stack with the coupon code. 👉 **Complete your transaction soon after signup** — many bonuses have time limits, so act quickly! --- ### 🚀 Frequently Asked Questions about Crobo Coupon Code: 51k3b0je **Q: Can I use Crobo coupon code: 51k3b0je if I already have a Crobo account?** A: No — the **Crobo coupon code: 51k3b0je** is intended for **new users only**. It must be applied during the initial registration process. --- **Q: How long does it take to get the \$25 Amazon gift card after using Crobo coupon code: 51k3b0je?** A: Typically, the gift card is sent **within a few business days** after your first qualifying transfer is completed and verified. --- **Q: Are there hidden fees when using Crobo coupon code: 51k3b0je?** A: No — Crobo is transparent about its fees. The **Crobo coupon code: 51k3b0je** simply adds a bonus reward without increasing your costs. --- **Q: Can I combine Crobo coupon code: 51k3b0je with other promo codes?** A: The **Crobo coupon code: 51k3b0je** is generally applied as a standalone signup bonus. However, Crobo often offers **ongoing promotions** that may apply to future transactions. ---  📌 Reference Crobo promo code: {51k3b0je} Crobo discount code: {51k3b0je} --- # 🌍 Final Thoughts If you want to enjoy safe, fast, and affordable money transfers with an added bonus, **Crobo coupon code: 51k3b0je** is your best option. Not only will you experience excellent service, but you’ll also earn a **\$25 Amazon gift card** — a reward that you can use immediately for shopping or gifts. 👉 **Don’t wait — sign up today using Crobo coupon code: 51k3b0je and claim your bonus!**
    • Does this schematic contain stuff from the mod prettypipes? Looks like Forgematica has issues to load it Try to load the schematic with worldedit - remove the pipes, save it and test it again
  • Topics

×
×
  • Create New...

Important Information

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