Jump to content

Recommended Posts

Posted

I added a layer whis is changing the player's skin but the first person hand is still with the original skin. How do I change it as well? Thanks.

Spoiler

public class CustomLayer extends LayerRenderer<AbstractClientPlayerEntity, PlayerModel<AbstractClientPlayerEntity>>
{
    private static ResourceLocation skin;

    public CustomLayer(PlayerRenderer entityRendererIn)
    {
        super(entityRendererIn);
    }

    @Override
    public void render(MatrixStack matrixStackIn, IRenderTypeBuffer bufferIn, int packedLightIn, AbstractClientPlayerEntity entitylivingbaseIn, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch)
    {
        skin = Registry.location("textures/entity/custom.png");
        if (Main.isCustom())
        {
            renderCutoutModel(this.getEntityModel(), skin, matrixStackIn, bufferIn, packedLightIn, entitylivingbaseIn, 1, 1, 1);
        }
    }
}

 

 

Posted
4 hours ago, ChampionAsh5357 said:

You would need to handle some rendering logic via RenderHandEvent. The layers are only applied in third person as you can never see the player in first.

Oh thanks. I did my own rendering but the line mc.getTextureManager().bindTexture(Registry.location("textures/entity/custom.png")) doesn't seem to work.

Posted
40 minutes ago, ChampionAsh5357 said:

Where and in what context? Also what is Registry#location?

Spoiler

@SubscribeEvent
public void onHandRender(RenderHandEvent event)
{
	mc.getTextureManager().bindTexture(Registry.location("textures/entity/custom.png"));
}

//Registry#location:
  
public static ResourceLocation location(String name)
{
	return new ResourceLocation(Main.MOD_ID, name);
}

 

I also tried copying FirstPersonRenderer class:

Spoiler

public class HandRender
{
    private static final Minecraft mc = Minecraft.getInstance();

    public static void renderArmFirstPerson(MatrixStack matrixStackIn, IRenderTypeBuffer bufferIn, int combinedLightIn, float equippedProgress, float swingProgress, ResourceLocation texture)
    {
        boolean flag = mc.gameSettings.mainHand != HandSide.LEFT;
        float f = flag ? 1.0F : -1.0F;
        float f1 = MathHelper.sqrt(swingProgress);
        float f2 = -0.3F * MathHelper.sin(f1 * (float)Math.PI);
        float f3 = 0.4F * MathHelper.sin(f1 * ((float)Math.PI * 2F));
        float f4 = -0.4F * MathHelper.sin(swingProgress * (float)Math.PI);
        matrixStackIn.translate((double)(f * (f2 + 0.64000005F)), (double)(f3 + -0.6F + equippedProgress * -0.6F), (double)(f4 + -0.71999997F));
        matrixStackIn.rotate(Vector3f.YP.rotationDegrees(f * 45.0F));
        float f5 = MathHelper.sin(swingProgress * swingProgress * (float)Math.PI);
        float f6 = MathHelper.sin(f1 * (float)Math.PI);
        matrixStackIn.rotate(Vector3f.YP.rotationDegrees(f * f6 * 70.0F));
        matrixStackIn.rotate(Vector3f.ZP.rotationDegrees(f * f5 * -20.0F));
        AbstractClientPlayerEntity abstractclientplayerentity = mc.player;
        mc.getTextureManager().bindTexture(texture);
        matrixStackIn.translate((double)(f * -1.0F), (double)3.6F, 3.5D);
        matrixStackIn.rotate(Vector3f.ZP.rotationDegrees(f * 120.0F));
        matrixStackIn.rotate(Vector3f.XP.rotationDegrees(200.0F));
        matrixStackIn.rotate(Vector3f.YP.rotationDegrees(f * -135.0F));
        matrixStackIn.translate((double)(f * 5.6F), 0.0D, 0.0D);
        PlayerRenderer playerrenderer = (PlayerRenderer)mc.getRenderManager().<AbstractClientPlayerEntity>getRenderer(abstractclientplayerentity);
        if (flag) {
            playerrenderer.renderRightArm(matrixStackIn, bufferIn, combinedLightIn, abstractclientplayerentity);
        } else {
            playerrenderer.renderLeftArm(matrixStackIn, bufferIn, combinedLightIn, abstractclientplayerentity);
        }
    }
}

//in the event:

