Jump to content

Nephroid

Members
  • Posts

    91
  • Joined

  • Last visited

Everything posted by Nephroid

  1. Can you post the bindTexture code? The null pointer is likely caused by something in it. Whenever you call someObj.someMethod(), see if someObj is null. That's usually what causes null pointers.
  2. The Teleporter class has a method that places a player in a portal, placePlayerInExistingPortal(), I believe. In that method, you can change where the player should spawn. I don't fully understand the Teleporter class, but I worked around it by storing the player's position as an extended property and returning the player to that position when he returns to the overworld. (Though setting up extended properties is a bit cumbersome is you don't already have something set up.)
  3. The vanilla door code might be a starting place. I would just use 2 blocks that respond to each other.
  4. Is it possible to have separate instances of a dimension for different players? I mainly want some temporary dimensions that should only contain one player at a time. Also, is it possible to restrict block placement in a dimension? Thanks in advance, Nephroid
  5. An approach to this would be using different blend modes. If you want to get into OpenGL, you might want to look into shaders, but that might be a bit complex. --- Alternatively, you can try GL11.glColor3b() and GL11.glBlendFunc(). The first takes the rgb components of the color (use bitwise operators to get the bits from the integer). The second takes some constants from GL11. You would use a base texture that's grayscale and draw that normally. Then call the color and blendfunc methods. Then draw a second texture that's all white above the first. The color method should change the all white texture to your color, and the blendfunc will blend that in with the gray texture. (You'll probably have to play around with the blendfunc method a bit before getting something you like.) You'll need to override some methods too (whenever icon rendering takes place). This is a good reference. --- I don't have any code examples at the moment, but using blend modes is how I would approach this. -Nephroid Also, the color is an integer, meaning it's 4 bytes. Each byte is 2 hexadecimal digits. The color is usually 0xAARRGGBB, where AA is the alpha (transparency) component. You normally don't need to worry about this, but it's nice to keep in mind.
  6. I believe damage is positive. Try using damageItem(1, ...) instead.
  7. Ah, I gave the teleporter serverPlayer.getServerForPlayer(), but that's the WorldServer that the player was previously in. I ended up adding the platform generation to the onBlockActivated() method after transferring the player to the new dimension: @Override public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float x2, float y2, float z2) { if (player instanceof EntityPlayerMP && !world.isRemote) { // Might be a bit redundant if (player.dimension == 0) { EntityPlayerMP serverPlayer = (EntityPlayerMP)player; serverPlayer.mcServer.getConfigurationManager().transferPlayerToDimension(serverPlayer, CUSTOM_DIM_ID, new CustomTeleporter()); World customDimension = serverPlayer.getServerForPlayer(); // Is now the WorldServer for the custom dimension int pX = MathHelper.floor_double(serverPlayer.posX); int pY = MathHelper.floor_double(serverPlayer.posY); int pZ = MathHelper.floor_double(serverPlayer.posZ); customDimension.setBlock(pX, pY-1, pZ, Blocks.glowstone); } else { // ... } } } Which works. Thanks! Nephroid
  8. In 1.7.2, I create custom tool tiers like this: ToolMaterial t = EnumHelper.addToolMaterial("material_name", harvestLevel, maxUses, efficiency, damage, enchantability); To create the tool: CustomAxe axe = new CustomAxe(t); There might be a similar method in 1.7.10.
  9. Hi, I'm trying to create a spawning platform when players spawn in a custom dimension, so that they don't fall from a high area. Travelling to and from the custom dimension and the overworld works, but the platform is being created in the overworld instead of the custom dimension. The relevant code for the portal block (transfers player properly when right-clicked): @Override public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float x2, float y2, float z2) { if (player instanceof EntityPlayerMP && !world.isRemote) { // Might be a bit redundant if (player.dimension == 0) { EntityPlayerMP serverPlayer = (EntityPlayerMP)player; serverPlayer.mcServer.getConfigurationManager().transferPlayerToDimension(serverPlayer, CUSTOM_DIM_ID, new CustomTeleporter()); } else { // ... } } } The CustomTeleporter class extends Teleporter, and I overrode 3 methods: @Override public void placeInPortal(Entity entity, double dX, double dY, double dZ, float f) { if (entity instanceof EntityPlayer) { makePortal(entity); placeInExistingPortal(entity, dX, dY, dZ, f); } } @Override public boolean placeInExistingPortal(Entity entity, double dX, double dY, double dZ, float f) { if (entity instanceof EntityPlayerMP) { EntityPlayerMP player = (EntityPlayerMP)entity; player.setPosition(dX, dY, dZ); return true; } return false; } @Override public boolean makePortal(Entity entity) { if (entity instanceof EntityPlayerMP) { EntityPlayerMP player = (EntityPlayerMP)entity; System.out.println("making portal in dimension "+ player.dimension); // This prints out the ID of the custom dimension int pX = MathHelper.floor_double(player.posX); int pY = MathHelper.floor_double(player.posY); int pZ = MathHelper.floor_double(player.posZ); this.worldServerInstance.setBlock(pX, pY-1, pZ, Blocks.glowstone); // This sets the block in the overworld (or previous dimension) instead of the current one return true; } return false; } The Teleporter class seems to be the class that creates the nether portal when you travel to the nether, so I'm not sure why it's changing the blocks in the overworld instead of the custom dimension. Is there any explanation of what the Teleporter class does, or any explanation of how custom dimensions work? (The tutorials that I've found show examples of code, but they don't really have much explanation.)
  10. I tried to use events, here's my source code. I'm probably not doing something right, since the block I click on is never equal to water. (I'm pretty sure that == can check block equality, since only 1 of each Block is ever instantiated.) Also, how do I check the type of block with useBlock? I don't know what to do with it; it's a Result object that can be DENY, DEFAULT, or ALLOW, which doesn't seem like too much to work with. (The above code is inside the onItemUse method, if that's relevant.)
  11. I'm trying to create a bucket-like tool that fills up if you right click on water. This line of code is being weird. MovingObjectPosition movingObjectPosition = this.getMovingObjectPositionFromPlayer(world, player, isFull); It only creates a MovingObjectPosition if there is a solid block in range. When there's a water block in range, but not a solid block, it gives me null. When there are both water blocks and solid blocks in range, and the solid blocks are behind the water blocks, the MovingObjectPosition contains information about the solid block instead of the water block. It seems to ignore all the water blocks, which is weird because the bucket works properly.
×
×
  • Create New...

Important Information

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