Jump to content

oldcheese

Members
  • Posts

    108
  • Joined

  • Last visited

Everything posted by oldcheese

  1. Wherever you put your account info; Just leave that blank.
  2. Really? Did you specifically configure your run to use your own minecraft account? If you don't, it should logon with a random username listed as player###, which should both be different.
  3. Weight can be empty, but usually defines the chance an item will be picked If you have 2 pools they can have different weights so one pool is more likely to show items. (I believe) The quality relates to weight. But is modifyable by a player's luck attribute. Bonus rolls is a chance for the player to roll an additional time from this pool. Bonus rolls can be more than 1, so you can have a bonus rolls value of 6 and the chest will always contain at least 7 items. Botania makes a 'random' amount of bonusrolls by using a new RAndomValueRange(0,1) which means that there's either 1 or 2 rolls. Which makes sense since if you always want 7 rolls you can just set the amount of rolls to 7. <Rolls> is the amount of rolls you'd have, so if it's 10 then you'll get 10 items from your table. The name, obviously, is just a name. The only confusing thing you might be baffled by is the LootConditions, since lootconditions is the only part where you can't just put in a number. The condition is something that is basically a check of "Does the player have this value?" If one condition fails it aborts the picking from the lootpool. Conditions is a list. So you can simply pass it an empty list by passing a new LootCondition[0] you could also add conditions. I believe the conditions right now are random_chance, killed_by_player, entity_properties, entity_scores. Entity properties has the "on fire" modifier. If you wanted to use a condition you could pass: new LootCondition[]{new KilledByPlayer(false), new RandomChanceWithLooting(0.07f, 0.05f)} for example. Tinker's construct does something similar.
  4. Edit: I actually installed Eclipse for some reason just to check.
  5. Using whatever client you're using to code you should be able to launch a test server and two clients (which will by default have different usernames)
  6. if it's in loot_tables/scrolls then you must reflect this in your registration. Since the default area is the loot_tables pool (According to the resources) you should put the location as "scrolls/dungeon_scrolls" The register you did seems to be alright. As long as you call ModLoot.Register() in your main class. What you want to do is get a LootPool from your JSON. The code that the Docs gives is the following: LootEntry entry = new LootEntryTable(new ResourceLocation("mymod:inject/simple_dungeon"), <weight>, <quality>, <conditions>, <entryName>); // weight doesn't matter since it's the only entry in the pool. Other params set as you wish. LootPool pool = new LootPool(new LootEntry[] {entry}, <conditions>, <rolls>, <bonusRolls>, <name>); // Other params set as you wish. evt.getTable().addPool(pool); You'd add something like that, obviously containing the proper code instead of <>'s and add it to the Event handler. Obviously the resourcelocation would be adjusted for your own mod. Botania has a good example of how they added loot, look at the getInjectPool and getInjectEntry at the bottom most of all. If you don't know how switches work, basically all cases jump down untill either it returns or breaks anything. So what it says there is that depending on what string they will just add a pool to the table, a pool gotten by the getInjectPool. The getInjectPool then gets an InjectEntry and yada yada. The code speaks for itself. Looking at that you should be able to figure out how to retrieve a lootpool and a lootentry.
  7. Don't turn off PVP. What you want to do is create a modifier for the players to make them belong to a team. You could add a custom Capability that lists their Teamname for example. Now what you want to do is create an forge event https://mcforge.readthedocs.io/en/latest/events/intro/ in which you subscribe to the LivingHurtEvent, this event fires whenever a player is ABOUT to take damage. Now you make it only listen to players taking damage, you do this with a simple if statement. if(event.getEntity() instanceof EntityPlayer) Now you have an Event that will listen to the damage event. You can now use event.getSource() to get the damage source. Most damage sources in the game (Projectiles, sword attacks etc.) Will have a parameter that tells you who actually fired the arrow/used the sword. While the code below probably wouldn't work, since I removed the part about capabilities with a comment and you probably need a few null checks to make sure the damagesource has an Entity attached. This is what I imagine the event would end up looking like: @SubscribeEvent public void event(LivingHurtEvent event){ if(event.getEntity() instanceof EntityPlayer && event.getSource().getSourceOfDamage() instanceof EntityPlayer){ EntityPlayer hitter = (EntityPlayer)event.getSource().getSourceOfDamage(); //returns an Entity who caused the damage. EntityPlayer target = (EntityPlayer)event.getEntity(); //returns Entity who got hit. We already established this is a player. //Code to check the user's Capabilities and see if they have the same team here if(hitterCapability.getTeam == targetCapability.getTeam){ event.setCanceled(true); } } } now, adding capabilities to players is documented here: https://mcforge.readthedocs.io/en/latest/datastorage/capabilities/ and if you want to synch this up to the server side you probably want to use a packet, unless players don't get a team untill after they log in. Sorry for being a bit long while talking, I'm messaging away from home. I hope this helps a bit, if you have questions feel free to ask. Edit: Not every source of damage has a player source like I said before, make sure that the code you end up making takes this into account. If the source of the damage is an TNT block you might want to block the damage alltogether. The most basic use of blocking damage with a player source should block sources like hits, throwables, throwing potions(?) etc. But the things that are NOT blocked are mostly stuff with big AOE's, which means that that could possibly count as friendly fire when blowing stuff up.
  8. You can put the Event anywhere. What you want to do is take that event from the forge docs that you linked, put them in any class. I personally recommend making a package where you can put your events so you can always check on them later. Then in your Main class you want to register the event using something similar to this: MinecraftForge.EVENT_BUS.register( new ClassContainingEvent() ); You register events during the PreInit phase of loading, there's no need to put it in a proxy for this particular event. You can pretty much use any class you want to put in an event. If you have a class shooting a character off high in the air you can put a falldamageEvent in there and then pass it off to the event bus. You might want to read the bit on events , but honestly just registering the event and writing the event bit should be enough to do what you want. @SubscribeEvent public void lootLoad(LootTableLoadEvent evt) { if (evt.getName().toString().equals("minecraft:chests/simple_dungeon")) { /* do stuff with evt.getTable() like LootTable table = evt.getTable(); //code to retrieve a lootpool table.mergePool(merge.getPool("main"); evt.setTable(table); */ } } You need to register your loot table as a JSON. I assume that "Dungeon_scrolls" is a loottable JSON. Also make sure that your Dungeon_Scrolls is in the folder /assets/modid/loot_tables/name.json, Once you have the event set up you can do stuff like evt.setTable, or you can evt.getTable and then merge the lootpools of the loottables. All of which are described in the LootTable class. Edit: I'm writing this up from my college PC, so I don't have IntelliJ to verify the exact commands you'd use. But I think this should help a fair bit. If you have any questions, feel free to burst loose.
  9. Ah, that makes sense. I guess I could then assign a value to each player and tick them off, but at the same time it's a lot easier to just have one global value and use WorldTicks. It seems a little bit more efficient right now. Thanks for the great answer.
  10. @SubscribeEvent public void regenStats(TickEvent.PlayerTickEvent e) { if (!e.player.getEntityWorld().isRemote && e.phase == TickEvent.Phase.END) { if (ticks < 200) { ticks++; } if (ticks == 200) { final IBarHandler handler = getHandler(e.player); handler.addFatigue(25); ticks = 0; tinyRefresh(e.player); //updates client with server data. } } } The loop is done kinda shittily at the moment, I originally had it doing different things at different ticks. Anyway. The added fatigue only seems to process for the latest player to have logged in. Is this a specific effect of this Event. It'd really be easier to use this event. My goal is to periodically 'regenerate' fatigue on every client. It doesn't have to be at once, but I do want there to be updates. I guess I could use a ServerTickEvent or a WorldTickEvent, loop through all available players in the world and adjut their fatigue and refresh, which would work spotlessly. I'm just wondering what exactly is the deal with PlayerEvent. Edit: I've changed it succesfully to the code below: @SubscribeEvent public void regenStats(TickEvent.WorldTickEvent e) { if(!e.world.isRemote && e.phase == TickEvent.Phase.END){ if(ticks < 200){ ticks++; }else{ ticks = 0; List players = e.world.playerEntities; for(int i = 0; i < players.size(); i++){ EntityPlayer player = (EntityPlayer)players.get(i); final IBarHandler handler = CustomDataHandlerBar.getHandler(player); handler.addFatigue(25); tinyRefresh(player); } } } } but I'm still wondering why PlayerTicks don't work apart from the last player to join.
  11. /]: [OptiFine] *** Reflector Vanilla *** [10:43:54] [main/INFO] [Config/]: [OptiFine] [10:43:54] [main/INFO] [Config/]: [OptiFine] OptiFine_1.12_HD_U_C4 Are you sure you're in 1.8.9? All your modfiles appear to be from 1.12
  12. Honestly. It was your comments on the existance of NBTTagInt that made me change stuff around. So you're still to 'blame' for this getting fixed. I've since re-worked everything to use ByteArray and IntArray. Which is ironic as all heck since I don't even need an NBTTagList using those! Took me a while to convert Bitsets to Bytes. I still am not quite sure that Bitsets are faster for non-bitset style operations. But considering the way bitset works it might be more efficient if none of the bits are actually set yet.
  13. I'm not sure about the intricacies of botania, but if you want to update other client-rendering things like having particles on tile entities usually you need a packet. You want to write two messages. 1. A message notifying the players in the area that the portal is active. (Which will then client-side show the particles.) 2. A message notifying the server that the player wants to recieve an update on whether the portal is active or not. then in the custom TileEntity class you do something like. @Override public void onLoad() { if (worldObj.isRemote) { Your update message } } to tell the client you want the portal active. When your block activates you want to make a sendToAllAround message that tells people around it that the portal is active. If you'd add that then players who walk from afar and load your TE will know the portal is active, and players who are near when it activates will know it's active. You don't have to send a packet with every particle, just tell the client it's active and make it use particles from there.
  14. Solved. Sollution didn't lay within rewriting code, even though I did re-write to use bytes and probably will re-write to just use ByteArrays and IntArray instead of ints and bytes. but for now the following worked: @Override public NBTBase writeNBT(Capability<IAdventurerHandler> capability, IAdventurerHandler instance, EnumFacing side) { final NBTTagCompound tag = new NBTTagCompound(); BitSet booleanAbilities = instance.getAllLevels(); NBTTagList tagBoolList = new NBTTagList(); for(int i = 0; i < booleanAbilities.length(); i++){ tagBoolList.appendTag(new NBTTagByte((byte)(booleanAbilities.get(i)?1:0))); System.out.println(booleanAbilities.get(i)); } tag.setTag("BooleanList", tagBoolList); int[] inthotkeyList = instance.getAllHotkeys(); NBTTagList tagHotBarList = new NBTTagList(); for(int i = 0; i < inthotkeyList.length; i++){ tagHotBarList.appendTag(new NBTTagInt(inthotkeyList[i])); } tag.setTag("hotlist", tagHotBarList); tag.setInteger("level", instance.getLevel()); tag.setInteger("xp", instance.getXP()); tag.setInteger("power", instance.getPower()); return tag; } @Override public void readNBT(Capability<IAdventurerHandler> capability, IAdventurerHandler instance, EnumFacing side, NBTBase nbt) { final NBTTagCompound tag = (NBTTagCompound) nbt; NBTTagList taglist = (NBTTagList)tag.getTag("BooleanList"); for(int i = 0; i < taglist.tagCount(); i++){ NBTTagByte byteTag = (NBTTagByte)taglist.get(i); instance.setAbility(i, (byteTag.getByte() != 0)); System.out.println("read " + instance.hasAbility(i)); } NBTTagList tagHot = (NBTTagList)tag.getTag("hotlist"); for(int k = 0; k < tagHot.tagCount(); k++){ NBTTagInt intTag = (NBTTagInt)tagHot.get(k); instance.setHotkey(k, intTag.getInt()); System.out.println("read : " + instance.gethotkey(k)); } instance.setLevel(tag.getInteger("level")); System.out.println("Level" + instance.getLevel()); instance.setXP(tag.getInteger("xp")); instance.setPower(tag.getInteger("power")); System.out.println("we're reading something"); } } My main problem didn't lay within the way I saved or read. The problem solved itself once I started doing the following: NBTTagList tagHot = (NBTTagList)tag.getTag("hotlist"); instead of this: NBTTagList tagHot = (NBTTagList)tag.getTagList("hotlist", TAG_LIST); I have no clue why I can't use getTagList, but what's done is done. Broke a good few days over what to fix. Marking as solved.
  15. The only thing you'd have to change is your amount of boxes. You'd probably want a box for the center, then a few rectangles to make the wings. If you don't feel like writing about twenty boxes I suggest using Qubble which doesn't work that great, but is better than nothing. Ofcourse there's a lot of other box-based modellers that you can use. or you can do it by hand for simple structures. I've made the following star in about five minutes or so. And as you can see it's model would take quite a while to code by hand: package com.cheese.rpvp.entities.throwables; import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelRenderer; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.entity.Entity; import org.lwjgl.opengl.GL11; public class Wing extends ModelBase { public ModelRenderer Centersquare; public ModelRenderer wing1; public ModelRenderer wing1b; public ModelRenderer wing1c; public ModelRenderer wing1d; public ModelRenderer wing2; public ModelRenderer wing2b; public ModelRenderer wing2c; public ModelRenderer wing2d; public ModelRenderer wing3; public ModelRenderer wing3b; public ModelRenderer wing3c; public ModelRenderer wing3d; public ModelRenderer wing4; public ModelRenderer wing4b; public ModelRenderer wing4c; public ModelRenderer wing4d; public Wing() { this.textureWidth = 64; this.textureHeight = 32; this.Centersquare = new ModelRenderer(this, 0, 6); this.Centersquare.setRotationPoint(0.0F, 0.0F, 0.0F); this.Centersquare.addBox(0.0F, 0.0F, 0.0F, 8, 1, 8); this.wing1 = new ModelRenderer(this, 0, 4); this.wing1.setRotationPoint(1.0F, 0.0F, -1.0F); this.wing1.addBox(0.0F, 0.0F, 0.0F, 7, 1, 1); this.Centersquare.addChild(this.wing1); this.wing1b = new ModelRenderer(this, 0, 2); this.wing1b.setRotationPoint(2.0F, 0.0F, -1.0F); this.wing1b.addBox(0.0F, 0.0F, 0.0F, 5, 1, 1); this.wing1.addChild(this.wing1b); this.wing1c = new ModelRenderer(this, 0, 0); this.wing1c.setRotationPoint(2.0F, 0.0F, -1.0F); this.wing1c.addBox(0.0F, 0.0F, 0.0F, 3, 1, 1); this.wing1b.addChild(this.wing1c); this.wing1d = new ModelRenderer(this, 0, 15); this.wing1d.setRotationPoint(2.0F, 0.0F, -1.0F); this.wing1d.addBox(0.0F, 0.0F, 0.0F, 1, 1, 1); this.wing1c.addChild(this.wing1d); this.wing2 = new ModelRenderer(this, 0, 4); this.wing2.setRotationPoint(9.0F, 0.0F, 1.0F); this.wing2.addBox(0.0F, 0.0F, 0.0F, 7, 1, 1); this.setRotationAngles(this.wing2, 0.0F, -1.5707963267948966F, 0.0F); this.Centersquare.addChild(this.wing2); this.wing2b = new ModelRenderer(this, 0, 2); this.wing2b.setRotationPoint(2.0F, 0.0F, -1.0F); this.wing2b.addBox(0.0F, 0.0F, 0.0F, 5, 1, 1); this.wing2.addChild(this.wing2b); this.wing2c = new ModelRenderer(this, 0, 0); this.wing2c.setRotationPoint(2.0F, 0.0F, -1.0F); this.wing2c.addBox(0.0F, 0.0F, 0.0F, 3, 1, 1); this.wing2b.addChild(this.wing2c); this.wing2d = new ModelRenderer(this, 0, 15); this.wing2d.setRotationPoint(2.0F, 0.0F, -1.0F); this.wing2d.addBox(0.0F, 0.0F, 0.0F, 1, 1, 1); this.wing2c.addChild(this.wing2d); this.wing3 = new ModelRenderer(this, 0, 4); this.wing3.setRotationPoint(7.0F, 0.0F, 9.0F); this.wing3.addBox(0.0F, 0.0F, 0.0F, 7, 1, 1); this.setRotationAngles(this.wing3, 0.0F, 3.141592653589793F, 0.0F); this.Centersquare.addChild(this.wing3); this.wing3b = new ModelRenderer(this, 0, 2); this.wing3b.setRotationPoint(2.0F, 0.0F, -1.0F); this.wing3b.addBox(0.0F, 0.0F, 0.0F, 5, 1, 1); this.wing3.addChild(this.wing3b); this.wing3c = new ModelRenderer(this, 0, 0); this.wing3c.setRotationPoint(2.0F, 0.0F, -1.0F); this.wing3c.addBox(0.0F, 0.0F, 0.0F, 3, 1, 1); this.wing3b.addChild(this.wing3c); this.wing3d = new ModelRenderer(this, 0, 15); this.wing3d.setRotationPoint(2.0F, 0.0F, -1.0F); this.wing3d.addBox(0.0F, 0.0F, 0.0F, 1, 1, 1); this.wing3c.addChild(this.wing3d); this.wing4 = new ModelRenderer(this, 0, 4); this.wing4.setRotationPoint(-1.0F, 0.0F, 7.0F); this.wing4.addBox(0.0F, 0.0F, 0.0F, 7, 1, 1); this.setRotationAngles(this.wing4, 0.0F, 1.5707963267948966F, 0.0F); this.Centersquare.addChild(this.wing4); this.wing4b = new ModelRenderer(this, 0, 2); this.wing4b.setRotationPoint(2.0F, 0.0F, -1.0F); this.wing4b.addBox(0.0F, 0.0F, 0.0F, 5, 1, 1); this.wing4.addChild(this.wing4b); this.wing4c = new ModelRenderer(this, 0, 0); this.wing4c.setRotationPoint(2.0F, 0.0F, -1.0F); this.wing4c.addBox(0.0F, 0.0F, 0.0F, 3, 1, 1); this.wing4b.addChild(this.wing4c); this.wing4d = new ModelRenderer(this, 0, 15); this.wing4d.setRotationPoint(2.0F, 0.0F, -1.0F); this.wing4d.addBox(0.0F, 0.0F, 0.0F, 1, 1, 1); this.wing4c.addChild(this.wing4d); } @Override public void render(Entity entity, float limbSwing, float limbSwingAmount, float ageInTicks, float rotationYaw, float rotationPitch, float scale) { GlStateManager.enableBlend(); GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GlStateManager.color(1.0F, 1.0F, 1.0F, 0.0F); this.Centersquare.render(scale); GlStateManager.disableBlend(); } public void setRotationAngles(ModelRenderer modelRenderer, float x, float y, float z) { modelRenderer.rotateAngleX = x; modelRenderer.rotateAngleY = y; modelRenderer.rotateAngleZ = z; } } Edit: For the item model in hand I believe you're going to have to create the same model in JSON, I'm not sure if you can directly translate an ModelBase to items. According to This post by Choonster it's not really possible if you want any longevity to the method. Since rendering the ModelBase with a TESR is deprecated. The best way is probably to use the program linked there to convert your Java into Json. Unless you want to do it by hand. Which is possible as well. Edit Edit: According to the post below it it might be possible. but I'm keeping the text here because it might be usefull later on.
  16. Alright. I've - Fixed horrible names somewhat. Even though they did technically follow naming conventions tag3 and tag2 are horrid names. - Changed it to get/set individual tags to my instance instead of trying to change the entire thing at once. Similar to how IItemHandler handles reading NBTData - switched it over to use NBTTagInt - Made tagappendbool non-useless. Again nothing much happens. The log of the console is here: [19:46:31] [Server thread/INFO]: Saving chunks for level 'New World'/Overworld [19:46:31] [Server thread/INFO]: Saving chunks for level 'New World'/Nether [19:46:31] [Server thread/INFO]: Saving chunks for level 'New World'/The End false false false false false false false false false false 2 1 2 1 0 false false false false false false false false false false 2 1 2 1 0 [19:46:32] [Server thread/INFO]: Stopping server [19:46:32] [Server thread/INFO]: Saving players [19:46:32] [Server thread/INFO]: Saving worlds [19:46:32] [Server thread/INFO]: Saving chunks for level 'New World'/Overworld [19:46:33] [Server thread/INFO]: Saving chunks for level 'New World'/Nether [19:46:33] [Server thread/INFO]: Saving chunks for level 'New World'/The End [19:46:33] [Server thread/INFO]: Unloading dimension 0 [19:46:33] [Server thread/INFO]: Unloading dimension -1 [19:46:33] [Server thread/INFO]: Unloading dimension 1 [19:46:33] [Server thread/INFO]: Applying holder lookups [19:46:33] [Server thread/INFO]: Holder lookups applied [19:46:38] [Server thread/INFO]: Starting integrated minecraft server version 1.10.2 [19:46:38] [Server thread/INFO]: Generating keypair [19:46:38] [Server thread/INFO]: Injecting existing block and item data into this server instance [19:46:38] [Server thread/INFO]: Applying holder lookups [19:46:38] [Server thread/INFO]: Holder lookups applied [19:46:38] [Server thread/INFO]: Loading dimension 0 (New World) (net.minecraft.server.integrated.IntegratedServer@64744e50) [19:46:38] [Server thread/INFO]: Loading dimension 1 (New World) (net.minecraft.server.integrated.IntegratedServer@64744e50) [19:46:38] [Server thread/INFO]: Loading dimension -1 (New World) (net.minecraft.server.integrated.IntegratedServer@64744e50) [19:46:38] [Server thread/INFO]: Preparing start region for level 0 [19:46:39] [Server thread/INFO]: Preparing spawn area: 89% [19:46:40] [Server thread/INFO]: Changing view distance to 12, from 10 [19:46:40] [Server thread/INFO]: [com.cheese.rpvp.capabilities.handlers.CustomItemBar:attachCapabilities:34]: Capability added [19:46:40] [Netty Local Client IO #1/INFO]: Server protocol version 2 [19:46:40] [Netty Server IO #3/INFO]: Client protocol version 2 [19:46:40] [Netty Server IO #3/INFO]: Client attempting to join with 6 mods : [email protected],[email protected],[email protected],[email protected],[email protected],[email protected] [19:46:40] [Netty Local Client IO #1/INFO]: [Netty Local Client IO #1] Client side modded connection established [19:46:40] [Server thread/INFO]: [Server thread] Server side modded connection established [19:46:40] [Server thread/INFO]: Player107[local:E:a195a490] logged in with entity id 529 at (-24.058057216920563, 76.0, 192.80032808752995) [19:46:40] [Server thread/INFO]: Player107 joined the game [19:46:40] [Client thread/INFO]: [com.cheese.rpvp.capabilities.handlers.CustomItemBar:attachCapabilities:34]: Capability added [19:46:40] [Server thread/INFO]: Saving and pausing game... false false false false false false false false false false 0 0 0 0 0 As you can see. the second I relog there's nothing but false's and 0's, Adjusted code: public class AdvStorage implements Capability.IStorage<IAdventurerHandler>{ @Override public NBTBase writeNBT(Capability<IAdventurerHandler> capability, IAdventurerHandler instance, EnumFacing side) { final NBTTagCompound tag = new NBTTagCompound(); boolean[] booleanAbilities = instance.getAllLevels(); int[] inthotkeyList = instance.getAllHotkeys(); NBTTagList tagBoolList = new NBTTagList(); NBTTagList tagHotBarList = new NBTTagList(); for(int i = 0; i < booleanAbilities.length; i++){ NBTTagCompound tagBooleanAppend = new NBTTagCompound(); Boolean s = booleanAbilities[i]; System.out.println(booleanAbilities[i]); tagBooleanAppend.setBoolean("Boolean", s); tagBoolList.appendTag(tagBooleanAppend); } tag.setTag("BooleanList", tagBoolList); for(int i = 0; i < inthotkeyList.length; i++){ System.out.println(inthotkeyList[i]); tagHotBarList.appendTag(new NBTTagInt(inthotkeyList[i])); } tag.setTag("hotlist", tagHotBarList); tag.setInteger("level", instance.getLevel()); tag.setInteger("xp", instance.getXP()); tag.setInteger("power", instance.getPower()); return tag; } @Override public void readNBT(Capability<IAdventurerHandler> capability, IAdventurerHandler instance, EnumFacing side, NBTBase nbt) { final NBTTagCompound tag = (NBTTagCompound) nbt; NBTTagList taglist = tag.getTagList("BooleanList", Constants.NBT.TAG_LIST); for(int i = 0; i < taglist.tagCount(); i++){ NBTTagCompound tagBooleanAgain = taglist.getCompoundTagAt(i); boolean booleantag = tagBooleanAgain.getBoolean("Boolean"); System.out.println("read: " + tagBooleanAgain.getBoolean("Boolean")); instance.setAbility(i, booleantag); } NBTTagList tagHot = tag.getTagList("hotlist", Constants.NBT.TAG_LIST); for(int k = 0; k < tagHot.tagCount(); k++){ instance.setHotkey(k, tagHot.getIntAt(k)); System.out.println(tagHot.getIntAt(k)); } instance.setLevel(tag.getInteger("level")); instance.setXP(tag.getInteger("xp")); instance.setPower(tag.getInteger("power")); } } I've decided to keep using boolean[] for now, since boolean[] is at least faster than Boolean[] and since I'm not doing bitSet operations in the current code it shouldn't impact performance that much. Especially with just a few. I just want to get this running for now. There's clearly something wrong with the reading part. Yet the reading part looks pretty decent to me. What do you mean by this? I'm not sure how to interpret this. Do you mean I shouldn't write as (tag + i), i and instead just (tag, i)?
  17. Are you sure you're getting the right Entity? It seems like trying to get the mob you're looking at on the server side is a bit of a stretch. Rather than that I'd try to get an Minecraft.getMinecraft().objectMouseOver which is a raytraceresult. Then use a packet to tell your server to add a potion effect to it. That seems like a more reasonable and foolproof idea, since the server doesn't know your exact position at all times, it just updates it with a client package every x ticks. I'm not an expert, but that's what I'd attempt. hopefully that can get you going. Edit: If you're sure this should work, the least you can do is implement a System.out.Println Message with the entity and the effect, just so you can be sure that whatever you think should happen is occuring.
  18. I'm fairly sure that starting 1.11 you want to register it in PreInit(), and your renderer in your client proxy PreInit(), but now that I've re-read I've noticed you're in 1.12, however, I'm not sure how to delete this post. edit: nevermind. I'm thinking about the wrong version.
  19. No problem brochacho. Feel free to post more if you're running into trouble. don't forget the documentation at https://mcforge.readthedocs.io/en/latest/gettingstarted/ which covers a LOT of usefull stuff.
  20. public class AdvStorage implements Capability.IStorage<IAdventurerHandler>{ @Override public NBTBase writeNBT(Capability<IAdventurerHandler> capability, IAdventurerHandler instance, EnumFacing side) { final NBTTagCompound tag = new NBTTagCompound(); boolean[] list = instance.getAllLevels(); int[] intlist = instance.getAllHotkeys(); NBTTagCompound tagappendbool = new NBTTagCompound(); NBTTagList taglist = new NBTTagList(); NBTTagList tagHot = new NBTTagList(); for(int i = 0; i < list.length; i++){ Boolean s = list[i]; System.out.println(list[i]); tag.setBoolean("Boolean" + i, s); taglist.appendTag(tagappendbool); } tag.setTag("BooleanList", taglist); for(int i = 0; i < intlist.length; i++) { int k = intlist[i]; System.out.println(intlist[i]); NBTTagCompound tag3 = new NBTTagCompound(); tag3.setInteger("Int" + i, k); tagHot.appendTag(tag3); } tag.setTag("hotlist", tagHot); tag.setInteger("level", instance.getLevel()); tag.setInteger("xp", instance.getXP()); tag.setInteger("power", instance.getPower()); return tag; } @Override public void readNBT(Capability<IAdventurerHandler> capability, IAdventurerHandler instance, EnumFacing side, NBTBase nbt) { final NBTTagCompound tag = (NBTTagCompound) nbt; boolean[] list = new boolean[10]; int[] intlist = new int[5]; NBTTagList taglist = tag.getTagList("BooleanList", Constants.NBT.TAG_LIST); NBTTagCompound tag2; for(int i = 0; i < taglist.tagCount(); i++){ tag2 = taglist.getCompoundTagAt(i); boolean s = tag2.getBoolean("Boolean" + i); System.out.println("read: " + tag2.getBoolean("Boolean")); list[i] = s; } NBTTagList tagHot = tag.getTagList("hotlist", Constants.NBT.TAG_LIST); for(int k = 0; k < tagHot.tagCount(); k++){ tag2 = taglist.getCompoundTagAt(k); int s = tag2.getInteger("Int" + k); intlist[k] = s; } instance.setAll(list); instance.setAllHotkey(intlist); instance.setLevel(tag.getInteger("level")); instance.setXP(tag.getInteger("xp")); instance.setPower(tag.getInteger("power")); } } Here it is. I've been trying to change some order around just to make sure. I've changed the saved variable to name + i, this way every instance gets it's own unique identifier. I know that might defeat the purpose of a NBTTagList. But it also doesn't work when I don't have the unique identifier. Edit: Thanks in advance. I know I make way too much use of the modder support forum. At least lately I've come to properly check the source material. This one I really couldn't figure out. Again, if you can point me at a class that'll help me instead of just helping outright, that's also fine.
  21. What you want to do is make a GUI/Overlay. There's a million tutorials for that even if you're not going to look at the forge src docs Now you'll want Forge to look for World.getBiome with a position. you'll want to take player.getPos for this. Then, whenever your previous World.getBiome is different from your current one, make your Gui Element appear with the correct name. That part should be as simple as a few if statements.
  22. So I've been working around with it and I'm still not quite able to save a TagList to my NBTTAgCompound and restore it at a later moment. Seems there's been a couple misreadings in the thread previously. So I'm bumping it in hope of help fixing my save/write.
  23. Alright. I'm not sure how new you are. But in these cases it's always incredibly helpfull to just take a gander at a relevant source class. For example; What throwable projectile manages to always shoot in the correct position? Right. The arrow. So go into your source folder and go to ForgeSrc/Net/Minecraft/client/renderer/Entity Here you will find a class called RenderArrow. RenderArrow will have the rotations you'll want to apply using your GlStateManager to make your projectile fully visible, If you're having trouble let me know. Second, your model seems to be 16x16 wide. that's pretty big, nothing you can't fix with scale though. But the rotationpoint is set at 0,0,0 which means it'll be at the very edge. Depending on how you want it to rotate you might want to set it to the middle of your projectile. Third. When you rotate your projectile using the code from RenderArrow your star might always render in a proper position away from your player, but rotated 90 degrees (So it's always in the same position from you, but vertical.) When this happens don't try to rotate with GLStateManager. It's a lot easier to just rotate the base model using something like the following: this.setRotationAngles(this.leftprong1, -0.67928211291826F, 0.0F, 0.0F); (And yes, that's in Rad, not Degrees) Sorry if my post rambles a bit. English isn't my first language, but I think this should be all to make your projectile fly off. Edit: Also, a little hint. And I'm only saying this because I just worked on my own custom projectile. If you want your projectile to cause particles on hit, look at the EntitySnowball class, if you want to change your Gravity you can simply overwrite the getGravityVelocity() class. And if you want to add particles during the flight you can override the onUpdate class, just make sure to invoke super so you don't mess up impact. you probably already know this stuff, but still.
  24. Here's your tutorial for networking, since nobody linked it before: https://mcforge.readthedocs.io/en/latest/networking/simpleimpl/ Honestly. Packets are very important and you should learn it at some point or another. With a lot of capabilities it's hard to get the client updated, My sollution was to send all capability updates in a synchronisation packet when the player logs in. Here's an example that I'm currently using to send capability info to the client: public class SmallMessage implements IMessage { public SmallMessage(){} private NBTTagCompound toSend; public SmallMessage(NBTTagCompound tag){ this.toSend = tag; } @Override public void toBytes(ByteBuf buf) { ByteBufUtils.writeTag(buf, this.toSend); } @Override public void fromBytes(ByteBuf buf) { this.toSend = ByteBufUtils.readTag(buf); } public static class MessageHandler implements IMessageHandler<SmallMessage, IMessage> { @Override public IMessage onMessage(final SmallMessage content, final MessageContext ctx) { FMLCommonHandler.instance().getWorldThread(ctx.netHandler).addScheduledTask(new Runnable(){ @Override public void run(){ final IBarHandler handler = Minecraft.getMinecraft().thePlayer.getCapability(CAPABILITY_BAR, null); NBTTagCompound tag = content.toSend; handler.setMana(tag.getInteger("mana")); handler.setHealth(tag.getInteger("health")); handler.setFatigue(tag.getInteger("fatigue")); } }); return null; } } } and I call it using if(player.hasCapability(CAPABILITY_BAR, null)) { final IBarHandler instance = getHandler(player); final NBTTagCompound tag = new NBTTagCompound(); tag.setInteger("mana", instance.getMana()); tag.setInteger("health", instance.getHealth()); tag.setInteger("fatigue", instance.getFatigue()); Main.packetHandler.barWrapper.sendTo(new SmallMessage(tag), (EntityPlayerMP) player); } Obviously you could easily add whatever information to the NBTTagCompound or even work with TagLists and such. The rest of the code is initiated in the way you see in the documentations linked above. If you read it through thoroughly you should be able to get a packet working.
  25. Yeah. That's what I said in my post as well Anyway, do you have any clue what's keeping the code in my original post from doing it's job, or what classes I could venture into to find out?
×
×
  • Create New...

Important Information

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