@SubscribeEvent
public void onHandRender(RenderHandEvent event)
{
	event.setCanceled(true);
	HandRender.renderArmFirstPerson(event.getMatrixStack(), event.getBuffers(), event.getLight(), event.getEquipProgress(),
    	event.getSwingProgress(), Registry.location("textures/entity/custom.png"));
}

 

 

Posted
8 hours ago, ChampionAsh5357 said:

Probably because entity textures are bound using a batched rendering system and not on the fly. You need to handle the rendering of the model yourself, not delegate it to the PlayerRenderer.

You mean the player's model? Where do I do that?

Posted
2 hours ago, ChampionAsh5357 said:

Inside RenderHandEvent. You just need to do all the logic instead of parts of it.

Sorry for bothering you but I researched for hours and I still doesn't understand what is that logic.

Posted
1 hour ago, ChampionAsh5357 said:

Look at PlayerRenderer#render*Arm, copy the logic, change the texture being passed into the RenderType.

Ok I get it now but how do I get the player's model?

Posted
31 minutes ago, ChampionAsh5357 said:

PlayerRenderer#getModel?

RenderHandEvent doesn't have a PlayerRenderer and mc.getRenderManager().getRenderer(mc.player) doesn't have the getModel.

Posted
Just now, ChampionAsh5357 said:

It's probably called #getEntityModel then, that's the mcp mapping name.

Yeah thats what I meant.

Posted
47 minutes ago, ChampionAsh5357 said:

PlayerRenderer#getModel?

What am I doing wrong?

Spoiler

public class HandRender extends LivingRenderer<AbstractClientPlayerEntity, PlayerModel<AbstractClientPlayerEntity>>
{
    public HandRender(EntityRendererManager rendererManager, PlayerModel<AbstractClientPlayerEntity> entityModelIn, float shadowSizeIn)
    {
        super(rendererManager, entityModelIn, shadowSizeIn);
    }

    public void renderRightArm(MatrixStack matrixStackIn, IRenderTypeBuffer bufferIn, int combinedLightIn, AbstractClientPlayerEntity playerIn) {
        this.renderItem(matrixStackIn, bufferIn, combinedLightIn, playerIn, (this.entityModel).bipedRightArm, (this.entityModel).bipedRightArmwear);
    }

    public void renderLeftArm(MatrixStack matrixStackIn, IRenderTypeBuffer bufferIn, int combinedLightIn, AbstractClientPlayerEntity playerIn) {
        this.renderItem(matrixStackIn, bufferIn, combinedLightIn, playerIn, (this.entityModel).bipedLeftArm, (this.entityModel).bipedLeftArmwear);
    }

    private void renderItem(MatrixStack matrixStackIn, IRenderTypeBuffer bufferIn, int combinedLightIn, AbstractClientPlayerEntity playerIn, ModelRenderer rendererArmIn, ModelRenderer rendererArmwearIn) {
        PlayerModel<AbstractClientPlayerEntity> playermodel = this.getEntityModel();
        this.setModelVisibilities(playerIn);
        playermodel.swingProgress = 0.0F;
        playermodel.isSneak = false;
        playermodel.swimAnimation = 0.0F;
        playermodel.setRotationAngles(playerIn, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F);
        rendererArmIn.rotateAngleX = 0.0F;
        rendererArmIn.render(matrixStackIn, bufferIn.getBuffer(RenderType.getEntitySolid(getEntityTexture(playerIn))), combinedLightIn, OverlayTexture.NO_OVERLAY);
        rendererArmwearIn.rotateAngleX = 0.0F;
        rendererArmwearIn.render(matrixStackIn, bufferIn.getBuffer(RenderType.getEntityTranslucent(getEntityTexture(playerIn))), combinedLightIn, OverlayTexture.NO_OVERLAY);
    }

