• Recently Browsing

    No registered users viewing this page.

  • Posts

    • Would it be necessary to create a structure? I'll certainly look into how structure generation works, however my goal is to simply create a lake in the desert with vegetation (grass, flowers, and trees) spawning around it on the grass.  Here's what I have so far, I generate a lake of water with dirt and grass surrounding it and then I set the chunk's biome to my custom Oasis biome. I was hoping that by doing that my tree features would just generate, but unfortunately that's not the case. At least it causes the Grass to be green though, which was the main point of the biome.    package killerjdog51.biomeEnhancementsMod.world.gen.feature; import java.util.Random; import java.util.Set; import java.util.function.Function; import com.mojang.datafixers.Dynamic; import killerjdog51.biomeEnhancementsMod.init.WorldGeneration; import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; import net.minecraft.block.material.Material; import net.minecraft.tags.BlockTags; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.ChunkPos; import net.minecraft.util.math.MutableBoundingBox; import net.minecraft.world.IWorld; import net.minecraft.world.LightType; import net.minecraft.world.biome.Biome; import net.minecraft.world.biome.Biomes; import net.minecraft.world.chunk.ChunkStatus; import net.minecraft.world.gen.ChunkGenerator; import net.minecraft.world.gen.GenerationSettings; import net.minecraft.world.gen.IWorldGenerationReader; import net.minecraft.world.gen.feature.Feature; import net.minecraft.world.gen.feature.NoFeatureConfig; public class OasisFeature extends Feature<NoFeatureConfig> { private static final BlockState AIR = Blocks.AIR.getDefaultState(); private static final BlockState WATER = Blocks.WATER.getDefaultState(); private static final BlockState GRASS = Blocks.GRASS_BLOCK.getDefaultState(); private static final BlockState DIRT = Blocks.Dirt.getDefaultState(); private Static final BlockState SAND = Blocks.Sand.getDefaultState(); private int size; public OasisFeature(Function<Dynamic<?>, ? extends NoFeatureConfig> configFactoryIn) { super(configFactoryIn); } @Override public boolean place(IWorld worldIn, ChunkGenerator<? extends GenerationSettings> generator, Random rand, BlockPos pos, NoFeatureConfig config) { int x = pos.getX(); int z = pos.getZ(); size = 1 + rand.nextInt(3); while(pos.getY() > 65 && worldIn.isAirBlock(pos)) { pos = pos.down(); } while(!(worldIn.getLightFor(LightType.SKY, pos) > 0)) { pos = pos.up(); } if (pos.getY() <= 65) { return false; } else { ChunkPos chunkpos = new ChunkPos(pos); if (!worldIn.getChunk(chunkpos.x, chunkpos.z, ChunkStatus.STRUCTURE_REFERENCES).getStructureReferences(Feature.VILLAGE.getStructureName()).isEmpty()) { return false; } for (int xPos = -(11*size); xPos <= (12*size); ++xPos) { for (int zPos = -(11*size); zPos <= (12*size); ++zPos) { for (int yPos = -(8*size); yPos <0; ++yPos) { if (xPos * xPos + zPos * zPos >= (11*(size*size)) && !worldIn.getBlockState(pos.add(xPos, yPos, zPos)).isSolid()) { return false; } } } } Layer(worldIn, pos, (11*size), SAND); Layer(worldIn, pos, (10*size), GRASS); for (int depth = 1; depth <= (4*size); depth++) { Layer(worldIn, pos.down(depth), (10*size), DIRT); } for (int depth = 0; depth < (3*size); depth++) { Layer(worldIn, pos.down(depth), ((8-depth)*size), WATER); } for (int air = 1; air <= 4; air++) { Layer(worldIn, pos.up(air), (10*size), AIR); } return true; } } private void Layer(IWorld worldIn, BlockPos layerCenter, int width, BlockState state) { int max = width * width; for (int x = -width; x <= width; ++x) { for (int z = -width; z <= width; ++z) { if (x * x + z * z <= max) { BlockPos blockpos = layerCenter.add(x, 0, z); worldIn.setBlockState(blockpos, state, 2); worldIn.getChunk(blockpos).getBiomes()[(blockpos.getX() & 15) << 4 | (blockpos.getZ() & 15)] = WorldGeneration.OASIS; } } } } }   public class WorldFeatures { public static AbstractTreeFeature<NoFeatureConfig> PALM_TREE = new PalmTreeFeature(NoFeatureConfig::deserialize); public static Feature<NoFeatureConfig> OASIS = new OasisFeature(NoFeatureConfig::deserialize); }   I want to trigger the palm tree feature to generate after I've created the lake portion. 
    • It appears that this requires both `RenderSystem.disableDepthTest()` and `RenderSystem.depthMask(false)`.   
    • Why did you copy-paste that class? That does not make any sense. Just register your condition to the registry in FMLCommonSetupEvent and use DeferredWorkQueue since the registry is not threadsafe. You do not need CorruptionLootConditionManager at all.
    • I have been trying to use a GlobalLootModifer to add a new item to the Strider's loot table. However, since it seems as there is no existing loot condition that checks the type of entity (minecraft:strider), it adds my item as a possible drop off of any entity. Because of this, I am trying to make my own LootCondition that checks the entity type, but the problem is that I get a message that says minecraft:entity_slain is unrecognized when it parses my JSON file. I believe this is because it is being registered improperly. Forge doesn't have a registry for LootConditionType so I had to use the vanilla one but is still won't work. If anyone has a solution OR an alternative I would greatly appreciate it! Here's the code: JSON { "type":"corruption:strider_socks", "conditions": [ { "condition":"minecraft:random_chance_with_looting", "chance":0.5, "looting_multiplier":0.2 }, { "condition": "minecraft:entity_slain", "entity":"minecraft:strider" } ], "item": "corruption:lava_waders" } CorruptionLootConditionManager: package com.enderunknown.corruption.util.loot; import java.util.function.Predicate; import net.minecraft.loot.ILootSerializer; import net.minecraft.loot.LootConditionType; import net.minecraft.loot.LootTypesManager; import net.minecraft.loot.conditions.ILootCondition; import net.minecraft.util.ResourceLocation; import net.minecraft.util.registry.Registry; public class CorruptionLootConditionManager { public static final LootConditionType ENTITY_SLAIN = func_237475_a_("entity_slain", new EntitySlain.Serializer()); private static LootConditionType func_237475_a_(String p_237475_0_, ILootSerializer<? extends ILootCondition> p_237475_1_) { return Registry.register(Registry.field_239704_ba_, new ResourceLocation(p_237475_0_), new LootConditionType(p_237475_1_)); } public static Object func_237474_a_() { return LootTypesManager.func_237389_a_(Registry.field_239704_ba_, "condition", "condition", ILootCondition::func_230419_b_).func_237395_a_(); } public static <T> Predicate<T> and(Predicate<T>[] p_216305_0_) { switch(p_216305_0_.length) { case 0: return (p_216304_0_) -> { return true; }; case 1: return p_216305_0_[0]; case 2: return p_216305_0_[0].and(p_216305_0_[1]); default: return (p_216307_1_) -> { for(Predicate<T> predicate : p_216305_0_) { if (!predicate.test(p_216307_1_)) { return false; } } return true; }; } } public static <T> Predicate<T> or(Predicate<T>[] p_216306_0_) { switch(p_216306_0_.length) { case 0: return (p_216308_0_) -> { return false; }; case 1: return p_216306_0_[0]; case 2: return p_216306_0_[0].or(p_216306_0_[1]); default: return (p_216309_1_) -> { for(Predicate<T> predicate : p_216306_0_) { if (predicate.test(p_216309_1_)) { return true; } } return false; }; } } } EntitySlain ILootCondition: package com.enderunknown.corruption.util.loot; import java.util.Set; import com.google.common.collect.ImmutableSet; import com.google.gson.JsonDeserializationContext; import com.google.gson.JsonObject; import com.google.gson.JsonSerializationContext; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityType; import net.minecraft.loot.ILootSerializer; import net.minecraft.loot.LootConditionType; import net.minecraft.loot.LootContext; import net.minecraft.loot.LootParameter; import net.minecraft.loot.LootParameters; import net.minecraft.loot.conditions.ILootCondition; import net.minecraft.util.JSONUtils; import net.minecraft.util.ResourceLocation; import net.minecraft.util.registry.Registry; public class EntitySlain implements ILootCondition { private final EntityType<?> entityType; public EntitySlain(EntityType<?> entityType) { this.entityType = entityType; } public LootConditionType func_230419_b_() { return CorruptionLootConditionManager.ENTITY_SLAIN; } public Set<LootParameter<?>> getRequiredParameters() { return ImmutableSet.of(LootParameters.THIS_ENTITY); } public boolean test(LootContext context) { Entity entity = context.get(LootParameters.THIS_ENTITY); return entity != null && this.entityType.getTags() == entity.getType().getTags(); } public static class Builder implements ILootCondition.IBuilder { private final EntityType<?> entity; public Builder(EntityType<?> entityIn) { this.entity = entityIn; } public ILootCondition build() { return new EntitySlain(this.entity); } } public static class Serializer implements ILootSerializer<EntitySlain> { public void func_230424_a_(JsonObject p_230424_1_, EntitySlain p_230424_2_, JsonSerializationContext p_230424_3_) { p_230424_1_.addProperty("entity", Registry.ENTITY_TYPE.getKey(p_230424_2_.entityType).toString()); } public EntitySlain func_230423_a_(JsonObject p_230423_1_, JsonDeserializationContext p_230423_2_) { ResourceLocation resourcelocation = new ResourceLocation(JSONUtils.getString(p_230423_1_, "entity")); EntityType<?> entityT = Registry.ENTITY_TYPE.getValue(resourcelocation).orElseThrow(() -> { return new IllegalArgumentException("Can't find block " + resourcelocation); }); return new EntitySlain(entityT); } } } Thanks!
  • Topics

  • Who's Online (See full list)