-
Posts
424 -
Joined
-
Last visited
Everything posted by Daeruin
-
[1.8.9] [SOLVED] PlayerTickEvent not applying damage when it should
Daeruin replied to Daeruin's topic in Modder Support
Draco, thanks for the suggestion. I tried it out. Unfortunately, after making sure that the world is not remote and the phase is START (or END, doesn't make a difference), (event.player.posX == event.player.lastTickPosX) only seems to be false about one tick out of twenty, even when I'm moving constantly. I'm trying to learn about packets so I can try coolAlias's suggestion. It's taking a while, but I'll try to report on that. In the meantime, any other suggestions are welcome. -
[SOLVED] Error com.google.common.collect.Multimap cannot be resolved
Daeruin replied to Daeruin's topic in Modder Support
I'm replying to my own month-old thread because I had the same problem again and had to look it up so I could remember the solution. Unfortunately, I didn't post the details. So here they are. In Eclipse: 1. Right click on the project in the Package Explorer. 2. Choose Build Path > Configure Build Path. 3. In the Libraries tab, choose Add External JARs. 4. Navigate to the physical location of the missing library. In my case, it was Users/~/.gradle/caches/modules-2/files-2.1/ and then into the specific package needed. I still don't understand why this is needed, because I can see the forge project in my Package Explorer, and if I go into the Referenced Libraries, I can see the ones that are missing from my build path. I must have set up something wrong, but I don't know what. Anyhow, hopefully this helps someone else in the future. Edit: Clarified instructions. -
[1.8.9] [SOLVED] PlayerTickEvent not applying damage when it should
Daeruin replied to Daeruin's topic in Modder Support
Awesome, that worked perfectly! However, now my check for movement is failing. It appears that whenever the world is not remote, event.player.motionX is always zero. Any other ideas how I can accomplish this? I need the event to trigger when the player is walking or sprinting across a certain type of block, and I need it to apply damage. -
[1.8.9] [SOLVED] PlayerTickEvent not applying damage when it should
Daeruin replied to Daeruin's topic in Modder Support
Good point. I really haven't been thinking about server use at all, but if the event gets called every time ANY player ticks . . . yeah. Not quite what I was imagining. So I check if the tick is happening on server side, in the correct phase, and whether Entity#ticksExisted % 100 is zero, then apply the damage. That sounds like it would be more reliable. I'll try it when I get home tonight. I just realized that I probably don't need to check if the entity is a player, because I'm using PlayerTickEvent. In my earlier code I created an Entity variable named "entity" and assigned it the value of event.player, then later on I checked to see if "entity" is an instance of EntityPlayer. Seems a little redundant, no? -
[1.8.9] [SOLVED] PlayerTickEvent not applying damage when it should
Daeruin replied to Daeruin's topic in Modder Support
Yes, I tried that after I posted as it seemed the next logical step. The behavior I'm seeing is that I can't predict whether any given tick is occurring on the server or the client. So if I check for whether the world is remote, THEN check whether a specific number of ticks have occurred (e.g., tickCount % 50), chances are good that specific tick was on client side (for example, see ticks 50 and 100 from the sample output in my last post), and nothing happens. In fact, when I'm checking every 100 ticks, the vast majority of those ticks are occurring on client side--embedding that kind of check inside a check for whether the world is remote will practically guarantee that the event code never occurs, especially after adding the other conditions I want to add (walking or sprinting on a specific kind of block). Maybe instead of checking every 100 ticks, I need to just generate a random number that should let the code execute 1% of the time. Same net result, hopefully. -
[1.8.9] [SOLVED] PlayerTickEvent not applying damage when it should
Daeruin replied to Daeruin's topic in Modder Support
OK, I kind of figured out what's causing this weirdness. To answer your question, I am registering the event handler in my Common Proxy during post initialization. I tried registering it in Server Proxy and Client Proxy, in pre, init, and post, just to see what would happen. It's interesting that the event doesn't fire at all when registered in Server Proxy, but I think that's a red herring. I created a new event without all the extra stuff. All it does is increment the tick value and print to the console the tick value, phase, and whether the world is remote. I found that I get ticks from client and server in roughly equal numbers, but in irregular patterns—sometimes it's 2 ticks in a row from the server, then 2 from client, for 20 or 30 ticks; then I'll get 10 ticks in a row from the server and 10 from the client for a little while. So it's a toss of the dice whether any given tick is coming from the client or the server. Either way, the phase alternates every other tick regularly. So next I set it up to check if the world is remote every X number of ticks. For example: public class TickTest { int tick; @SubscribeEvent public void onTick(PlayerTickEvent event) { tick += 1; if (tick % 50 == 0) { System.out.println("Tick: " + tick + " - Phase: " + (event.phase) + " - World remote? " + event.player.worldObj.isRemote); event.player.attackEntityFrom(DamageSource.generic, 1.0F); } } } The code above has a tick firing from the server about 5 out of 15 times. I guess that's not too weird, given the uneven patterns I was seeing when checking every tick. I'm guessing it would have evened out to 50% of the time if I waited long enough. I also checked the tick phase, and it was always END, no matter what. Sample from log output: Every time the tick comes from the server, the code to damage the player works (well, it takes a couple hundred ticks upon starting up the world before the damage starts registering). When the tick comes from the client, no damage is applied. If I change the above code to check every 100 ticks, I get almost every single tick occurring on the client (in one test I got a single tick from the server after waiting 4000 ticks, in another test it took 2000 ticks). The reason my previous tests seemed to be occurring only on the client is because I was only checking every 100 ticks. If I change it to every 101 ticks, I get roughly every other one from the server. So it appears if I check every X ticks, I just need to randomly pick the right value for X to get the code to execute regularly. Unless someone else can see a pattern that I can't. -
[1.8.9] [SOLVED] PlayerTickEvent not applying damage when it should
Daeruin replied to Daeruin's topic in Modder Support
Further testing shows the event is only happening on the client side (event.player.worldObj.isRemote is always TRUE, and the event doesn't fire at all if I register it only in the server proxy). Does that mean I need to set up a packet handler to make sure the damage gets communicated to the server? I haven't delved into packet handling yet. -
[1.8.9] [SOLVED] PlayerTickEvent not applying damage when it should
Daeruin replied to Daeruin's topic in Modder Support
Could this problem have something to do with whether the event is firing on client vs. server side? Or maybe the tick phase? I'm at work so I can't check, but I'll try tonight. Any further insight on this would be appreciated. -
[1.8.9] [SOLVED] PlayerTickEvent not applying damage when it should
Daeruin replied to Daeruin's topic in Modder Support
I didn't mean to sound dismissive. I did ask for advice on player movement, and I appreciate the tip. I'm just really frustrated that I can't get the damage to be applied consistently. -
[1.8.9] [SOLVED] PlayerTickEvent not applying damage when it should
Daeruin replied to Daeruin's topic in Modder Support
The motion part isn't the problem—the check for sneaking is working OK for now. The problem is that the damage isn't getting applied for some reason. -
[1.8.9] [SOLVED] PlayerTickEvent not applying damage when it should
Daeruin replied to Daeruin's topic in Modder Support
Duh. Just figured out the last one right after I posted. Still wondering about the first two questions, though. -
I'm working on a little feature that is supposed to apply damage to the player when they are walking or sprinting across a specific kind of block on a semi-random basis. As a test, I have created a PlayerTickEvent: As you can see, I'm not actually checking if the player is moving yet. I'm using dirt for now (because it's plentiful). I haven't applied any kind of randomization. I'm just trying to get it to happen every 100 ticks as a test. But it isn't happening. I'm keeping my player just standing there on dirt blocks, and can see my debug statement "ALL CHECKS PASSED" occurring every 100 ticks like clockwork, but the damage is only being applied every 20th time or so. It seems random. Any idea what is preventing the damage from being applied? As a secondary question, how would you recommend checking if the player is walking or sprinting over the block? I was thinking that as long as the player is on the ground (event.entity.onGround == true) and not sneaking (event.entity.isSneaking() == true) and their X movement isn't 0 (event.entity.motionX != 0), then that's enough to apply the damage. I've implemented the first two, but not the last. Does that sound like it would work? Oh, and a third, very minor, question. This is how I'm registering this event: FMLCommonHandler.instance().bus().register(new PlayerTickEventHandler()); But Eclipse is telling me that "bus()" is deprecated. It seems to be working as is, but I'm curious what is the correct way to do this for 1.8.9. I did some searching and couldn't find a quick answer, so I thought I'd tack it onto this post. Thanks in advance! Edit: Added clarification to subject title
-
Woo-hoo! It worked! Many thanks!
-
It's not my block. I've already looked through the available events and considered using HarvestDropsEvent but it didn't seem right. I just looked again and noticed that HarvestDropsEvent has BlockPos and IBlockState as parameters. What would I do to actually place the block?
-
I'd like some advice on how to do this: I want to allow the player to break a block, drop some items, and then immediately replace the block with a new block. I've seen at least one mod that does this, Draco's Reasonable Realism, but can't piece together the code (I only have experience with modding for 1.8.9). I've been searching for ages but haven't come up with anything helpful. I have been successful at using events for other things, like using HarvestDropsEvent to change vanilla drops and BreakEvent to cancel breaks, but neither of those seems right for what I want to do this time. Any help you can give would be appreciated.
-
[SOLVED] Error com.google.common.collect.Multimap cannot be resolved
Daeruin replied to Daeruin's topic in Modder Support
That gave me the clue I needed. How did you know that com.google.common.collect.Multimap was part of the guava library? I checked my build path, and sure enough that library wasn't listed. After a bit of fiddling, I finally found where the library was located in my system and was able to add it as an external jar. Is there a better way of doing it? It sounds like the library should have been in my build path already if Forge was set up correctly. It makes me think there are probably other missing libraries, but I'm not sure what it's supposed to look like. -
I just tried to make a new tool in my mod, and I'm getting an error: The type com.google.common.collect.Multimap cannot be resolved. It is indirectly referenced from required .class files I've been searching online for a couple hours and haven't figured out how to fix this. I finally deleted Forge and Eclipse and reinstalled from scratch, and I'm still getting this error. Any idea what's up?
-
[1.8] Custom drop from vanilla block not working
Daeruin replied to Daeruin's topic in Modder Support
It's working now! Thanks so much for your feedback. -
[1.8] Custom drop from vanilla block not working
Daeruin replied to Daeruin's topic in Modder Support
Here you go. Main: CommonProxy: ClientProxy: ServerProxy: -
[1.8] Custom drop from vanilla block not working
Daeruin replied to Daeruin's topic in Modder Support
I tried moving it to init and preInit. No change. -
[1.8] Custom drop from vanilla block not working
Daeruin replied to Daeruin's topic in Modder Support
The breakpoint on CommonProxy#postInit is hit, but the one on ModDrops#onDrop is not. I had already added System.out.println in a few places with the same results--postInit occurs but ModDrops never seems to. -
I just started a new mod, and I'm trying to get my new item to drop from a vanilla block. It's nothing original (straw dropping from tall grass). It was just supposed to be something easy. But I can't for the life of me get it to work. I don't get any errors, but the item never drops. public class ModDrops { @SubscribeEvent public void onDrop(BlockEvent.HarvestDropsEvent event) { if (event.state.getBlock() == Blocks.tallgrass) { event.drops.clear(); event.dropChance = 1.0f; event.drops.add(new ItemStack(ModItems.ItemStraw, 1)); } } } public class CommonProxy { public void preInit(FMLPreInitializationEvent e) { ModItems.createItems(); } public void init(FMLInitializationEvent e) { } public void postInit(FMLPostInitializationEvent e) { MinecraftForge.EVENT_BUS.register(new ModDrops()); } }