    private void setModelVisibilities(AbstractClientPlayerEntity clientPlayer) {
        PlayerModel<AbstractClientPlayerEntity> playermodel = this.getEntityModel();
        if (clientPlayer.isSpectator()) {
            playermodel.setVisible(false);
            playermodel.bipedHead.showModel = true;
            playermodel.bipedHeadwear.showModel = true;
        } else {
            playermodel.setVisible(true);
            playermodel.bipedHeadwear.showModel = clientPlayer.isWearing(PlayerModelPart.HAT);
            playermodel.bipedBodyWear.showModel = clientPlayer.isWearing(PlayerModelPart.JACKET);
            playermodel.bipedLeftLegwear.showModel = clientPlayer.isWearing(PlayerModelPart.LEFT_PANTS_LEG);
            playermodel.bipedRightLegwear.showModel = clientPlayer.isWearing(PlayerModelPart.RIGHT_PANTS_LEG);
            playermodel.bipedLeftArmwear.showModel = clientPlayer.isWearing(PlayerModelPart.LEFT_SLEEVE);
            playermodel.bipedRightArmwear.showModel = clientPlayer.isWearing(PlayerModelPart.RIGHT_SLEEVE);
            playermodel.isSneak = clientPlayer.isCrouching();
            BipedModel.ArmPose bipedmodel$armpose = func_241741_a_(clientPlayer, Hand.MAIN_HAND);
            BipedModel.ArmPose bipedmodel$armpose1 = func_241741_a_(clientPlayer, Hand.OFF_HAND);
            if (bipedmodel$armpose.func_241657_a_()) {
                bipedmodel$armpose1 = clientPlayer.getHeldItemOffhand().isEmpty() ? BipedModel.ArmPose.EMPTY : BipedModel.ArmPose.ITEM;
            }

            if (clientPlayer.getPrimaryHand() == HandSide.RIGHT) {
                playermodel.rightArmPose = bipedmodel$armpose;
                playermodel.leftArmPose = bipedmodel$armpose1;
            } else {
                playermodel.rightArmPose = bipedmodel$armpose1;
                playermodel.leftArmPose = bipedmodel$armpose;
            }
        }
    }

    private static BipedModel.ArmPose func_241741_a_(AbstractClientPlayerEntity p_241741_0_, Hand p_241741_1_) {
        ItemStack itemstack = p_241741_0_.getHeldItem(p_241741_1_);
        if (itemstack.isEmpty()) {
            return BipedModel.ArmPose.EMPTY;
        } else {
            if (p_241741_0_.getActiveHand() == p_241741_1_ && p_241741_0_.getItemInUseCount() > 0) {
                UseAction useaction = itemstack.getUseAction();
                if (useaction == UseAction.BLOCK) {
                    return BipedModel.ArmPose.BLOCK;
                }

                if (useaction == UseAction.BOW) {
                    return BipedModel.ArmPose.BOW_AND_ARROW;
                }

                if (useaction == UseAction.SPEAR) {
                    return BipedModel.ArmPose.THROW_SPEAR;
                }

                if (useaction == UseAction.CROSSBOW && p_241741_1_ == p_241741_0_.getActiveHand()) {
                    return BipedModel.ArmPose.CROSSBOW_CHARGE;
                }
            } else if (!p_241741_0_.isSwingInProgress && itemstack.getItem() == Items.CROSSBOW && CrossbowItem.isCharged(itemstack)) {
                return BipedModel.ArmPose.CROSSBOW_HOLD;
            }

            return BipedModel.ArmPose.ITEM;
        }
    }

    @Override
    public ResourceLocation getEntityTexture(AbstractClientPlayerEntity entity)
    {
        return Registry.location("textures/entity/custom.png");
    }
}

 

Spoiler

@SubscribeEvent
public void onHandRender(RenderHandEvent event)
{
	PlayerRenderer playerRenderer = (PlayerRenderer) mc.getRenderManager().getRenderer(mc.player);
	HandRender handRender = new HandRender(mc.getRenderManager(), playerRenderer.getEntityModel(), 0);
	if (mc.gameSettings.mainHand == HandSide.RIGHT)
	{
		handRender.renderRightArm(event.getMatrixStack(), event.getBuffers(), event.getLight(), mc.player);
	}
	else
	{
		handRender.renderLeftArm(event.getMatrixStack(), event.getBuffers(), event.getLight(), mc.player);
	}
}

 

 

Posted
On 5/20/2021 at 10:33 PM, ozi said:

What am I doing wrong?

  Reveal hidden contents


public class HandRender extends LivingRenderer<AbstractClientPlayerEntity, PlayerModel<AbstractClientPlayerEntity>>
{
    public HandRender(EntityRendererManager rendererManager, PlayerModel<AbstractClientPlayerEntity> entityModelIn, float shadowSizeIn)
    {
        super(rendererManager, entityModelIn, shadowSizeIn);
    }

