Jump to content

Jetug

Members
  • Posts

    32
  • Joined

  • Last visited

  • Days Won

    1

Jetug last won the day on January 16

Jetug had the most liked content!

Converted

  • Gender
    Male
  • URL
    https://github.com/Jetug

Recent Profile Visitors

79637 profile views

Jetug's Achievements

Tree Puncher

Tree Puncher (2/8)

2

Reputation

  1. I found it. It's the IForgeEntity#getStepHeight()
  2. I have a rideable LivingEntity and when I ride on it near a block it automatically climbs on it. How to disable it? Here is my travel method: @Override public void travel(@NotNull Vec3 travelVector) { if (!isAlive()) return; if (isVehicle() && hasPassenger()) { var entity = getControllingPassenger(); if(entity == null) return; setRotationMatchingPassenger(entity); if (isControlledByLocalInstance()) super.travel(new Vec3(entity.xxa, travelVector.y, entity.zza)); else setDeltaMovement(Vec3.ZERO); } else { super.travel(travelVector); } }
  3. Thanks! It worked
  4. From finishUsingItem() in my item class public ItemStack finishUsingItem(ItemStack stack, Level level, LivingEntity entity) { if (entity instanceof Player player) setAddMaxHealth(player, -10) return super.finishUsingItem(stack, level, entity); } The code works fine only when the value is positive
  5. I'm modifying the player's max health attribute but it only updates when the player gets damage private static void addMaxHealth(Player player, double value) { player.getAttribute(Attributes.MAX_HEALTH) .addPermanentModifier(new AttributeModifier("health", value, AttributeModifier.Operation.ADDITION)); }
  6. Because I am working on a feature related to username and if I could change it testing would be much easier
  7. I tried to write mcUsername=somename in gradle.properties but it didn't work
  8. Turns out it was much easier @OnlyIn(Dist.CLIENT) @SubscribeEvent() public static void onRenderHand(RenderArmEvent event) { if(handRenderer == null) handRenderer = new CustomHandRenderer(); var poseStack = new PoseStack(); poseStack.translate(0.5, -0.5, -0.6); handRenderer.render( null, poseStack, event.getMultiBufferSource(), event.getPackedLight()); event.setCanceled(true); } https://i.imgur.com/tHo5mqo.png
  9. I wrote this code and my hand model renders but doesn't follow camera rotation(https://imgur.com/1pgyxUl). I took the PoseStack installation code from GameRenderer#renderLeve. @OnlyIn(Dist.CLIENT) @SubscribeEvent() public static void onRenderHand(RenderArmEvent event) { if(handRenderer == null) handRenderer = new CustomHandRenderer(); var minecraft = Minecraft.getInstance(); var camera = minecraft.gameRenderer.getMainCamera(); var poseStack = new PoseStack(); poseStack.mulPose(Vector3f.XP.rotationDegrees(camera.getXRot())); poseStack.mulPose(Vector3f.YP.rotationDegrees(camera.getYRot() + 180.0F)); applyItemArmTransform(poseStack, HumanoidArm.RIGHT, 1); handRenderer.render( null, poseStack, event.getMultiBufferSource(), event.getPackedLight()); event.setCanceled(true); } For rendering I use GeckoLib
  10. I want to make a custom first person hand model. Can anyone tell me how can I do this or give me examples of open source mods that have done this
  11. Never heard of mixin before, very cool tool, rewrote everything with mixin and it works. Thanks.
  12. I needed to rewrite the GameRenderer#pick() method so I wrote my own GameRenderer class and set an instance of it to Minecraft#gameRenderer with reflection: @Mod.EventBusSubscriber(modid = Global.MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD, value = Dist.CLIENT) public final class SetupEvents { @SubscribeEvent() public static void onRegisterRenderers(EntityRenderersEvent.RegisterRenderers event){ try { var minecraft = Minecraft.getInstance(); var gameRenderer = new ModGameRenderer(minecraft, minecraft.getResourceManager() ,minecraft.renderBuffers()); Field field = minecraft.getClass().getDeclaredField("gameRenderer"); field.setAccessible(true); field.set(minecraft, gameRenderer); } catch (Exception e) { e.printStackTrace(); } } } And when I run the mod in the IDE my pick() method works but when I build the mod and run it through the minecraft launcher it doesn't. Maybe it's because of the GeckoLib library that I use in my project?
  13. I want to get the skin of a certain player. I tried to get it with AbstractClientPlayer#getSkinTextureLocation but it returns the default Steve or Alex skin and it looks like it only works with offline players
  14. Maybe harder but i already did it :) Anyway thank you, I corrected the method and now it works public static NativeImage getNativeImage(BufferedImage img) { NativeImage nativeImage = new NativeImage(img.getWidth(), img.getHeight(), true); for (int x = 0; x < img.getWidth(); x++) { for (int y = 0; y < img.getHeight(); y++) { int clr = img.getRGB(x, y); int alpha = (clr & 0xff000000) >> 24; int red = (clr & 0x00ff0000) >> 16; int green = (clr & 0x0000ff00) >> 8; int blue = clr & 0x000000ff; int rgb = alpha; rgb = (rgb << 8) + blue; rgb = (rgb << 8) + green; rgb = (rgb << 8) + red; nativeImage.setPixelRGBA(x, y, rgb); } } return nativeImage; }
  15. I decided that it would be easier to do this with the resizing of the player texture and wrote this code while waiting for an answer: @Override public void render(PoseStack matrixStackIn, MultiBufferSource bufferIn, int packedLightIn, PowerArmorEntity entity, float limbSwing, float limbSwingAmount, float parti if(!entity.isInvisible() && entity.isVehicle() && entity.getControllingPassenger() instanceof AbstractClientPlayer clientPlayer ) { var texture = getHeadResourceLocation(clientPlayer, entity); if (texture == null) return; var cameo = RenderType.armorCutoutNoCull(texture); int overlay = OverlayTexture.NO_OVERLAY; matrixStackIn.pushPose(); matrixStackIn.scale(1.0f, 1.0f, 1.0f); matrixStackIn.translate(0.0d, 0.0d, 0.0d); this.getRenderer().render( getEntityModel().getModel(POWER_ARMOR_MODEL_LOCATION), entity, partialTicks, cameo, matrixStackIn, bufferIn, bufferIn.getBuffer(cameo), packedLightIn, overlay, 1f, 1f, 1f, 1f); matrixStackIn.popPose(); } } @Nullable private ResourceLocation getHeadResourceLocation(AbstractClientPlayer clientPlayer, PowerArmorEntity entity) { var tag = clientPlayer.getUUID().toString(); if (playerTextures.containsKey(tag)) { return playerTextures.get(tag); } else { var playerHead = getPlayerHead(clientPlayer); var entityTextureRL = entityRenderer.getTextureLocation(entity); var entityTexture = resourceToBufferedImage(entityTextureRL); if (playerHead == null || entityTexture == null) return null; playerHead = extendImage(playerHead, entityTexture.getWidth(), entityTexture.getHeight()); var nativeImage = getNativeImage(playerHead); var dynamicTexture = new DynamicTexture(nativeImage); var finalTextureLocation = new ResourceLocation(Global.MOD_ID, tag); Minecraft.getInstance().getTextureManager().register(finalTextureLocation, dynamicTexture); playerTextures.put(tag, finalTextureLocation); return finalTextureLocation; } } And it actually worked, but Steve looks like he's turned into a vampire I think the problem is in this method: public static NativeImage getNativeImage(BufferedImage img) { NativeImage nativeImage = new NativeImage(img.getWidth(), img.getHeight(), true); for (int x = 0; x < img.getWidth(); x++) { for (int y = 0; y < img.getHeight(); y++) { var color = img.getRGB(x, y); nativeImage.setPixelRGBA(x, y, color); } } return nativeImage; } Full code: https://github.com/Jetug/PowerArmorMod/blob/1.18/src/main/java/com/jetug/power_armor_mod/client/render/layers/PlayerHeadLayer.java
×
×
  • Create New...

Important Information

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