Jump to content

zerozhou

Members
  • Posts

    63
  • Joined

  • Last visited

Everything posted by zerozhou

  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 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?
  13. 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); } }
  14. And I found when I pick the item up on the ground, it will combine with my inventory item that with different damage too.
  15. I want to make an item with damage. With different damage, it represent different item, like wool and wood. But when I craft the item with damage 2, it auto combine with the item with damage 1 when using Shift+Click. But when I take it from the crafting table(custome crafting table, don't know if it's related), they are different, and can not combine together. Which method should I override to prevent the item from combine automatically between item with different damage?
  16. It's a big question. Maybe anyone has his own opinion. I'm trying to talk about mine. 'Event' is something that happened or is happening. When the zombie hit you, it's an event(And we would know that it's LivingAttackEvent and LivingHurtEvent). As the mod required, you may want to know about what event is happenning. If we want to make zombie very very strong, we can catch the 'event' that when the damage is count(LivingHurtEvent), and change the damage to make the zombie stronger(there is other way to do this of course). Or we could apply special effect to the player when he's hit by zombie. To know when the player is hit, you need events. And many other events, like LivingDeathEvent. To catch this event allow you to do something when someone(Zombie, Player or other living) died. And do something you want after this, like bury them. To know when someone die, you need events. To catch the event, add an annotation before the method, and register it. The class is as below. public class EventTest { @ForgeSubscribe(priority = EventPriority.LOW,receiveCanceled = true) public void test1(LivingFallEvent event) { if(event.entityLiving instanceof EntityPlayer) { EntityPlayer entityPlayer = (EntityPlayer)event.entityLiving; entityPlayer.sendChatToPlayer(ChatMessageComponent.func_111066_d("Falling Star!You fell "+event.distance+ " meters.That's cool,man!"); } } } And registe it with MinecraftForge.EVENT_BUS.register(new EventTest()); So when someone fall to the ground, he will receive a message how far he fall. And you can set event.distance to 0.0f or 24.f to get rid of the falling damage or make the player die when fall, no matter how far he falls. And there are many feature of event, like result, priority, cancelable and so on. Maybe you should figure it out yourself.
  17. Maybe I found how to do this with forge as I found a code like this in EntityPlayer //Copy over a section of the Entity Data from the old player. //Allows mods to specify data that persists after players respawn. NBTTagCompound old = par1EntityPlayer.getEntityData(); if (old.hasKey(PERSISTED_NBT_TAG)) { getEntityData().setCompoundTag(PERSISTED_NBT_TAG, old.getCompoundTag(PERSISTED_NBT_TAG)); } Which would be called when the player is respawn. It seems that I need to record the data with the key PERSISTED_NBT_TAG and add a new NBT node here. Am I right?
  18. I've try to record something about the player with NBT, like level or something like that. But when the player dead, and respawn, all the record seems to be clear. I want to keep the information of the player after his death. Which code should I check for?
  19. I dont know what MyStone2 do. Why not just let Mystone1 to drop cobblestone and smelt the cobblestone to a Stone? If so, all recpie can stay still. And about x-ray, I'll check it sometime, but maybe not now. I think the theory is strong enough that unless the client can cheat the server to change the server's behavior or make the server to spawn something. And that maybe not the problem I can handle.
  20. Actually I havent used xray to know how it works. And my idea is base on that even the server dont know where the ore is. If I simply give the new block the texture of stone, maybe xray could filter all the real stone, make them transparent and knowing that where the real ore is.
  21. I did stupid things. Now it works. And for change the block from y = 0 to 40, it increase the spawn time from 12s to 20s. Which I think it's acceptable and maybe a safer way to do what I want. Thanks all of you.
  22. And I try to replace all stone into a new block while generating the map, and I found that the speed is acceptable. But what it confused me is that some stones are replaced but some are not in different chunk. I think that it's the generate algorithm that run my own generator firstly then the original one, dont know if that's right. If so, how to make my generator run last?
  23. Yes it seems ok. But while I'm checking the code, I found that there is a "public static final Block stone" in the class Block, and many other code reffer this. which may cause some strange things? Should I change that too? And I'm thinking if there is a event that hook when the player break a block(it seems there is not). If so, I would not need to change the vanilla stone which may have many many issues.
×
×
  • Create New...

Important Information

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