    public void renderRightArm(MatrixStack matrixStackIn, IRenderTypeBuffer bufferIn, int combinedLightIn, AbstractClientPlayerEntity playerIn) {
        this.renderItem(matrixStackIn, bufferIn, combinedLightIn, playerIn, (this.entityModel).bipedRightArm, (this.entityModel).bipedRightArmwear);
    }

    public void renderLeftArm(MatrixStack matrixStackIn, IRenderTypeBuffer bufferIn, int combinedLightIn, AbstractClientPlayerEntity playerIn) {
        this.renderItem(matrixStackIn, bufferIn, combinedLightIn, playerIn, (this.entityModel).bipedLeftArm, (this.entityModel).bipedLeftArmwear);
    }

    private void renderItem(MatrixStack matrixStackIn, IRenderTypeBuffer bufferIn, int combinedLightIn, AbstractClientPlayerEntity playerIn, ModelRenderer rendererArmIn, ModelRenderer rendererArmwearIn) {
        PlayerModel<AbstractClientPlayerEntity> playermodel = this.getEntityModel();
        this.setModelVisibilities(playerIn);
        playermodel.swingProgress = 0.0F;
        playermodel.isSneak = false;
        playermodel.swimAnimation = 0.0F;
        playermodel.setRotationAngles(playerIn, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F);
        rendererArmIn.rotateAngleX = 0.0F;
        rendererArmIn.render(matrixStackIn, bufferIn.getBuffer(RenderType.getEntitySolid(getEntityTexture(playerIn))), combinedLightIn, OverlayTexture.NO_OVERLAY);
        rendererArmwearIn.rotateAngleX = 0.0F;
        rendererArmwearIn.render(matrixStackIn, bufferIn.getBuffer(RenderType.getEntityTranslucent(getEntityTexture(playerIn))), combinedLightIn, OverlayTexture.NO_OVERLAY);
    }

    private void setModelVisibilities(AbstractClientPlayerEntity clientPlayer) {
        PlayerModel<AbstractClientPlayerEntity> playermodel = this.getEntityModel();
        if (clientPlayer.isSpectator()) {
            playermodel.setVisible(false);
            playermodel.bipedHead.showModel = true;
            playermodel.bipedHeadwear.showModel = true;
        } else {
            playermodel.setVisible(true);
            playermodel.bipedHeadwear.showModel = clientPlayer.isWearing(PlayerModelPart.HAT);
            playermodel.bipedBodyWear.showModel = clientPlayer.isWearing(PlayerModelPart.JACKET);
            playermodel.bipedLeftLegwear.showModel = clientPlayer.isWearing(PlayerModelPart.LEFT_PANTS_LEG);
            playermodel.bipedRightLegwear.showModel = clientPlayer.isWearing(PlayerModelPart.RIGHT_PANTS_LEG);
            playermodel.bipedLeftArmwear.showModel = clientPlayer.isWearing(PlayerModelPart.LEFT_SLEEVE);
            playermodel.bipedRightArmwear.showModel = clientPlayer.isWearing(PlayerModelPart.RIGHT_SLEEVE);
            playermodel.isSneak = clientPlayer.isCrouching();
            BipedModel.ArmPose bipedmodel$armpose = func_241741_a_(clientPlayer, Hand.MAIN_HAND);
            BipedModel.ArmPose bipedmodel$armpose1 = func_241741_a_(clientPlayer, Hand.OFF_HAND);
            if (bipedmodel$armpose.func_241657_a_()) {
                bipedmodel$armpose1 = clientPlayer.getHeldItemOffhand().isEmpty() ? BipedModel.ArmPose.EMPTY : BipedModel.ArmPose.ITEM;
            }

            if (clientPlayer.getPrimaryHand() == HandSide.RIGHT) {
                playermodel.rightArmPose = bipedmodel$armpose;
                playermodel.leftArmPose = bipedmodel$armpose1;
            } else {
                playermodel.rightArmPose = bipedmodel$armpose1;
                playermodel.leftArmPose = bipedmodel$armpose;
            }
        }
    }

