Jump to content

Tschipp

Forge Modder
  • Posts

    307
  • Joined

  • Last visited

Everything posted by Tschipp

  1. @Animefan8888 It's a placement identifier Yes, I guess that would kinda work, but the glass would then just have the standard transparency that it already has, and it wouldn't be decreased
  2. That's not what I'm trying to do. I'm trying to render a solid block (like planks) slightly transparent, and I also want to render stained glass, just with a bit extra transparency applied to the already existing transparency of the block.
  3. I'm trying to render ghost blocks (partially transparent blocks), but I am having some minor issues. Issue #1: Stained glass is rendered as a plain Color/Solid blocks aren't rendered as transparent: Code: double d0 = player.lastTickPosX + (player.posX - player.lastTickPosX) * event.getPartialTicks(); double d1 = player.lastTickPosY + (player.posY - player.lastTickPosY) * event.getPartialTicks(); double d2 = player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * event.getPartialTicks(); IBlockState stateToRender = LinearHelper.getState(player); Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE); BlockRendererDispatcher renderer = Minecraft.getMinecraft().getBlockRendererDispatcher(); GlStateManager.pushMatrix(); GlStateManager.enableBlend(); GlStateManager.blendFunc(GL11.GL_CONSTANT_ALPHA, GL11.GL_ONE_MINUS_CONSTANT_ALPHA); for (BlockPos toPlace : positions) //positions is just a Collection filled with BlockPos { GlStateManager.pushMatrix(); GlStateManager.translate(-d0, -d1, -d2); GlStateManager.translate(toPlace.getX(), toPlace.getY(), toPlace.getZ()); GlStateManager.rotate(-90, 0f, 1f, 0f); GL14.glBlendColor(1f, 1f, 1f, 0.8f); renderer.renderBlockBrightness(stateToRender, 1f); GlStateManager.popMatrix(); } GlStateManager.disableBlend(); GlStateManager.popMatrix(); I've also tried changing the blend Function to GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); That solved the issue of glass transparency, but it also removed the transparency of other solid blocks: To be honest, I don't exactly understand what the Blend functions do. If someone could enlighten me, I would be very happy. Issue #2: The second issue is probably closely related to the first one. The preview-block (the block that gets rendered next to the cursor) is also rendered as a flat Color. Code: RenderHelper.enableGUIStandardItemLighting(); GlStateManager.pushMatrix(); Minecraft.getMinecraft().getRenderItem().renderItemAndEffectIntoGUI(stack, (int) (res.getScaledWidth() / 2 + (2.3 * res.getScaleFactor())), (int) (res.getScaledHeight() / 2 - (2.4 * res.getScaleFactor()))); GlStateManager.popMatrix(); RenderHelper.disableStandardItemLighting(); Issue #3: At some positions in the world (and always at the same positions), the blockface of a partially transparent block gets rendered. It shouldn't render that blockface, it should behave like glass when it's placed down. The code is the same as for Issue #1. I'm really not sure why it happens, and it always happens at the same spots in the same world. As far as I can tell, nothing is special about these positions, they aren't adjacent to chunkborders or anything.
  4. Hmm... I've done rendering of Entities on the shoulder on Animania before, I also use RenderPlayerEvent... I think I'm just gonna modify that to my needs
  5. I wanted to make a parrot-like entity, so I made it extend EntityShoulderRiding and added the appropriate AI for it. It does work, the entity flys towards the player and then lands on its shoulder, but the entity isn't visible and the console gets spammed with errors. The errors stem from the LayerEntityOnShoulder class, where a check gets made if the entity is a parrot. If it isn't, the code just fails: private LayerEntityOnShoulder.DataHolder renderEntityOnShoulder(EntityPlayer p_192864_1_, @Nullable UUID p_192864_2_, NBTTagCompound p_192864_3_, RenderLivingBase <? extends EntityLivingBase > p_192864_4_, ModelBase p_192864_5_, ResourceLocation p_192864_6_, Class<?> p_192864_7_, float p_192864_8_, float p_192864_9_, float p_192864_10_, float p_192864_11_, float p_192864_12_, float p_192864_13_, float p_192864_14_, boolean p_192864_15_) { if (p_192864_2_ == null || !p_192864_2_.equals(p_192864_3_.getUniqueId("UUID"))) { p_192864_2_ = p_192864_3_.getUniqueId("UUID"); p_192864_7_ = EntityList.getClassFromName(p_192864_3_.getString("id")); if (p_192864_7_ == EntityParrot.class) { p_192864_4_ = new RenderParrot(this.renderManager); p_192864_5_ = new ModelParrot(); p_192864_6_ = RenderParrot.PARROT_TEXTURES[p_192864_3_.getInteger("Variant")]; } } p_192864_4_.bindTexture(p_192864_6_); GlStateManager.pushMatrix(); float f = p_192864_1_.isSneaking() ? -1.3F : -1.5F; float f1 = p_192864_15_ ? 0.4F : -0.4F; GlStateManager.translate(f1, f, 0.0F); if (p_192864_7_ == EntityParrot.class) { p_192864_11_ = 0.0F; } p_192864_5_.setLivingAnimations(p_192864_1_, p_192864_8_, p_192864_9_, p_192864_10_); p_192864_5_.setRotationAngles(p_192864_8_, p_192864_9_, p_192864_11_, p_192864_12_, p_192864_13_, p_192864_14_, p_192864_1_); p_192864_5_.render(p_192864_1_, p_192864_8_, p_192864_9_, p_192864_11_, p_192864_12_, p_192864_13_, p_192864_14_); GlStateManager.popMatrix(); return new LayerEntityOnShoulder.DataHolder(p_192864_2_, p_192864_4_, p_192864_5_, p_192864_6_, p_192864_7_); } Is there something that forge adds that allows me to render my entity on the shoulder? Or do I have to make my own system with own AI?
  6. I'm trying to make a custom bed that allows the player to sleep at any time of the day. I've managed to get through EntityPlayer#isInBed by subscribing to SleepingLocationCheckEvent, but now the player gets ejected out of the bed at else if (this.world.isDaytime()) EntityPlayer#onUpdate: ... if (this.isPlayerSleeping()) { ++this.sleepTimer; if (this.sleepTimer > 100) { this.sleepTimer = 100; } if (!this.world.isRemote) { if (!this.isInBed()) { this.wakeUpPlayer(true, true, false); } else if (this.world.isDaytime()) { this.wakeUpPlayer(false, true, true); } } } else if (this.sleepTimer > 0) { ++this.sleepTimer; if (this.sleepTimer >= 110) { this.sleepTimer = 0; } } ... Any way I can prevent this? Can I subscribe to some event? Or can this not be done without some major rewriting?
  7. Yep! Thanks a lot, this has been giving me a headache for weeks!
  8. I am rendering an IBakedModel during RenderHandEvent. I fetch the model like this: IBakedModel model = Minecraft.getMinecraft().getRenderItem().getItemModelWithOverrides(stack, world, player); I then render it using this method: Minecraft.getMinecraft().getRenderItem().renderItem(stack, model); The IBakedModels that I'm rendering are normal blocks, like sand, grass and stone. This works most of the time, but when certain other mods are installed, one of them being ModularRouters, the block gets rendered as one solid color or invisible. The author of ModularRouters, desht, contacted me and pointed out, that removing one line in his code (marked) fixes the problem: https://github.com/desht/ModularRouters/blob/MC1.12-master/src/main/java/me/desht/modularrouters/client/fx/FXSparkle.java#L61 It seems to have something to do with the texture that is bound. However, I don't think that this is desht's fault, as I have seen this happening in local Lan games as well as in Singleplayer with other mods. What am I missing?
  9. I'm sending a packet to everyone on the server from my Item's onItemUse method. It looks like this: @Override public EnumActionResult onItemUse(EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { ItemStack stack = player.getHeldItem(hand); Block block = world.getBlockState(pos).getBlock(); if (hasEntityData(stack)) { BlockPos finalPos = pos; if (!block.isReplaceable(world, pos)) { finalPos = pos.offset(facing); } Entity entity = getEntity(stack, world); if (entity != null) { if (!world.isRemote) { entity.setPositionAndRotation(finalPos.getX() + 0.5, finalPos.getY(), finalPos.getZ() + 0.5, 180 + player.rotationYawHead, 0.0f); world.spawnEntity(entity); if (entity instanceof EntityLiving) { ((EntityLiving) entity).playLivingSound(); } clearEntityData(stack); player.setHeldItem(hand, ItemStack.EMPTY); } player.getEntityData().removeTag("overrideKey"); Pickup.network.sendToAll(new CarrySlotPacket(9, player.getEntityId())); return EnumActionResult.SUCCESS; } } return EnumActionResult.FAIL; } The packet is not either not sent or recieved correctly, I'm getting this error: [16:17:57] [Client thread/ERROR] [FML]: SimpleChannelHandlerWrapper exception java.lang.NullPointerException at net.minecraftforge.fml.common.network.FMLOutboundHandler$OutboundTarget$5.selectNetworks(FMLOutboundHandler.java:154) ~[FMLOutboundHandler$OutboundTarget$5.class:?] at net.minecraftforge.fml.common.network.FMLOutboundHandler.write(FMLOutboundHandler.java:297) ~[FMLOutboundHandler.class:?] at io.netty.channel.AbstractChannelHandlerContext.invokeWrite(AbstractChannelHandlerContext.java:658) ~[AbstractChannelHandlerContext.class:4.0.23.Final] at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:716) ~[AbstractChannelHandlerContext.class:4.0.23.Final] at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:651) ~[AbstractChannelHandlerContext.class:4.0.23.Final] at io.netty.handler.codec.MessageToMessageEncoder.write(MessageToMessageEncoder.java:112) ~[MessageToMessageEncoder.class:4.0.23.Final] at io.netty.handler.codec.MessageToMessageCodec.write(MessageToMessageCodec.java:116) ~[MessageToMessageCodec.class:4.0.23.Final] at io.netty.channel.AbstractChannelHandlerContext.invokeWrite(AbstractChannelHandlerContext.java:658) ~[AbstractChannelHandlerContext.class:4.0.23.Final] at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:716) ~[AbstractChannelHandlerContext.class:4.0.23.Final] at io.netty.channel.AbstractChannelHandlerContext.writeAndFlush(AbstractChannelHandlerContext.java:706) ~[AbstractChannelHandlerContext.class:4.0.23.Final] at io.netty.channel.AbstractChannelHandlerContext.writeAndFlush(AbstractChannelHandlerContext.java:741) ~[AbstractChannelHandlerContext.class:4.0.23.Final] at io.netty.channel.DefaultChannelPipeline.writeAndFlush(DefaultChannelPipeline.java:895) ~[DefaultChannelPipeline.class:4.0.23.Final] at io.netty.channel.AbstractChannel.writeAndFlush(AbstractChannel.java:240) ~[AbstractChannel.class:4.0.23.Final] at net.minecraftforge.fml.common.network.simpleimpl.SimpleNetworkWrapper.sendToAll(SimpleNetworkWrapper.java:240) [SimpleNetworkWrapper.class:?] at tschipp.carryon.common.item.ItemEntity.onItemUse(ItemEntity.java:116) [ItemEntity.class:?] at net.minecraft.item.ItemStack.onItemUse(ItemStack.java:180) [ItemStack.class:?] at net.minecraft.client.multiplayer.PlayerControllerMP.processRightClickBlock(PlayerControllerMP.java:489) [PlayerControllerMP.class:?] at net.minecraft.client.Minecraft.rightClickMouse(Minecraft.java:1606) [Minecraft.class:?] at net.minecraft.client.Minecraft.processKeyBinds(Minecraft.java:2276) [Minecraft.class:?] at net.minecraft.client.Minecraft.runTickKeyboard(Minecraft.java:2053) [Minecraft.class:?] at net.minecraft.client.Minecraft.runTick(Minecraft.java:1841) [Minecraft.class:?] at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1119) [Minecraft.class:?] at net.minecraft.client.Minecraft.run(Minecraft.java:407) [Minecraft.class:?] at net.minecraft.client.main.Main.main(Main.java:118) [Main.class:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_121] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_121] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_121] at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_121] at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) [launchwrapper-1.12.jar:?] at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.12.jar:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_121] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_121] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_121] at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_121] at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97) [start/:?] at GradleStart.main(GradleStart.java:26) [start/:?] The packet is registered correctly and has also been sent in different places, which worked fine. Does anyone know what's going on here?
  10. The same still happens. I assume you meant I should call this: Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
  11. This piece of code gets the IBakedModel of the held item (in this case sand) IBakedModel model = Minecraft.getMinecraft().getRenderItem().getItemModelWithOverrides(tileItem, world, player); The model gets rendered by this, during RenderPlayerEvent.Post: Minecraft.getMinecraft().getRenderItem().renderItem(tileItem, model); This works on the client itself, but sometimes looks weird on servers: The player that is holding the block sees no issue, whereas the other players can SOMETIMES see this, or nothing, or some garbled pixels... it's really strange. So I'm wondering.. why and how is this happening? Is it possibly a forge bug? Another picture:
  12. Updating to 1.12: I used to have achievements that got triggered when the player fed an item to an animal (custom Animal). I looked through all builtin advancement triggers - is there no item right click or entity right click trigger? I didn't find anything, so I've though about making the trigger impossible, and triggering it via code. Is it possible to trigger advancements via code? If that's also not possible, how do I create my own criterion?
  13. I've been using cofh's RedstoneFlux API and repackaged it in my mods, but in 1.12 the api is distributed separately, in a jar. So my question is, how should I go about updating this? Should I just switch to Forge Energy? Will I lose cross-mod compat if I do that? Or should I just add RF API as a dependency for the mod? That seems bad, because the player will have to download the api separately. So, what are your suggestions?
  14. That's not the problem. The problem is that if I don't remove the TileEntity beforehand, it will drop the contents when setBlockToAir is called. But at the same time, Block#breakBlock doesn't expect the TileEntity at the position to be null, which can cause nullpointers in some cases. I did a workaround, which seemed to work for me. Do you think it's somewhat safe? if (world.getTileEntity(pos) != null) { TileEntity newtile = world.getTileEntity(pos).getClass().newInstance(); world.removeTileEntity(pos); world.setTileEntity(pos, newtile); } world.setBlockToAir(pos);
  15. So what I'm trying to do, is break a block (set it to air, so no drops). If that block also contains a TileEntity, I also want that not to drop its contents. I achieved this by first calling world.removeTileEntity(pos) and then calling world.setBlockToAir(pos) This works, but can cause problems with some TileEntites, especially ones that do some item drop code and don't check if the TileEntity is null. So, what are my alternatives?
  16. You should probably store a value for each texture on the bandit entity, like an integer. You assign it when the entity is first spawned, it can be something like 0 for texture 1 and 1 for texture 2 or whatever you want. Then you can check for that value and determine which texture should be used.
  17. I have an event that checks if a certain key is pressed, an InputEvent (Fires at Keyboart Input and Mouse Input) @SideOnly(Side.CLIENT) @SubscribeEvent public void inputEvent(InputEvent event) { GameSettings settings = Minecraft.getMinecraft().gameSettings; ItemStack stack = Minecraft.getMinecraft().player.getHeldItemMainhand(); if (!stack.isEmpty() && stack.getItem() == RegistrationHandler.itemTile && ItemTile.hasTileData(stack)) { if (settings.keyBindDrop.isPressed()) { System.out.println("Drop!"); } if (settings.keyBindSwapHands.isPressed()) { System.out.println("Swap!"); } if (settings.keyBindPickBlock.isPressed()) { System.out.println("Pick!"); } for (KeyBinding keyBind : settings.keyBindsHotbar) { if (keyBind.isPressed()) { System.out.println("Hotbar!"); } } } } Now, this works for the keyBindDrop, keyBindSwapHands and the keyBindsHotbar, but not for keyBindPickBlock. Why? It seems like keyBindPickBlock.isPressed() is never true...
×
×
  • Create New...

Important Information

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