Jump to content

zerozhou

Members
  • Posts

    63
  • Joined

  • Last visited

Converted

  • Gender
    Undisclosed
  • Personal Text
    I am new!

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

zerozhou's Achievements

Stone Miner

Stone Miner (3/8)

5

Reputation

  1. thx, this seems much more useful than the tutorials. btw, if there is a size limit with the messages?
  2. I leave the game when it's 1.6.4 for a while and come back at 1.7.2. And the network become strange in 1.7.2. The tutorials in the wiki confused me, that it seems ok to send the message, but I cant see how it receive the message. Do someone have a very simple example of the new usage of the network that is easier to understand?
  3. Okay, I dont know this event before. But how about when the mob attack the player?
  4. In my mod maybe there actually is difference. I'm trying to apply some potion effect when the player(or other mobs) attack, no matter if the target take damage. And trying to change the interval of the attack action of the player(using EntityLivingBase#attacktime which seems to no use for player). That may cause the potion effect apply twice, and attack interval become hard to handle.
  5. When I call EntityPlayer#attackEntityFrom, it would post the LivingAttackEvent twice, as the EntityPlayer first post an event, and then call the super.attackEntityFrom, which would post the same event too. How could I identify these two event, or maybe it's a bug that forge make? BTW, I'm using 9.10.1.871.
  6. The whole code of mine. public static List GetNearEntityWithPlayer( EntityLivingBase player, int range, boolean needToBeSeen) { double px = player.posX; double py = player.posY; double pz = player.posZ; List l = player.worldObj.getEntitiesWithinAABB( EntityLivingBase.class, AxisAlignedBB.getBoundingBox(px - range, py - range, pz - range, px + range, py + range, pz + range)); List result = new ArrayList(); for (int i = 0; i < l.size(); ++i) { EntityLivingBase x = (EntityLivingBase) l.get(i); if (x != null) { if (x.getDistanceToEntity(player) <= range && (!needToBeSeen || x.canEntityBeSeen(player))) { result.add(x); } } } return result; } public static EntityLivingBase GetEntityLookAt(EntityPlayer player, int max_dis) { List list = Utils.GetNearEntityWithPlayer(player, 30, true); for(Iterator iterator = list.iterator();iterator.hasNext() { EntityLivingBase obj = (EntityLivingBase) iterator.next(); Vec3 vec3 = player.getLook(1.0F).normalize(); Vec3 vec31 = obj.worldObj.getWorldVec3Pool().getVecFromPool( obj.posX - player.posX, obj.boundingBox.minY + (double)(obj.height / 2.0F) - (player.posY + (double)player.getEyeHeight()), obj.posZ - player.posZ); double d0 = vec31.lengthVector(); vec31 = vec31.normalize(); double d1 = vec3.dotProduct(vec31); if (d1 > 1.0D - 0.025D / d0 && player.canEntityBeSeen(obj)) { return obj; } } //player.worldObj.spawnParticle(par1Str, par2, par4, par6, par8, par10, par12) return null; }
  7. I did it with worldObj#getEntitiesWithinAABB and scan for every entity in the list(Maybe there is a better way, tell me if you have one afterwards). and this is partly(or all? I cant remember) copy from code of enderman to know if the obj is looking at by the player. EntityLivingBase obj = (EntityLivingBase) iterator.next(); Vec3 vec3 = player.getLook(1.0F).normalize(); Vec3 vec31 = obj.worldObj.getWorldVec3Pool().getVecFromPool( obj.posX - player.posX, obj.boundingBox.minY + (double)(obj.height / 2.0F) - (player.posY + (double)player.getEyeHeight()), obj.posZ - player.posZ); double d0 = vec31.lengthVector(); vec31 = vec31.normalize(); double d1 = vec3.dotProduct(vec31); if (d1 > 1.0D - 0.025D / d0 && player.canEntityBeSeen(obj)) { return obj; }
  8. Minecraft is a client side only class. You should try to get the entity the player is pointing at in the server side without Minecraft#objectMouseOver. As it's client only, when the target is not null, it would be always client side.
  9. So you means that I should count the number of players in the world. I'll try it later. Hope it works.
  10. I'm try to heal the player while he is sleeping in the server, like one point health in 30s. But when you play in single-player mode, the time flies, there is no evening. So I want to heal the player when he wakes up. How could I know?
  11. The code @ForgeSubscribe public void cancelHealthBar(RenderGameOverlayEvent.Pre event){ if (event.type == RenderGameOverlayEvent.ElementType.HEALTH) { event.setCanceled(true); mc.fontRenderer.drawString("123467", 100, 1, 0xffff80); GL11.glColor3f(1, 1, 1); } } Thought, I found another way to get rid of this. I try to cancel the event, and render it when ElementType.ALL event is post. But the origin problem seems not to be sloved.
  12. I've tried. Not work.
  13. I hook the healthbar rendering event and rewrite myself. @ForgeSubscribe public void renderHealthBar(RenderGameOverlayEvent.Pre event){ if (event.type == RenderGameOverlayEvent.ElementType.HEALTH) { event.setCanceled(true); // Which I render my custom healthbar here mc.fontRenderer.drawStringWithShadow("" + display_health, left, top, 0xffffff80); } } I try to display the health using number, and try to draw the number with drawStringWithShadow. But after that, the foodbar become strange, it's color is the same as the color of the number. Don't know what's going wrong, maybe some gl11 problem. Could anyone tell what's going wrong?
  14. This may help you. But I was doing this in 162, dont know if there is difference. To write a movementinput and act the movement by yourself. But one thing is that you need to control the movement by yourself too. It's not so smart when you want to control a player with WSAD just with code. The code below is that when the player have potion 37,39 and 41, he can't move and jump. and with potion 49, when you press W, you go backward, same with "AD". public class ConfusedMovementInput extends MovementInput { public ConfusedMovementInput(MovementInput interceptedMovementInput) { underlyingMovementInput = interceptedMovementInput; System.out.println("construct movementinput"); } @Override public void updatePlayerMoveState() { underlyingMovementInput.updatePlayerMoveState(); EntityPlayer p = Minecraft.getMinecraft().thePlayer; this.jump = underlyingMovementInput.jump && !p.isPotionActive(37) && !p.isPotionActive(39) && !p.isPotionActive(41); this.sneak = underlyingMovementInput.sneak; if (p.isPotionActive(37) || p.isPotionActive(39) || p.isPotionActive(41)) { this.moveForward = 0; this.moveStrafe = 0; } if (p.isPotionActive(49)) { this.moveStrafe = -underlyingMovementInput.moveStrafe; this.moveForward = -underlyingMovementInput.moveForward; } else { this.moveStrafe = underlyingMovementInput.moveStrafe; this.moveForward = underlyingMovementInput.moveForward; } } public void setConfusion(boolean newConfused) { confused = newConfused; } protected MovementInput underlyingMovementInput; private boolean confused = false; } and you can replace the origin movement input somewhere in your code EntityClientPlayerMP player = Minecraft.getMinecraft().thePlayer; if (player != null) { if (player.movementInput instanceof ConfusedMovementInput) { } else { player.movementInput = new ConfusedMovementInput(player.movementInput); } }
  15. Yeah I found it. thanks.
×
×
  • Create New...

Important Information

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