    private static BipedModel.ArmPose func_241741_a_(AbstractClientPlayerEntity p_241741_0_, Hand p_241741_1_) {
        ItemStack itemstack = p_241741_0_.getHeldItem(p_241741_1_);
        if (itemstack.isEmpty()) {
            return BipedModel.ArmPose.EMPTY;
        } else {
            if (p_241741_0_.getActiveHand() == p_241741_1_ && p_241741_0_.getItemInUseCount() > 0) {
                UseAction useaction = itemstack.getUseAction();
                if (useaction == UseAction.BLOCK) {
                    return BipedModel.ArmPose.BLOCK;
                }

                if (useaction == UseAction.BOW) {
                    return BipedModel.ArmPose.BOW_AND_ARROW;
                }

                if (useaction == UseAction.SPEAR) {
                    return BipedModel.ArmPose.THROW_SPEAR;
                }

                if (useaction == UseAction.CROSSBOW && p_241741_1_ == p_241741_0_.getActiveHand()) {
                    return BipedModel.ArmPose.CROSSBOW_CHARGE;
                }
            } else if (!p_241741_0_.isSwingInProgress && itemstack.getItem() == Items.CROSSBOW && CrossbowItem.isCharged(itemstack)) {
                return BipedModel.ArmPose.CROSSBOW_HOLD;
            }

            return BipedModel.ArmPose.ITEM;
        }
    }

    @Override
    public ResourceLocation getEntityTexture(AbstractClientPlayerEntity entity)
    {
        return Registry.location("textures/entity/custom.png");
    }
}

 

  Reveal hidden contents


@SubscribeEvent
public void onHandRender(RenderHandEvent event)
{
	PlayerRenderer playerRenderer = (PlayerRenderer) mc.getRenderManager().getRenderer(mc.player);
	HandRender handRender = new HandRender(mc.getRenderManager(), playerRenderer.getEntityModel(), 0);
	if (mc.gameSettings.mainHand == HandSide.RIGHT)
	{
		handRender.renderRightArm(event.getMatrixStack(), event.getBuffers(), event.getLight(), mc.player);
	}
	else
	{
		handRender.renderLeftArm(event.getMatrixStack(), event.getBuffers(), event.getLight(), mc.player);
	}
}

 

 

I realized I had to use the previous rendering as well so it works now.

  • 2 years later...
Posted (edited)
On 5/21/2021 at 4:17 PM, ozi said:

I realized I had to use the previous rendering as well so it works now.

would you upload the full code here or to github? I have been having problems with this

