Jump to content

Spring

Members
  • Posts

    90
  • Joined

  • Last visited

Converted

  • Gender
    Male
  • Location
    China

Recent Profile Visitors

6760 profile views

Spring's Achievements

Stone Miner

Stone Miner (3/8)

0

Reputation

  1. Maybe I didn't express my problem well. But now it has been solved. This line of code is compiled incorrectly. But I did。 public class AddItemTagModifier extends LootModifier { public static final Codec<CompoundTag> TAG_CODEC = Codec.PASSTHROUGH.comapFlatMap((convert) -> { Tag tag = convert.convert(NbtOps.INSTANCE).getValue(); String replace = tag.toString().replace("'", ""); CompoundTag compoundtag = null; try { compoundtag = TagParser.parseTag(replace); } catch (CommandSyntaxException e) { e.printStackTrace(); } return DataResult.success(compoundtag); }, (value) -> new Dynamic<>(NbtOps.INSTANCE, value)); private final Item item; private final CompoundTag compoundTag; public static final Supplier<Codec<AddItemTagModifier>> CODEC = Suppliers.memoize(() -> RecordCodecBuilder.create(inst -> codecStart(inst) .and(ForgeRegistries.ITEMS.getCodec().fieldOf("item").forGetter(m -> m.item)) .and(TAG_CODEC.fieldOf("nbt").forGetter(m -> m.compoundTag)) .apply(inst, AddItemTagModifier::new))); protected AddItemTagModifier(LootItemCondition[] conditionsIn, Item item, CompoundTag compoundTag) { super(conditionsIn); this.item = item; this.compoundTag = compoundTag; } @Override protected @NotNull ObjectArrayList<ItemStack> doApply(ObjectArrayList<ItemStack> generatedLoot, LootContext context) { if (context.getRandom().nextFloat() >= 0.4f) { ItemStack out = new ItemStack(item); if (compoundTag != null) { out.setTag(compoundTag); } generatedLoot.add(out); } return generatedLoot; } @Override public Codec<? extends IGlobalLootModifier> codec() { return CODEC.get(); } It works very well !
  2. public class AddItemModifier extends LootModifier { private final Item item; private final CompoundTag compoundTag; public static final Supplier<Codec<AddItemModifier>> CODEC = Suppliers.memoize(() -> RecordCodecBuilder.create(inst -> codecStart(inst) .and(ForgeRegistries.ITEMS.getCodec().fieldOf("item").forGetter(m -> m.item)) //I didn't find anything about CompoundTag in ForgeRegistries? ForgeRegistries.BIOMES be replaced with? .and(ForgeRegistries.BIOMES.getCodec().fieldOf("nbt").forGetter(m -> m.compoundTag)) .apply(inst, AddItemModifier::new))); protected AddItemModifier(LootItemCondition[] conditionsIn, Item item, CompoundTag compoundTag) { super(conditionsIn); this.item = item; this.compoundTag = compoundTag; } @Override protected @NotNull ObjectArrayList<ItemStack> doApply(ObjectArrayList<ItemStack> generatedLoot, LootContext context) { if (context.getRandom().nextFloat() >= 0.4f) { ItemStack out = new ItemStack(item); if (compoundTag != null) { out.setTag(compoundTag); } generatedLoot.add(new ItemStack(item)); } return generatedLoot; } @Override public Codec<? extends IGlobalLootModifier> codec() { return CODEC.get(); } } loot_modifiers folder { "type": "chinacraft:add_item", "conditions": [ { "condition": "forge:loot_table_id", "loot_table_id": "minecraft:chests/nether_bridge" } ], "item": "patchouli:guide_book", "nbt": "{\"patchouli:book\":\"chinacraft:mencius\"}" } thank you !
  3. How do I overwrite Entity # changeDimension? I want to remove this. unRide(); method
  4. There is only one world available variable, how to find the biome in the world?
  5. solved: event.getGeneration().addFeature(GenerationStage.Decoration.VEGETAL_DECORATION, ModConfiguredFeatures.LIGHTNING_BAMBOO_SAPLING);
  6. like this: Entity entity = event.getEntity(); if (entity.isAlive() && entity instanceof ZombieEntity) { ZombieEntity zombie = (ZombieEntity) entity; // TODO ... event.setCanceled(true); } Cancel zombie spawn
  7. i use: public static void generatePlant(final BiomeLoadingEvent event) { if (event.getName() != null) { IForgeRegistry<Biome> biomes = ForgeRegistries.BIOMES; for (Biome biome : biomes) { if (biome == biomes.getValue(new ResourceLocation("bamboo_jungle"))) { BiomeGenerationSettings.Builder builder = new BiomeGenerationSettings.Builder() .surfaceBuilder(ConfiguredSurfaceBuilders.GRASS); builder.addFeature(GenerationStage.Decoration.VEGETAL_DECORATION, ModConfiguredFeatures.LIGHTNING_BAMBOO_SAPLING); builder.addFeature(GenerationStage.Decoration.VEGETAL_DECORATION, Features.BAMBOO_VEGETATION); } } } } But he didn't work
  8. I want to generate some plants in the bamboo biome, but bamboo does not seem to be a biome? If I want to generate custom plants in the bamboo forest, what should I do, can this be achieved? Or another way. Delete the bamboo biome and generate it by me I found the registration bamboo biome in the BiomeRegistry class. What should I do next, any suggestions?
  9. I want to do certain things when the weather changes, such as generating some plants. Is there such an event? I didn't find it. If not, is there a recommended way to implement it? thanks
  10. block bench: my entity model,export use java model private final ModelRenderer renderer; public SkyLanternModel() { texWidth = 16; texHeight = 16; renderer = new ModelRenderer(this); renderer.setPos(0.0F, 18.0F, 0.0F); renderer.texOffs(3, 3).addBox(-5.0F, -8.5F, -5.0F, 10.0F, 0.0F, 10.0F, 0.0F, false); renderer.texOffs(0, 25).addBox(-5.5F, -8.0F, -5.5F, 11.0F, 0.0F, 11.0F, 0.0F, false); renderer.texOffs(0, 0).addBox(-6.0F, -7.5F, -6.0F, 12.0F, 13.0F, 12.0F, 0.0F, false); } @Override public void setupAnim(Entity entity, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch) { } @Override public void renderToBuffer(MatrixStack matrixStack, IVertexBuilder buffer, int packedLight, int packedOverlay, float red, float green, float blue, float alpha) { renderer.render(matrixStack, buffer, packedLight, packedOverlay); } public void setRotationAngle(ModelRenderer modelRenderer, float x, float y, float z) { modelRenderer.xRot = x; modelRenderer.yRot = y; modelRenderer.zRot = z; } There is a problem with his rendering, how to make it work
  11. You are right, he works now
  12. java.lang.NullPointerException: Cannot invoke "net.minecraft.client.renderer.entity.EntityRenderer.shouldRender(net.minecraft.entity.Entity, net.minecraft.client.renderer.culling.ClippingHelper, double, double, double)" because "entityrenderer" is null at net.minecraft.client.renderer.entity.EntityRendererManager.shouldRender(EntityRendererManager.java:238) ~[forge-1.16.5-36.2.2_mapped_official_1.16.5-recomp.jar:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A} at net.minecraft.client.renderer.WorldRenderer.renderLevel(WorldRenderer.java:987) ~[forge-1.16.5-36.2.2_mapped_official_1.16.5-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A} at net.minecraft.client.renderer.GameRenderer.renderLevel(GameRenderer.java:608) ~[forge-1.16.5-36.2.2_mapped_official_1.16.5-recomp.jar:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A} at net.minecraft.client.renderer.GameRenderer.render(GameRenderer.java:425) ~[forge-1.16.5-36.2.2_mapped_official_1.16.5-recomp.jar:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A} at net.minecraft.client.Minecraft.runTick(Minecraft.java:976) ~[forge-1.16.5-36.2.2_mapped_official_1.16.5-recomp.jar:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A} at net.minecraft.client.Minecraft.run(Minecraft.java:607) ~[forge-1.16.5-36.2.2_mapped_official_1.16.5-recomp.jar:?] {re:classloading,pl:accesstransformer:B,pl:runtimedistcleaner:A} at net.minecraft.client.main.Main.main(Main.java:184) ~[forge-1.16.5-36.2.2_mapped_official_1.16.5-recomp.jar:?] {re:classloading,pl:runtimedistcleaner:A} at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?] {} at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) ~[?:?] {} at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?] {} at java.lang.reflect.Method.invoke(Method.java:568) ~[?:?] {} at net.minecraftforge.userdev.FMLUserdevClientLaunchProvider.lambda$launchService$0(FMLUserdevClientLaunchProvider.java:52) ~[forge-1.16.5-36.2.2_mapped_official_1.16.5-recomp.jar:?] {} at cpw.mods.modlauncher.LaunchServiceHandlerDecorator.launch(LaunchServiceHandlerDecorator.java:37) [modlauncher-8.0.9.jar:?] {} at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:54) [modlauncher-8.0.9.jar:?] {} at cpw.mods.modlauncher.LaunchServiceHandler.launch(LaunchServiceHandler.java:72) [modlauncher-8.0.9.jar:?] {} at cpw.mods.modlauncher.Launcher.run(Launcher.java:82) [modlauncher-8.0.9.jar:?] {} at cpw.mods.modlauncher.Launcher.main(Launcher.java:66) [modlauncher-8.0.9.jar:?] {} at net.minecraftforge.userdev.LaunchTesting.main(LaunchTesting.java:108) [forge-1.16.5-36.2.2_mapped_official_1.16.5-recomp.jar:?] {} He broke down
  13. you forge version?Detailed version like this: 1.16.5-36.2.2
×
×
  • Create New...

Important Information

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