Jump to content

Darkona

Forge Modder
  • Posts

    21
  • Joined

  • Last visited

Everything posted by Darkona

  1. That is an almost completely useless answer. See, the Ice code works on the side of the blocks. What he wants to do is on the side of the player, meaning it is the player (presumably while wearing something) who is going to be "slippery" (I'm assuming) Turns out that if you want to constantly change the block properties under you, you're only wasting your time. To answer the OP's question, look here: https://github.com/Darkona/AdventureBackpack2/blob/master/src/main/java/com/darkona/adventurebackpack/common/BackpackAbilities.java See the itemSlime method for a way to make it so the player is all slippery. Mind you, this method executes every tick and leaves blocks untouched. You can use something similar in an event handler, executing in every tick the player has boots with the enchantment or however you're handling the enchantment.
  2. onBlockActivated happens in both client and server, and also you should spawn the item only serverside
  3. This answer is applicable for 1.7.10 .json models are for 1.8 onwards (AFAIK) http://www.minecraftforge.net/wiki/Rendering_a_Techne_Model_as_a_Block Also, iChun made a mod called Tabula that is way better than Techne to make models.
  4. You need: 1- A model with the two cubes, one inside the other. 2- A texture file that includes the textture for both boxes- 3- A Tile Entity Special Renderer. 4- Your own rendering method (preferrably in the model itself), in wich you will first render the inside box, then call a blending function, and render the second, bigger cube. Example: smallBox.render(f5); GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); bigBox.render(f5) GL11.glDisable(GL11.GL_BLEND); Blending enables alpha transparency, so by rendering the outer box second you already rendered the small inside and the second will be semi transparent.
  5. You can also use rand.getNextGaussian() to add some natural flavor to the motion.
  6. Yeah, my bad, i didn't see the second one. It appears to me that the tileentityrenderer won't work for the inventory you have to do the rendering yerself. You are looking for something along these lines. This is not actual code, you need to adapt it for your personal circumstances. public void renderItem(IItemRenderer.ItemRenderType type, ItemStack stack, Object... data) { ///blahblahblah get the texture get the model etc case INVENTORY: Minecraft.getMinecraft().renderEngine.bindTexture(modelTexture); { GL11.glPushMatrix(); GL11.glColor4f(1, 1, 1, 128); GL11.glPushMatrix(); GL11.glTranslatef(-0.5f, 0f, -0.5f); //This one is important because the model renders upside down because of reasons GL11.glPushMatrix(); GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); GL11.glPushMatrix(); GL11.glScalef(1.9f, 1.9f, 1.9f); model.render(null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.05F, other arguments, whatevers); GL11.glPopMatrix(); GL11.glPopMatrix(); GL11.glPopMatrix(); GL11.glPopMatrix(); } and for entity items case ENTITY: Minecraft.getMinecraft().renderEngine.bindTexture(modelTexture); { GL11.glPushMatrix(); GL11.glColor4f(1, 1, 1, 128); GL11.glPushMatrix(); GL11.glTranslatef(0f, 1f, 0f); GL11.glPushMatrix(); GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); GL11.glPushMatrix(); GL11.glScalef(1.2f, 1.2f, 1.2f); model.render(null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.05F, again some extra stuff if you want); GL11.glPopMatrix(); GL11.glPopMatrix(); GL11.glPopMatrix(); GL11.glPopMatrix(); }
  7. You are using it wrong. You should override the whole render code in IItemRenderer to render in the inventory, not use the tile entity renderer. Somewheree in your initialization you should have something like this: ClientRegistry.bindTileEntitySpecialRenderer(MyTileEntity.class, new MyTileEntityRenderer()); http://www.minecraftforge.net/wiki/Custom_Tile_Entity_Renderer
  8. Block public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack stack) { //This gets the direction the player is facing as an int from 0 to 3 int dir = MathHelper.floor_double((player.rotationYaw * 4F) / 360F + 0.5D) & 3; //You can use the block metadata to save the direction world.setBlockMetadataWithNotify(x, y, z, dir, 3); //Or you can save it in a tile entity if you are using one createNewTileEntity(world, world.getBlockMetadata(x, y, z)); } Custom Renderer //Stuff to get the dir int, from the block metadata or the tile or whatever //Check the dir and apply rotations if (dir == 0) { GL11.glRotatef(-180F, 0.0F, 1.0F, 0.0F); } if (dir % 2 != 0) { GL11.glRotatef(dir * (-90F), 0.0F, 1.0F, 0.0F); } if (dir % 2 == 0) { GL11.glRotatef(dir * (-180F), 0.0F, 1.0F, 0.0F); } This probably can be optimized a bit more, but this way its readable This is so commonly asked that it should be stickied somewhere ._.
  9. Call this.mc.getTextureManager().bindTexture(texture); again before drawing the second time and see if it works out. The drawString method rebinds to a different texture, and you are calling it between drawTexturedModalRect calls.
  10. what you are looking for are: - The different EntityAI classes. - the "tasks" and the "targetTasks" in EntityLiving You might have to end up adding your own custom AI by copying the herd AI from the pigman, adapt it for chickens and use an event to add it to them. If you want them to be able to attack you might have to change their Attributes as well to add attack damage, or you might have to make your own custom Entity and replace regular chickens with it. It's kinda complicated stuff for a begginer, and you'll have to learn to do a lot of things in the process.
  11. This is in the property class public static void syncToNear(EntityPlayer player) { if(player.worldObj instanceof WorldServer) { WorldServer world = (WorldServer)player.worldObj; SyncPropertiesPacket.Message msg = new SyncPropertiesPacket.Message(player.getEntityId(), get(player).getData()); world.getEntityTracker().func_151248_b(player, ModNetwork.net.getPacketFrom(msg)); } } And this is in the client side: public void synchronizePlayer(int id, NBTTagCompound properties) { Entity entity = Minecraft.getMinecraft().theWorld.getEntityByID(id); if(entity != null && entity instanceof EntityPlayer) { EntityPlayer player = (EntityPlayer)entity; if(BackpackProperty.get(player) == null) BackpackProperty.register(player); BackpackProperty.get(player).loadNBTData(properties); if(player == Minecraft.getMinecraft().thePlayer) { if (player.openContainer != null && player.openContainer instanceof IWearableContainer) { player.openContainer.detectAndSendChanges(); } } } } Works perfectly. Thanks so much, diesieben, you just saved me like 5 solid hours or more of messing around.
  12. public void func_151248_b(Entity p_151248_1_, Packet p_151248_2_) this expects a packet, and I assume I could use the old packet250custompayload for this. but a little down below there's this: public Set<net.minecraft.entity.player.EntityPlayer> getTrackingPlayers(Entity entity) which appears to return a set of the players tracking an entity. This looks like a better approach, considering I'm using the new networking wrapper thing. I'll test this out and if it doesn't work, packet250 it is (which I don't want to use since I'm sending an NBT and that would be a lot of refactoring)
  13. I get it, thanks diesieben. My only doubt is if the EntityID is the same for the server world and the client world. My guess is yes but I remember seeing somewhere else that there's a persistent ID, and then there's IDs. I'm coding your proposal at the moment to see how it goes anyway.
  14. Hello mates. I'm using IExtendedProperties to save information about a player. I use a custom player renderer to render a model on the player depending on the custom property. Synchronization between the server and the player works correctly, but the problem arises whn I want to render other players: they can't see the model. I realize that each client knows about its personal IExtendedProperties, but do not know about other client's. Any recommendation on an approach that would make all clients in rendering distance know that certain players have the property set? My current approach is sending packets to all players nearby each other every second or so, saving the data in a HashMap<UUID,NBTTagCompound> in the client proxy if the player != Minecraft...thePlayer, and when rendering doing a lookup in said HasMap based on the player's UUID. Is there something I'm missing that could make this easier?
  15. I agree is redundat, except in the rare case when you'd like other mods to notice that you used a hoe, for example. By the looks of it, though, he uses a custom hoe on a custom block, so it doesn't appear to be necessary at all.
  16. Are you actually firing a HoeEvent anywhere? You should fire it in the onItemUse of your custom hoe, unless you are making a call to super, Forge doesn't know that there was an event. Are you doing something with the event result after you fire it?
  17. This might help you, here's an example. Then you can simply iterate and do something to the entities. double posX = player.posX; double posY = player.posY; double posZ = player.posZ; List<EntityItem> groundItems = world.getEntitiesWithinAABB( EntityItem.class, AxisAlignedBB.getBoundingBox(posX, posY, posZ, posX + 1.0D, posY + 1.0D, posZ + 1.0D).expand(4.0D, 4.0D, 4.0D));
  18. Apparently the fact of analyzing (again) the whole deal, made me realize the answer! I'll leave the solution here to help others: When the updateAllSounds method detects a sound that has donePlaying set to true, it does indeed stop the sound, and it also removes the source. HOWEVER, if the repeat variable is set to true, it will add it to the delayedSounds list AFTER it stops it and removes the source. So it will muck up the whole playing lists, making you unable to start or stop the sound again. To avoid this, if your sound is a looping one, you must set the repeat variable to false as well as the donePlaying to true, at the same time. Below is my CopterPackSound class, that works corectly and can be started, stopped and loops as long as the item is in use. Note that it is better in my opinion to override both the fields and all the methods you need to ensure that the ones in your class are the ones actually being called. I know its not THAT necessary in some cases due to inheritance, but I find this approach a "safer" route. public class CopterPackSound extends MovingSound { public EntityPlayer thePlayer; protected boolean repeat = true; protected int repeatDelay = 0; protected float pitch; public CopterPackSound() { super(new ResourceLocation(ModInfo.MOD_ID, "helicopter")); this.repeat = true; this.volume = 0.8f; this.pitch = 1.0F; } public CopterPackSound(EntityPlayer player) { super(new ResourceLocation(ModInfo.MOD_ID, "helicopter")); volume = 0.8f; pitch = 1.0F; thePlayer = player; LogHelper.info("Sound Created"); } public void setDonePlaying() { this.repeat = false; this.donePlaying = true; this.repeatDelay = 0; } @Override public boolean isDonePlaying() { return this.donePlaying; } @Override public void update() { ItemStack copter = Wearing.getWearingCopter(thePlayer); byte status = 0; if(thePlayer == null || thePlayer.worldObj == null) { setDonePlaying(); } if (copter != null&& copter.hasTagCompound() && copter.getTagCompound().hasKey("status")) { status = copter.getTagCompound().getByte("status"); if (status == ItemCopterPack.OFF_MODE) { setDonePlaying(); }else{ if(status == ItemCopterPack.HOVER_MODE) { pitch = (thePlayer.motionY == 0) ? 1.0f : (thePlayer.motionY > 0) ? 1.2f : 0.8f; } else { pitch = (thePlayer.onGround || thePlayer.motionY == 0) ? 0.8f : (thePlayer.isSneaking()) ? 0.8f : (thePlayer.motionY > 0) ? 1.2f : 1.0F; } } }else{ setDonePlaying(); } xPosF = (float)thePlayer.posX; yPosF = (float)thePlayer.posY; zPosF = (float)thePlayer.posZ; } @Override public boolean canRepeat() { return this.repeat; } @Override public float getVolume() { return this.volume; } @Override public float getPitch() { return this.pitch; } @Override public int getRepeatDelay(){ return this.repeatDelay; } @Override public AttenuationType getAttenuationType() { return AttenuationType.LINEAR; }
  19. Hello fellow modders and Forge coders. In trying to implement a looping, moving sound, I came across a seemingly unresolvable problem. If you use a MovingSound to, let's say, make a constant jetpack sound on a player, that moves with it, you're better off using a moving sound, logically, than making very short, continuous calls to world.playsound(); Case example: The sound should start when the player turns the jetpack on and stops when he turns it off, but it should loop as long as the jetpack is working. This can be apparently done by implementing a custom Moving sound, with the "loop" variable set to true, and an onUpdate() method setting the position of the sound to the player. No mystery here. The problem arises when you want to make the sound stop. Let's call setDonePlaying() when the jetpack is off, to indicate the system that the sound should stop. Then we go to the SoundManager class, where all the sounds are processed for playing. In the updateAllSounds method, there is a check for isDonePlaying(), and if it is set to true, there's a call to stopSound(). Making the call to stopSound() does indeed stop it, but for some reason you are not able to start it again, not even creating a new Isound object and telling SoundHandler to play it. The sound manager has two methods for stopping sounds, "stopAllSounds" and "stopSound". updateAllSounds() iterates across multiple lists of sounds: - playingSounds - tickableSounds - delayedSounds and others. updateAllSounds does iterate over all these lists and removes the sound appropiately from each of them, as well as executes paulscode's removeSource(), so I'm at a loss at what could be preventing the sound from being played again. For some reason a reference to the ResouceLocation where the sound file is, stays around somewhere and prevents the sound from being played again, until some time has passed. Any insight on this matter would be very appreciatted.
  20. I've been exploring code for the last 4 hours and I can't find a way to make that work. Also tried the search on the forums but couldn't come up with better keywords, I'm afraid. Is it possible to get the "NORTH; EAST; WEST; UP; DOWN; SOUTH" side of a block corresponding to the player crosshair? I want to call it inside of onItemUse, or onItemUseFirst.
×
×
  • Create New...

Important Information

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