Edited by ElTotisPro50

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • I've been trying to find a solution for this for the past few days and cant seem to find it anywhere.   What i want to do is basically set my player's head pitch without the server noticing it. Basically client-side change.   Is there a way to do this? With mixins or anything else?   Thanks in advance.
    • Did you ever find a solution to this
    • I have followed a tutorial on how to generate ores for my mod though the data files have not been generated despite me running data in my IDE.  I have looked over and compared my code multiple times and the only differences are either with the IDs or with unnecessary code because of what my mod is (The mod is for the End so I don't need the Overworld or Nether ores), my folders are all in the right structure and no warnings are present when ran. I have been trying to figure this out for a few days now so help would be much appreciated.  The tutorial I was following.  My code -  public class ModBiomeModifiers { public static final ResourceKey<BiomeModifier> ADD_GAZITE_ORE = registerKey("add_gazite_ore"); public static final ResourceKey<BiomeModifier> TRANSCENDINE_GAZITE_ORE = registerKey("add_transcendine_ore"); public static void bootstrap(BootstrapContext<BiomeModifier> context) { var placedFeature = context.lookup(Registries.PLACED_FEATURE); var biomes = context.lookup(Registries.BIOME); context.register(ADD_GAZITE_ORE, new ForgeBiomeModifiers.AddFeaturesBiomeModifier( biomes.getOrThrow(BiomeTags.IS_END), HolderSet.direct(placedFeature.getOrThrow(ModPlacedFeatures.GAZITE_ORE_PLACED_KEY)), GenerationStep.Decoration.UNDERGROUND_ORES)); context.register(TRANSCENDINE_GAZITE_ORE, new ForgeBiomeModifiers.AddFeaturesBiomeModifier( biomes.getOrThrow(BiomeTags.IS_END), HolderSet.direct(placedFeature.getOrThrow(ModPlacedFeatures.TRANSCENDINE_ORE_PLACED_KEY)), GenerationStep.Decoration.UNDERGROUND_ORES)); } private static ResourceKey<BiomeModifier> registerKey(String name) { return ResourceKey.create(ForgeRegistries.Keys.BIOME_MODIFIERS, ResourceLocation.fromNamespaceAndPath(EchoingEnd.MOD_ID, name)); } } The tutorial's code -  public class ModBiomeModifiers { public static final ResourceKey<BiomeModifier> ADD_ALEXANDRITE_ORE = registerKey("add_alexandrite_ore"); public static final ResourceKey<BiomeModifier> ADD_NETHER_ALEXANDRITE_ORE = registerKey("add_nether_alexandrite_ore"); public static final ResourceKey<BiomeModifier> ADD_END_ALEXANDRITE_ORE = registerKey("add_end_alexandrite_ore"); public static void bootstrap(BootstrapContext<BiomeModifier> context) { var placedFeature = context.lookup(Registries.PLACED_FEATURE); var biomes = context.lookup(Registries.BIOME); context.register(ADD_ALEXANDRITE_ORE, new ForgeBiomeModifiers.AddFeaturesBiomeModifier( biomes.getOrThrow(BiomeTags.IS_OVERWORLD), HolderSet.direct(placedFeature.getOrThrow(ModPlacedFeatures.ALEXANDRITE_ORE_PLACED_KEY)), GenerationStep.Decoration.UNDERGROUND_ORES)); // Individual Biomes // context.register(ADD_ALEXANDRITE_ORE, new ForgeBiomeModifiers.AddFeaturesBiomeModifier( // HolderSet.direct(biomes.getOrThrow(Biomes.PLAINS), biomes.getOrThrow(Biomes.BAMBOO_JUNGLE)), // HolderSet.direct(placedFeature.getOrThrow(ModPlacedFeatures.ALEXANDRITE_ORE_PLACED_KEY)), // GenerationStep.Decoration.UNDERGROUND_ORES)); context.register(ADD_NETHER_ALEXANDRITE_ORE, new ForgeBiomeModifiers.AddFeaturesBiomeModifier( biomes.getOrThrow(BiomeTags.IS_NETHER), HolderSet.direct(placedFeature.getOrThrow(ModPlacedFeatures.NETHER_ALEXANDRITE_ORE_PLACED_KEY)), GenerationStep.Decoration.UNDERGROUND_ORES)); context.register(ADD_END_ALEXANDRITE_ORE, new ForgeBiomeModifiers.AddFeaturesBiomeModifier( biomes.getOrThrow(BiomeTags.IS_END), HolderSet.direct(placedFeature.getOrThrow(ModPlacedFeatures.END_ALEXANDRITE_ORE_PLACED_KEY)), GenerationStep.Decoration.UNDERGROUND_ORES)); } private static ResourceKey<BiomeModifier> registerKey(String name) { return ResourceKey.create(ForgeRegistries.Keys.BIOME_MODIFIERS, ResourceLocation.fromNamespaceAndPath(TutorialMod.MOD_ID, name)); } }   ModConfiguredFeatures:   My code -  public class ModConfiguredFeatures { public static final ResourceKey<ConfiguredFeature<?, ?>> GAZITE_ORE_KEY = registerKey("gazite_ore"); public static final ResourceKey<ConfiguredFeature<?, ?>> TRANSCENDINE_ORE_KEY = registerKey("transcendine_ore"); public static void bootstrap(BootstrapContext<ConfiguredFeature<?, ?>> context) { RuleTest endReplaceables = new BlockMatchTest(Blocks.END_STONE); register(context, GAZITE_ORE_KEY, Feature.ORE, new OreConfiguration(endReplaceables, ModBlocks.GAZITE_ORE.get().defaultBlockState(), 4)); register(context, TRANSCENDINE_ORE_KEY, Feature.ORE, new OreConfiguration(endReplaceables, ModBlocks.TRANSCENDINE_ORE.get().defaultBlockState(), 8)); List<OreConfiguration.TargetBlockState> EndOres = List.of( OreConfiguration.target(endReplaceables, ModBlocks.GAZITE_ORE.get().defaultBlockState()), OreConfiguration.target(endReplaceables, ModBlocks.TRANSCENDINE_ORE.get().defaultBlockState())); } public static ResourceKey<ConfiguredFeature<?, ?>> registerKey(String name) { return ResourceKey.create(Registries.CONFIGURED_FEATURE, ResourceLocation.fromNamespaceAndPath(EchoingEnd.MOD_ID, name)); } private static <FC extends FeatureConfiguration, F extends Feature<FC>> void register(BootstrapContext<ConfiguredFeature<?, ?>> context, ResourceKey<ConfiguredFeature<?, ?>> key, F feature, FC configuration) { context.register(key, new ConfiguredFeature<>(feature, configuration)); } }   The tutorial's code - public class ModConfiguredFeatures { public static final ResourceKey<ConfiguredFeature<?, ?>> OVERWORLD_ALEXANDRITE_ORE_KEY = registerKey("alexandrite_ore"); public static final ResourceKey<ConfiguredFeature<?, ?>> NETHER_ALEXANDRITE_ORE_KEY = registerKey("nether_alexandrite_ore"); public static final ResourceKey<ConfiguredFeature<?, ?>> END_ALEXANDRITE_ORE_KEY = registerKey("end_alexandrite_ore"); public static void bootstrap(BootstrapContext<ConfiguredFeature<?, ?>> context) { RuleTest stoneReplaceables = new TagMatchTest(BlockTags.STONE_ORE_REPLACEABLES); RuleTest deepslateReplaceables = new TagMatchTest(BlockTags.DEEPSLATE_ORE_REPLACEABLES); RuleTest netherrackReplaceables = new BlockMatchTest(Blocks.NETHERRACK); RuleTest endReplaceables = new BlockMatchTest(Blocks.END_STONE); List<OreConfiguration.TargetBlockState> overworldAlexandriteOres = List.of( OreConfiguration.target(stoneReplaceables, ModBlocks.ALEXANDRITE_ORE.get().defaultBlockState()), OreConfiguration.target(deepslateReplaceables, ModBlocks.ALEXANDRITE_DEEPSLATE_ORE.get().defaultBlockState())); register(context, OVERWORLD_ALEXANDRITE_ORE_KEY, Feature.ORE, new OreConfiguration(overworldAlexandriteOres, 9)); register(context, NETHER_ALEXANDRITE_ORE_KEY, Feature.ORE, new OreConfiguration(netherrackReplaceables, ModBlocks.ALEXANDRITE_NETHER_ORE.get().defaultBlockState(), 9)); register(context, END_ALEXANDRITE_ORE_KEY, Feature.ORE, new OreConfiguration(endReplaceables, ModBlocks.ALEXANDRITE_END_ORE.get().defaultBlockState(), 9)); } public static ResourceKey<ConfiguredFeature<?, ?>> registerKey(String name) { return ResourceKey.create(Registries.CONFIGURED_FEATURE, ResourceLocation.fromNamespaceAndPath(TutorialMod.MOD_ID, name)); } private static <FC extends FeatureConfiguration, F extends Feature<FC>> void register(BootstrapContext<ConfiguredFeature<?, ?>> context, ResourceKey<ConfiguredFeature<?, ?>> key, F feature, FC configuration) { context.register(key, new ConfiguredFeature<>(feature, configuration)); } }   ModPlacedFeatures:   My code - public class ModPlacedFeatures { public static final ResourceKey<PlacedFeature> GAZITE_ORE_PLACED_KEY = registerKey("gazite_ore_placed"); public static final ResourceKey<PlacedFeature> TRANSCENDINE_ORE_PLACED_KEY = registerKey("transcendine_ore_placed"); public static void bootstrap(BootstrapContext<PlacedFeature> context) { var configuredFeatures = context.lookup(Registries.CONFIGURED_FEATURE); register(context, GAZITE_ORE_PLACED_KEY, configuredFeatures.getOrThrow(ModConfiguredFeatures.GAZITE_ORE_KEY), ModOrePlacement.commonOrePlacement(9, HeightRangePlacement.uniform(VerticalAnchor.absolute(-64), VerticalAnchor.absolute(71)))); register(context, TRANSCENDINE_ORE_PLACED_KEY, configuredFeatures.getOrThrow(ModConfiguredFeatures.GAZITE_ORE_KEY), ModOrePlacement.rareOrePlacement(6, HeightRangePlacement.uniform(VerticalAnchor.absolute(-32), VerticalAnchor.absolute(71)))); } private static ResourceKey<PlacedFeature> registerKey(String name) { return ResourceKey.create(Registries.PLACED_FEATURE, ResourceLocation.fromNamespaceAndPath(EchoingEnd.MOD_ID, name)); } private static void register(BootstrapContext<PlacedFeature> context, ResourceKey<PlacedFeature> key, Holder<ConfiguredFeature<?, ?>> configuration, List<PlacementModifier> modifiers) { context.register(key, new PlacedFeature(configuration, List.copyOf(modifiers))); } }   the tutorial's code -  public class ModPlacedFeatures { public static final ResourceKey<PlacedFeature> ALEXANDRITE_ORE_PLACED_KEY = registerKey("alexandrite_ore_placed"); public static final ResourceKey<PlacedFeature> NETHER_ALEXANDRITE_ORE_PLACED_KEY = registerKey("nether_alexandrite_ore_placed"); public static final ResourceKey<PlacedFeature> END_ALEXANDRITE_ORE_PLACED_KEY = registerKey("end_alexandrite_ore_placed"); public static void bootstrap(BootstrapContext<PlacedFeature> context) { var configuredFeatures = context.lookup(Registries.CONFIGURED_FEATURE); register(context, ALEXANDRITE_ORE_PLACED_KEY, configuredFeatures.getOrThrow(ModConfiguredFeatures.OVERWORLD_ALEXANDRITE_ORE_KEY), ModOrePlacement.commonOrePlacement(12, HeightRangePlacement.uniform(VerticalAnchor.absolute(-64), VerticalAnchor.absolute(80)))); register(context, NETHER_ALEXANDRITE_ORE_PLACED_KEY, configuredFeatures.getOrThrow(ModConfiguredFeatures.NETHER_ALEXANDRITE_ORE_KEY), ModOrePlacement.commonOrePlacement(12, HeightRangePlacement.uniform(VerticalAnchor.absolute(-64), VerticalAnchor.absolute(80)))); register(context, END_ALEXANDRITE_ORE_PLACED_KEY, configuredFeatures.getOrThrow(ModConfiguredFeatures.END_ALEXANDRITE_ORE_KEY), ModOrePlacement.commonOrePlacement(12, HeightRangePlacement.uniform(VerticalAnchor.absolute(-64), VerticalAnchor.absolute(80)))); } private static ResourceKey<PlacedFeature> registerKey(String name) { return ResourceKey.create(Registries.PLACED_FEATURE, ResourceLocation.fromNamespaceAndPath(TutorialMod.MOD_ID, name)); } private static void register(BootstrapContext<PlacedFeature> context, ResourceKey<PlacedFeature> key, Holder<ConfiguredFeature<?, ?>> configuration, List<PlacementModifier> modifiers) { context.register(key, new PlacedFeature(configuration, List.copyOf(modifiers))); } }   ModOrePlacement:   My code -  public class ModOrePlacement { public static List<PlacementModifier> orePlacement(PlacementModifier pCountPlacement, PlacementModifier pHeightRange) { return List.of(pCountPlacement, InSquarePlacement.spread(), pHeightRange, BiomeFilter.biome()); } public static List<PlacementModifier> commonOrePlacement(int pCount, PlacementModifier pHeightRange) { return orePlacement(CountPlacement.of(pCount), pHeightRange); } public static List<PlacementModifier> rareOrePlacement(int pChance, PlacementModifier pHeightRange) { return orePlacement(RarityFilter.onAverageOnceEvery(pChance), pHeightRange); } }   The tutorial's code -  public class ModOrePlacement { public static List<PlacementModifier> orePlacement(PlacementModifier pCountPlacement, PlacementModifier pHeightRange) { return List.of(pCountPlacement, InSquarePlacement.spread(), pHeightRange, BiomeFilter.biome()); } public static List<PlacementModifier> commonOrePlacement(int pCount, PlacementModifier pHeightRange) { return orePlacement(CountPlacement.of(pCount), pHeightRange); } public static List<PlacementModifier> rareOrePlacement(int pChance, PlacementModifier pHeightRange) { return orePlacement(RarityFilter.onAverageOnceEvery(pChance), pHeightRange); } }  
    • I'm creating a modpack, and i just discovered that if i try to connect to a server it gives the error: Internal Exception: io.netty.handler.codec.DecoderException: java.lang.negativearraysizeexception -1   The client log:  
    • You just need to run the updated installer like if you were installing a new server. You can overwrite an existing install with a new version.
  • Topics

×
×
  • Create New...

Important Information

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