Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

Hello,

I'm working on Path-finding algorithm, also I have a class that makes the player go through the path that he found.

I want to programmally make the interaction between the player and a block,  when you try to harvest a block it takes time (depends on block and weapon) and while you try to break it you can see crack animation, this is what I'm looking for.

I want to call a function the does this interaction, I tried to use "harvestBlock" but it only harvests it without applying the animation and calculating how much time it supposed to take.

 

Any ideas how to it?

Thanks in advance.

Question - are you making client-side BOT, or server-side player AI?

 

Or maybe we can sue both sides? Asking because it can be done on either of those, or on both threads.

1.7.10 is no longer supported by forge, you are on your own.

  • Author

Hello, this is the code that I currently have - but the harvestBlock function is not what I'm looking for.

I need a function that would show the crack animation and break the block after the time it should take to mine it...

@SubscribeEvent
public void onPlayerTick(TickEvent.PlayerTickEvent event) {
	//this condition is here in order to avoid this code running twice for each tick
	if (event.phase == TickEvent.Phase.END)
		return;

	EntityPlayer player = event.player;
	Minecraft mc = Minecraft.getMinecraft();
	World world = mc.getIntegratedServer().worldServerForDimension(player.dimension);

	Vec3 blockLocation = Vec3.createVectorHelper(403, 35, 250);
	Block block = world.getBlock((int)blockLocation.xCoord, (int)blockLocation.yCoord, (int)blockLocation.zCoord);

	if (!world.isRemote){
		block.harvestBlock(world, player, (int)blockLocation.xCoord, (int)blockLocation.yCoord, (int)blockLocation.zCoord, 0);
	}
}

 

 

Can't help you directly (update to damn 1.8 please), but that is not way to go.

 

PlayerTickEvent is not only fired by both sides, but also for each player, you can't steer other players  on client.

 

*You need to use ClientTickEvent, registered by ClientProxy.

*You cannot reference ANY server methods/classes/logic.

*You will need to manipulate PlayerControllerMP (in 1.8, idk about 1.7).

*PlayerControllerMP handles client-sided player actions (note that is doesn NOT act on its own, but is a handler of actions) such as mining. It will send packets to server about those actions, including stuff like mining progress. It contains number of methods responsinble for handling mentioned actions. You will need to call those methods from ClientTickEvent whenever you want to create action without human-input (mouse/keyboard), and generate virtual actions - movement, mining, clicking).

 

Example:

Minecraft#rightClickMouse() has a line:

this.playerController.func_178890_a(this.thePlayer, this.theWorld, itemstack, blockpos, this.objectMouseOver.sideHit, this.objectMouseOver.hitVec)

 

Which informs client that "human" clicked mouse. PlayerController will be informed about it and send info to server. You need to replicate those actions.

Simply go over PlayerControllerMP.class and check its method callbacks. Then replicate them virually.

1.7.10 is no longer supported by forge, you are on your own.

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.