
coolAlias
Members-
Content Count
2805 -
Joined
-
Last visited
Content Type
Profiles
Forums
Calendar
Everything posted by coolAlias
-
I just want to stress the bolded portion there - marking your classes @SideOnly(Side.SERVER) will preclude the use of your mod in single player. Is that really what you want? In the vast majority of cases, there isn't any reason to make a mod specifically server-side only. You could just as easily make it a general mod that performs its duties in the various mod init phases, events, etc., all running on the logical server i.e. when the World object is not remote, and it will have the same effect but be usable also in single player. Just a thought.
-
Absolutely not. They will not do what you think they will. Each IMessage is created once when you send it, then a new instance is created on the other side and reads the data sent over the network. Once that's done, an instance of the IMessageHandler is created and the message passed to it. So, if you send a message in return, it will be recreated on the other side and another new instance of the IMessageHandler created to handle that. This is why a single handler can handle both sides, but if doing so you have to check which side you are on before doing anything if your message behaves differently on different sides. When a single message can be handled on both sides, you need to register it twice - once on each side - and using the same discriminator byte (at least that's what I've found). However, it's somewhat rare for a single message to be useful on both sides, so you may want to carefully evaluate whether one message type is sufficient, or whether you really need two.
-
If you read the crash log, you will see it: cpw.mods.fml.common.LoaderException: java.lang.NoClassDefFoundError: net/malisis/core/network/MalisisNetwork Whatever mod 'malisis' is, that is your culprit.
-
[1.7.10]How to ensure world.setBlock successful?
coolAlias replied to D0431791's topic in Modder Support
Sounds like you are setting the block on the client side - only ever call setBlock on the server side, i.e. when the world is not remote. if (!worldObj.isRemote) { // logical server - okay to set block worldObj.setBlock(...); } -
ClientTickEvent itself isn't doing anything - it is posted twice per Minecraft run tick on the client side, from the Minecraft class. The first time is the START phase, and the second time is the END phase. Since it is CLIENT side only, any player data retrieved at this point must have been kept updated from the server side via packets. Several things are kept in sync for you by Minecraft, but most things are not because they are not normally needed client-side. What are you trying to do that made you look at ClientTickEvent?
-
[1.8.9] Sending a tileentity (with IInventory) through a packet
coolAlias replied to Roboguy99's topic in Modder Support
Sorry, you don't actually use the Container directly - send the TE coordinates in the packet, as Draco mentioned, then use those to fetch the TE and add the stack to the inventory. If your inventory is coded correctly, the Container will notice the changes and send an update to the client. If it's your first time using packets, I suggest following diesieben's tutorial to get the basics down; if you end up making lots of packets and get sick of writing IMessageHandler classes, then take a look at my tutorial. I'm not sure what you mean about linking a world to a URL - could you explain that more? -
[Solved][1.9] Vanilla sound not playing when called from my mod
coolAlias replied to American2050's topic in Modder Support
@jeffryfisher Or if he doesn't want anyone nearby to hear and figure out that he's using a hoe, which is what I assumed* * given that he was wanting to play the sound on the client, but perhaps that was the only way he found? or is that how vanilla tools or just the hoes behave? I don't have an IDE to check right now, but I kinda think that tool sounds are client only - do you actually hear other players chopping and mining? Not that I recall, but it's been ages since I've played. -
I only meant to set persistence for the purpose of testing, not permanently I don't recall where you can find the vanilla spawn rates, but most of them are in the range of 10 to 100 if I recall correctly. For my own mobs, I tend to give them spawn rates of 5-10 and they spawn regularly enough to be fun, but aren't an overwhelming presence. I'd just play around with it until you find something you like to use as the default, and then give your users the option to set it to what they like in via your configuration file.
-
There may other checks going on that prevent it from spawning after #getCanSpawnHere, though one would think that the spawn event would be correct. That's odd. It's possible that it is simply despawning before you get there. Try setting the entity to be persistent, or return false for #canDespawn. Alternatively, you could try increasing your entity's spawn rate to something ridiculous, like 10,000, just to see if it will spawn. Unrelated to your issue, but in 1.8.9+ (and maybe earlier), EntityRegistry#registerModEntity optionally takes additional parameters for the egg colors and will automatically register the spawn egg for you; it is recommended to use only that method and not add spawn eggs manually.
-
[1.8.9] Sending a tileentity (with IInventory) through a packet
coolAlias replied to Roboguy99's topic in Modder Support
No, most definitely do NOT use the TE description packet for this - that is not what it is designed for. Whenever you have a client-side action, such as a GUI button, that you want to change something on the server, you need to send your own custom packet that only knows what action the player requested, e.g. clicked GUI button 'X', and then when that packet is handled on the server, you validate the action, e.g.: - is the player interacting with the appropriate container / TE for this to happen? - is the player allowed to press that button? - etc. Once you determine the action is allowed, then you can alter the inventory contents via the server side Container, which will automatically update the client side view. IF you are sure the action will succeed and IF you want your GUI to be extremely snappy, you can go ahead and update the inventory client-side first before you send the packet, BUT NEVER let the client-side dictate what the server-side values are. That is, still do the server side validation before altering the inventory, and let the server update the client with the correct values (which should be the same, but you never know). -
IIRC, #onBlockDestroyed is an Item class method - it should be called for all items, not just ItemTools.
-
Try using Block.getItemForBlock(Blocks.cake) or something like that. If that doesn't work, then the cake block doesn't have a corresponding ItemBlock (like doors), but a special Item, so you'd use Items.cake or whatever it's called instead.
-
[1.8] summoning entity when block is broken.
coolAlias replied to thvardhan's topic in Modder Support
You need to make a new entity each time, rather than spawning the same one multiple times. Every entity needs to be its own unique instance. -
[Solved][1.9] Vanilla sound not playing when called from my mod
coolAlias replied to American2050's topic in Modder Support
As you read more vanilla code, you will see cases of when and when not to use !world.isRemote. Generally, you use it to encapsulate code that changes the world or things within the world, such as modifying a block state, giving a player an item, or spawning an entity. You only need to encapsulate the actual changing code, not necessarily everything around it, though sometimes that is useful to avoid wasting processing power on the client. Anyway, if you model your item after the hoe, then mimic their #onItemUse implementation more closely as I doubt they encapsulate the entire thing in an if (!world.isRemote) statement. -
[Solved][1.9] Vanilla sound not playing when called from my mod
coolAlias replied to American2050's topic in Modder Support
World#playSound plays a sound only when called on the client side (i.e. when the world IS remote). My guess is that your method is only getting called on the server. Is #tillDirt your own method, or inherited from Item and/or ItemTool? If it's your own method, show the code that calls it. If it's a vanilla method, are you sure it is called on both the client and the server side? If you haven't already, take a closer look at the hoe to see how and where it plays its sound. -
Hm, your entity registration code looks correct, you're not doing anything strange in your Entity class, and you're testing in a new world so the entity name hasn't changed... those are the usual suspects when it comes to tracking entry errors, so it could be that spawn eggs in 1.9 are bugged. If my coding computer wasn't toast, I'd try it out myself to confirm it; if it is indeed a bug, you can open an issue on Forge's issue tracker (GitHub).
-
In my earlier post, I mentioned this: if (!itemstack.hasTagCompound()) { // method name may vary based on version itemstack.setTagCompound(new NBTTagCompound()); } That is the ONLY way you should ever set an empty tag compound on an ItemStack, and that will guarantee that the ItemStack does in fact have an nbt tag. You put that code as the first thing in your #onItemRightClick or #onItemUse method so that the first time the item is used, you will create the tag compound if it doesn't already have one. That way you can add / set your custom tag. You don't need to check if it has the tag or not; integer tags return 0 if they do not exist: if (stack.getInteger("abljeilahgahgeiah") == 0) { // either the tag didn't exist, or it is actually zero } Really, though, you shouldn't be too concerned with that if you follow my advice about using the world time + interval instead of a traditional cooldown timer. There is no reason to add yet another a ticking counter when you already have a perfectly good one.
-
[1.8] summoning entity when block is broken.
coolAlias replied to thvardhan's topic in Modder Support
You have to create the zombie entity, set its position (and anything else you want), and THEN summon it Also, only spawn entities on the server side, i.e. when the world is not remote. The client side entity will be created automatically. -
You don't need to worry about giving it an NBTTagCompound when summoned - the tag will be created the first time the player uses it. Unless, of course, you need to store other things in the tag, too? I'm not sure if there are any hooks that allow you to change the outcome of /give and other commands, but I doubt it. If the player has /give permissions, they can set the NBT to whatever they want. As for damaging it when destroying a block, check out ItemTool. I'm certain there is an Item (or ItemTool) method that does just that.
-
I don't think there is any sort of color code -> int mapping anywhere in Minecraft. You either map them out yourself, or you ask your users to use the integer value of the color they want rather than a string code.
-
You should really properly indent your code - it's very hard to read right now and probably not a small part of why you're having trouble. Really, it makes a difference: if (itemstack.stackTagCompound.getInteger("word") == 0) itemstack.stackTagCompound = new NBTTagCompound(); itemstack.stackTagCompound.setInteger("word", 60); Look at that - the only thing you do if the 'word' value is 0 is completely wipe any data that may exist in the stack's current tag compound... And then, whether the value was 0 or not, you continue on your merry way to heal the entity. 1. ALWAYS use brackets { } with if statements, even if they are one line. Yeah, some cool kids don't do it, but it can save you some facepalms. 2. NEVER overwrite an existing NBTTagCompound on an ItemStack - you have no idea what it contains, and it is probably important (e.g. enchantment info, etc.) 3. The only time you set a new tag compound on an ItemStack is when it doesn't have one, but if it didn't have one, your check will crash anyway: if (itemstack.stackTagCompound. // right here, because you're trying to call a method on NULL getInteger("word") == 0) Better to use: if (!itemstack.hasTagCompound()) { // method name may vary based on version itemstack.setTagCompound(new NBTTagCompound()); } 4. I don't see anywhere where you decrement the cooldown timer on the stack... so I guess it's single-use? It's better to store the world time at which the stack can be used again anyway, as then you only check when the item is used, not every tick: public static final int INTERVAL = 60; // cooldown interval // when your item is used: if (world.getTotalWorldTime() > stack.getTagCompound().getInteger("nextUse")) { // yay, enough time has passed to use the item again! now set the next time it will be available stack.getTagCompound().setInteger("nextUse", world.getTotalWorldTime() + INTERVAL); } Note: null checks not provided.
-
FontRender#drawString takes an int parameter for the color, which is a single-value representation of the RGB values. There are color charts available online, or you can search through Minecraft's code for their chat formatting color codes to find their values.
-
Try removing all spawn eggs for your entity from your inventory, then getting new ones and trying to spawn it again. Does it still happen then? As for the attribute, if the attribute is already registered, you can still change the value: // from 1.8 - names may have changed this.getEntityAttribute(SharedMonsterAttributes.attackDamage).setBaseValue(5.0D);
-
[1.7.10][and newer]How to get the speed part pushed by water?
coolAlias replied to D0431791's topic in Modder Support
The method that handles water acceleration is in the World class and is called #handleMaterialAcceleration. If you determine the player is in water, you can do some math to reverse it and then reapply it, or you could probably get by with a simple player.motionX/Y/Z *= 2. If you don't want the player to get pushed at all, you can make a method to reverse the applied motion.