Jump to content

Ferrettomato

Members
  • Posts

    65
  • Joined

  • Last visited

Everything posted by Ferrettomato

  1. If it's a delay you want, thread.sleep() definitely won't work as intended, as the post above says. The proper method would depend on what's playing the sounds; if it's an item, consider saving and adding to the countdown in its NBT data; if it's a tile entity, just create an integer in the tile entity's class and add to it in update(); if it's the player itself (or another entity), you might want to look into capabilities.
  2. Thanks a bunch! There is some weirdness with translucent tiles, but disabling glDepthMask more or less did exactly what I wanted.
  3. I'm making a custom particle that is partially semi-transparent. I want the alpha of the particles to combine (so that two low-alpha parts appear high-alpha when overlapping), instead of hiding the particles behind them. The particles do this, but only when the player is facing in the direction the particle is traveling. How can I get the particles to overlap regardless of the player's looking direction? My particle's render function: @Override public void renderParticle(VertexBuffer worldRendererIn, Entity entityIn, float partialTicks, float rotationX, float rotationZ, float rotationYZ, float rotationXY, float rotationXZ) { // this.theRenderEngine.bindTexture(rLocPortal); // super.renderParticle(worldRendererIn, entityIn, partialTicks, rotationX, rotationZ, rotationYZ, rotationXY, rotationXZ); // int i = 1;//(int)(((float)this.life + partialTicks) * 15.0F / (float)this.lifeTime); // if (i <= 15) // { GlStateManager.enableAlpha(); GL11.glEnable(GL11.GL_BLEND); this.theRenderEngine.bindTexture(rLoc); float f = /*(float)(i % 4) /*/ (0.0f); float f1 = 1;//f + 0.24975F; float f2 = /*float)(i / 4) /*/ (0.0f); float f3 = 1;//f2 + 0.24975F; float f4 = 0.3F; float f5 = (float)(this.prevPosX + (this.posX - this.prevPosX) * (double)partialTicks - interpPosX); float f6 = (float)(this.prevPosY + (this.posY - this.prevPosY) * (double)partialTicks - interpPosY); float f7 = (float)(this.prevPosZ + (this.posZ - this.prevPosZ) * (double)partialTicks - interpPosZ); GlStateManager.color(0.0F, 0.0F, 0.0F, 1.0F); this.particleAlpha = 1F; this.particleRed = 1F; this.particleBlue = 1F; this.particleGreen = 1F; GlStateManager.disableLighting(); RenderHelper.disableStandardItemLighting(); worldRendererIn.begin(7, VERTEX_FORMAT); worldRendererIn.pos((double)(f5 - rotationX * f4 - rotationXY * f4), (double)(f6 - rotationZ * f4), (double)(f7 - rotationYZ * f4 - rotationXZ * f4)).tex((double)f1, (double)f3).color(this.particleRed, this.particleGreen, this.particleBlue, this.particleAlpha).lightmap(0, 240).normal(0.0F, 1.0F, 0.0F).endVertex(); worldRendererIn.pos((double)(f5 - rotationX * f4 + rotationXY * f4), (double)(f6 + rotationZ * f4), (double)(f7 - rotationYZ * f4 + rotationXZ * f4)).tex((double)f1, (double)f2).color(this.particleRed, this.particleGreen, this.particleBlue, this.particleAlpha).lightmap(0, 240).normal(0.0F, 1.0F, 0.0F).endVertex(); worldRendererIn.pos((double)(f5 + rotationX * f4 + rotationXY * f4), (double)(f6 + rotationZ * f4), (double)(f7 + rotationYZ * f4 + rotationXZ * f4)).tex((double)f, (double)f2).color(this.particleRed, this.particleGreen, this.particleBlue, this.particleAlpha).lightmap(0, 240).normal(0.0F, 1.0F, 0.0F).endVertex(); worldRendererIn.pos((double)(f5 + rotationX * f4 - rotationXY * f4), (double)(f6 - rotationZ * f4), (double)(f7 + rotationYZ * f4 - rotationXZ * f4)).tex((double)f, (double)f3).color(this.particleRed, this.particleGreen, this.particleBlue, this.particleAlpha).lightmap(0, 240).normal(0.0F, 1.0F, 0.0F).endVertex(); Tessellator.getInstance().draw(); GlStateManager.enableLighting(); GL11.glDisable(GL11.GL_BLEND); // } } Apologies if I'm using strange terminology. I'm new to rendering and such.
  4. If you need another example, the visible-source Wizardry mod has an easy-to-understand implementation of capabilities. I used it to figure out capabilities myself.
  5. I'm trying to hide (vanilla) mobs from players under certain conditions. Canceling RenderLivingEvent.Pre works fine for hiding the model itself, but their shadows are still visible. Is there any way to hide them client-side?
  6. Having a 20% chance of spreading every 5 ticks seems to work well enough. It actually makes the movement feel more natural. Thanks.
  7. I'm trying to make a grey goo-esque block that eats through plants. It works pretty well so far, but the massive amount of updates that happen every tick when it spreads to a thick forest cripples my FPS. How could I reduce this lag? I've tried disabling the particles, but that doesn't seem to help. TileEntity class: public class TileEntityLocust extends TileEntity implements ITickable { private int counter = 0; private int food = 6; private IBlockState state; @Override public void update() { Random rand = new Random(); counter++; state = worldObj.getBlockState(pos); if(counter >= 5 && !worldObj.isRemote) { for(int i = 0; i < 6; i++) { BlockPos target = pos.offset(EnumFacing.getFront(i)); int newFood = food - 3; boolean didSpread = false; Block block = worldObj.getBlockState(target).getBlock(); Material mat = block.getMaterial(worldObj.getBlockState(target)); if(mat.equals(Material.LEAVES) || mat.equals(Material.PLANTS) || mat.equals(Material.VINE)) { newFood = food + 1; worldObj.destroyBlock(target, !(block instanceof BlockCrops)); worldObj.setBlockState(target, state); didSpread = true; } else if(worldObj.getBlockState(target).getBlock().equals(Blocks.AIR) && newFood >= 0) { worldObj.setBlockState(target, state); didSpread = true; } if(didSpread) { NBTTagCompound tag = worldObj.getTileEntity(target).writeToNBT(new NBTTagCompound()); tag.setInteger("counter", 0); tag.setInteger("food", newFood); worldObj.getTileEntity(target).readFromNBT(tag); } } worldObj.setBlockToAir(pos); } worldObj.spawnParticle(EnumParticleTypes.SWEEP_ATTACK, (double)((float)pos.getX() + rand.nextFloat()), (double)((float)pos.getY() + rand.nextFloat()), (double)((float)pos.getZ() + rand.nextFloat()), (rand.nextDouble() - 0.5) / 5, (rand.nextDouble() - 0.5) / 5, (rand.nextDouble() - 0.5) / 5, new int[0]); } @Override public void readFromNBT(NBTTagCompound tag) { super.readFromNBT(tag); counter = tag.getInteger("counter"); food = tag.getInteger("food"); } @Override public NBTTagCompound writeToNBT(NBTTagCompound tag) { tag.setInteger("counter", counter); tag.setInteger("food", food); return super.writeToNBT(tag); } @Override public void onDataPacket(NetworkManager net, SPacketUpdateTileEntity packet) { this.readFromNBT(packet.getNbtCompound()); } }
  8. It just applies a potion effect. I tried only doing that if worldObj.isRemote, but the effect isn't visible.
  9. Is there any way to render the spectral arrow's "Glowing" effect on a mob so that it's only visible on a certain player's client?
  10. I added that to the end of the file (since you didn't specify a location), but it's just replaced the unintelligible character with a '?' in a white square.
  11. I've been using the section sign (§) to make my item tooltips a bit more colorful. I've been doing this using Item#addInformation. The formatting works perfectly in the development environment, but whenever I build the mod and use it in the actual game, it bugs out and seems to replace all the section signs with another unintelligible symbol, resulting in no formatting taking place. What's wrong?
  12. Is there any way to prevent the player from emitting particles when they sprint/swim/fall/etc.? (when they've equipped a certain item.) I'm trying to make the player completely undetectable, and this is the last step.
  13. Thanks! The problem was that I forgot to cast event.entityLiving to a more specific type; it's rather misleading when it actually gives you an EntityLivingBase.
  14. I've already tried setting its target to null in the event, but the field is final, and the entity's saved target is private. I already have the item canceling damage, but that's not the point.
  15. I'm trying to make an armor item that, when worn, causes all mobs to ignore (not target) the player. I've tried removing EntityAITarget/EntityAINearestAttackableTarget, but I keep getting ConcurrentModificationExceptions. How would I go about doing this properly?
  16. Thanks. Apparently, due to the unusual way that the sprint modifier is applied, it doesn't look like I can apply modifiers in this fashion.
  17. Okay, on further inspection, it looks like I might be able to fix it if I can find the UUID for sprinting's AttributeModifier. Where can I find it? Does it even exist?
  18. I'm trying to give the player an AttributeModifier when they sprint, then remove it when they stop, but the way EntityPlayer#isSprinting works makes the game constantly add and remove the modifier, as if isSprinting changes every tick. Is there any way around this?
  19. I'm trying (and failing) to get a Vec3 that's pointed towards an entity from another entity's perspective, without bringing its look vec in to consideration. This is probably really simple, but I can't figure it out. How?
  20. I'm trying to make use BlockEvent.BreakEvent to allow the player to chop down trees that are multiple blocks wide all at once, but all kinds of things are going wrong. It counts all blocks as wood, even if they're not, and it always thinks that positions have already been used. (so, basically, all the breaks are being tripped every time.) I honestly don't know why this is happening, can anyone enlighten me? Notes: * I've tried using Block#isWood, it doesn't help. * I've also tried comparing the individual co-ordinates in the BlockPoses instead of .equals'ing them, it doesn't help. Code: @SubscribeEvent public void treecapitate(BlockEvent.BreakEvent event) { if(event.state.getBlock().isWood(event.world, event.pos)) { chopTree(event.world, event.pos, new ArrayList<BlockPos>(128)); } } public void chopTree(World world, BlockPos pos, List<BlockPos> done) { done.add(pos); for(int i = 2; i <= 5; i++) { BlockPos target = pos.offset(EnumFacing.getFront(i)); System.out.println(target.toString()); if(world.getBlockState(target).getBlock().equals(Blocks.log)); { System.out.println("Found wood!"); boolean stop = false; for(BlockPos donepos : done) { System.out.println(donepos.toString()); if(donepos.equals(target)) { stop = true; break; } } if(stop = false) { chopTree(world, target, done); } else System.out.println("Been there, done that!"); } } while(world.getBlockState(pos.up()).getBlock().isWood(world, pos.up())) { world.destroyBlock(pos.up(), true); pos = pos.up(); } } Console output when the player harvests the northwest corner of a 2x2 tree: Note: The actual donepos should have been 2180/65/-1499. BlockPos{x=2180, y=65, z=-1501} Found wood! BlockPos{x=2180, y=65, z=-1500} Been there, done that! BlockPos{x=2180, y=65, z=-1499} Found wood! BlockPos{x=2180, y=65, z=-1500} Been there, done that! BlockPos{x=2179, y=65, z=-1500} Found wood! BlockPos{x=2180, y=65, z=-1500} Been there, done that! BlockPos{x=2181, y=65, z=-1500} Found wood! BlockPos{x=2180, y=65, z=-1500} Been there, done that!
  21. I'm trying to have an armor item modify the player's fortune and looting levels in HarvestDropsEvent and LivingDropsEvent respectively, but the required fields are final. Is there any other way to change it?
  22. Hang on... Relogging is making the durability go up by exactly 131072 points each time, and relogging with the game-increased durability doesn't revert anything. The mask has a total of 167992 durability. Could the high maximum durability be causing problems? To clarify, its durability is that high because it allows for roughly 1 day of fast-forwarding followed by roughly 1 week of recharging.
  23. I've tried that, nothing. Here's the relevant code, I've probably done something wrong there. onArmorTick method: public void onArmorTick(World world, EntityPlayer player, ItemStack itemStack) { if(KeyBindings.ability.isKeyDown()) { if(itemStack.getItemDamage() + 350 <= itemStack.getMaxDamage()) { world.setWorldTime(world.getWorldTime() + 50); PacketHandler.INSTANCE.sendToServer(new ItemDamageMessage(350)); System.out.println(world.isRemote); } else if(itemStack.getItemDamage() > itemStack.getMaxDamage()) itemStack.setItemDamage(itemStack.getMaxDamage()); } } ItemDamageMessage: package com.ferret.myfirstmod.handlers; import io.netty.buffer.ByteBuf; import net.minecraftforge.fml.common.network.simpleimpl.IMessage; public class ItemDamageMessage implements IMessage { public ItemDamageMessage(){} public int toSend; public ItemDamageMessage(int toSend) { this.toSend = toSend; } @Override public void toBytes(ByteBuf buf) { buf.writeInt(toSend); } @Override public void fromBytes(ByteBuf buf) { toSend = buf.readInt(); } } ItemDamageMessageHandler: package com.ferret.myfirstmod.handlers; import java.util.Random; import java.util.concurrent.Callable; import net.minecraft.client.Minecraft; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.init.Items; import net.minecraft.item.ItemStack; import net.minecraftforge.fml.common.network.simpleimpl.IMessage; import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler; import net.minecraftforge.fml.common.network.simpleimpl.MessageContext; public class ItemDamageMessageHandler implements IMessageHandler<ItemDamageMessage, IMessage> { @Override public IMessage onMessage(ItemDamageMessage message, MessageContext ctx) { EntityPlayerMP serverPlayer = ctx.getServerHandler().playerEntity; // The value that was sent int amount = message.toSend; serverPlayer.getServerForPlayer().addScheduledTask(new ItemDamageRunnable(serverPlayer, amount)); System.out.println("Packet received!"); // No response packet return null; } } ItemDamageRunnable: package com.ferret.myfirstmod.handlers; import net.minecraft.entity.player.EntityPlayerMP; public class ItemDamageRunnable implements Runnable { EntityPlayerMP player; int amount; public ItemDamageRunnable(EntityPlayerMP player, int amount) { this.player = player; this.amount = amount; } @Override public void run() { if(player.getCurrentArmor(3) != null) player.getCurrentArmor(3).setItemDamage(player.getCurrentArmor(3).getItemDamage() + amount); } } I know that there's nothing wrong with the packet registration because I have a working packet that was copied from this. This performs identically to the client-only code, for some reason.
  24. This code is going to be the end of me. I've tried everything I can think of - sides, packets, breaks, you name it - and I can't get this code to work. I'm trying to damage an armor item when a key binding is pressed, utilizing the armor tick, and everything points to this code being run on both the client and the server. Despite that, relogging consistently reverts the item's durability to either full or nearly full after it's been lowered to any given durability by the key press. Please, for my sanity's sake, what's wrong? *braces for obvious realization* public void onArmorTick(World world, EntityPlayer player, ItemStack itemStack) { if(KeyBindings.ability.isKeyDown()) { if(itemStack.getItemDamage() + 350 <= itemStack.getMaxDamage()) { world.setWorldTime(world.getWorldTime() + 50); itemStack.setItemDamage(itemStack.getItemDamage() + 350); System.out.println(world.isRemote); } else if(itemStack.getItemDamage() > itemStack.getMaxDamage()) itemStack.setItemDamage(itemStack.getMaxDamage()); } }
×
×
  • Create New...

Important Information

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