This commit is contained in:
Adubbz 2019-06-14 00:00:59 +10:00
parent 5b42883511
commit 567b505439
38 changed files with 1586 additions and 1601 deletions

View File

@ -8,9 +8,10 @@
package biomesoplenty.api.entity;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.projectile.ProjectileItemEntity;
public class BOPEntities
{
public static EntityType<?> mudball;
public static EntityType<ProjectileItemEntity> mudball;
public static EntityType<?> boat_bop;
}

View File

@ -8,15 +8,16 @@
package biomesoplenty.client.util;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.BlockModelShapes;
import net.minecraft.client.renderer.BlockRendererDispatcher;
import net.minecraft.client.renderer.color.BlockColors;
import net.minecraft.client.renderer.model.BakedQuad;
import net.minecraft.client.renderer.model.IBakedModel;
import net.minecraft.block.Blocks;
import net.minecraft.util.Direction;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.registry.Registry;
import net.minecraft.world.biome.Biome;
import net.minecraftforge.common.BiomeDictionary;
@ -101,7 +102,7 @@ public class BiomeMapColours
return biomeColours.get(biomeId);
}
int colour = getBiomeMapColourRaw(Biome.getBiome(biomeId, null));
int colour = getBiomeMapColourRaw(Registry.BIOME.getByValue(biomeId));
biomeColours.put(biomeId, colour);
return colour;
}
@ -162,7 +163,7 @@ public class BiomeMapColours
public static int getBiomeBlockColourForCoords(Biome biome, BlockPos pos)
{
BlockState topBlock = biome.getSurfaceBuilder().getConfig().getTop();
BlockState topBlock = biome.getSurfaceBuilder().getConfig().getTopMaterial();
int colour;
if (topBlock == Blocks.GRASS.getDefaultState())

View File

@ -11,13 +11,12 @@ import biomesoplenty.common.world.BOPLayerUtil;
import biomesoplenty.common.world.BOPWorldSettings;
import biomesoplenty.common.world.layer.traits.IBOPContextExtended;
import biomesoplenty.common.world.layer.traits.LazyAreaLayerContextBOP;
import net.minecraft.world.biome.Biomes;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.biome.Biome;
import net.minecraft.world.biome.Biomes;
import net.minecraft.world.biome.provider.BiomeProviderType;
import net.minecraft.world.biome.provider.OverworldBiomeProviderSettings;
import net.minecraft.world.gen.OverworldGenSettings;
import net.minecraft.world.gen.area.AreaDimension;
import net.minecraft.world.gen.area.IAreaFactory;
import net.minecraft.world.gen.area.LazyArea;
import org.lwjgl.glfw.GLFW;
@ -160,10 +159,8 @@ public class GenLayerVisualizer
OverworldBiomeProviderSettings settingsProvider = BiomeProviderType.VANILLA_LAYERED.createSettings();
OverworldGenSettings settings = settingsProvider.getGeneratorSettings();
int[] aint = new int[1];
LongFunction<IBOPContextExtended<LazyArea>> contextFactory = (seedModifier) -> {
++aint[0];
return new LazyAreaLayerContextBOP(1, aint[0], 0, seedModifier);
return new LazyAreaLayerContextBOP(1, 0, seedModifier);
};
IAreaFactory<LazyArea> landAreaFactory = BOPLayerUtil.createInitialLandAndSeaFactory(contextFactory);
@ -172,8 +169,7 @@ public class GenLayerVisualizer
//IAreaFactory<LazyArea> biomeAreaFactory = BOPLayerUtil.createAreaFactories(WorldType.DEFAULT, settings, contextFactory).get(0);
AreaDimension areaDimension = new AreaDimension(0, 0, CANVAS_WIDTH, CANVAS_HEIGHT);
LazyArea area = biomeAreaFactory.make(areaDimension);
LazyArea area = biomeAreaFactory.make();
int startX = 5000;
int startZ = 10000;

View File

@ -11,14 +11,9 @@ import java.util.Random;
public class FirTree extends Tree
{
@Nullable
@Override
protected AbstractTreeFeature<NoFeatureConfig> getTreeFeature(Random random)
{
return BOPBiomeFeatures.FIR_TREE;
}
@Nullable
protected AbstractTreeFeature<NoFeatureConfig> getBigTreeFeature(Random random)
{
return BOPBiomeFeatures.FIR_TREE_LARGE;
}
}

View File

@ -11,14 +11,9 @@ import java.util.Random;
public class RedwoodTree extends Tree
{
@Nullable
@Override
protected AbstractTreeFeature<NoFeatureConfig> getTreeFeature(Random random)
{
return BOPBiomeFeatures.REDWOOD_TREE;
}
@Nullable
protected AbstractTreeFeature<NoFeatureConfig> getBigTreeFeature(Random random)
{
return BOPBiomeFeatures.REDWOOD_TREE_MEDIUM;
}
}

View File

@ -11,14 +11,9 @@ import java.util.Random;
public class UmbranTree extends Tree
{
@Nullable
@Override
protected AbstractTreeFeature<NoFeatureConfig> getTreeFeature(Random random)
{
return BOPBiomeFeatures.UMBRAN_TREE;
}
@Nullable
protected AbstractTreeFeature<NoFeatureConfig> getBigTreeFeature(Random random)
{
return BOPBiomeFeatures.TALL_UMBRAN_TREE;
}
}

View File

@ -1,107 +0,0 @@
package biomesoplenty.common.entity.item;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.entity.model.IMultipassModel;
import net.minecraft.client.renderer.entity.model.ModelBase;
import net.minecraft.client.renderer.entity.model.ModelRenderer;
import net.minecraft.entity.Entity;
import net.minecraft.util.math.MathHelper;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@OnlyIn(Dist.CLIENT)
public class ModelBoatBOP extends ModelBase implements IMultipassModel {
private final ModelRenderer[] boatSides = new ModelRenderer[5];
private final ModelRenderer[] paddles = new ModelRenderer[2];
/**
* An invisible layer that is rendered to make it seem like there's no water in the boat.
*
* @see https://redd.it/3qufgo
* @see https://bugs.mojang.com/browse/MC-47636
*/
private final ModelRenderer noWater;
public ModelBoatBOP() {
this.boatSides[0] = (new ModelRenderer(this, 0, 0)).setTextureSize(128, 64);
this.boatSides[1] = (new ModelRenderer(this, 0, 19)).setTextureSize(128, 64);
this.boatSides[2] = (new ModelRenderer(this, 0, 27)).setTextureSize(128, 64);
this.boatSides[3] = (new ModelRenderer(this, 0, 35)).setTextureSize(128, 64);
this.boatSides[4] = (new ModelRenderer(this, 0, 43)).setTextureSize(128, 64);
int i = 32;
int j = 6;
int k = 20;
int l = 4;
int i1 = 28;
this.boatSides[0].addBox(-14.0F, -9.0F, -3.0F, 28, 16, 3, 0.0F);
this.boatSides[0].setRotationPoint(0.0F, 3.0F, 1.0F);
this.boatSides[1].addBox(-13.0F, -7.0F, -1.0F, 18, 6, 2, 0.0F);
this.boatSides[1].setRotationPoint(-15.0F, 4.0F, 4.0F);
this.boatSides[2].addBox(-8.0F, -7.0F, -1.0F, 16, 6, 2, 0.0F);
this.boatSides[2].setRotationPoint(15.0F, 4.0F, 0.0F);
this.boatSides[3].addBox(-14.0F, -7.0F, -1.0F, 28, 6, 2, 0.0F);
this.boatSides[3].setRotationPoint(0.0F, 4.0F, -9.0F);
this.boatSides[4].addBox(-14.0F, -7.0F, -1.0F, 28, 6, 2, 0.0F);
this.boatSides[4].setRotationPoint(0.0F, 4.0F, 9.0F);
this.boatSides[0].rotateAngleX = ((float)Math.PI / 2F);
this.boatSides[1].rotateAngleY = ((float)Math.PI * 1.5F);
this.boatSides[2].rotateAngleY = ((float)Math.PI / 2F);
this.boatSides[3].rotateAngleY = (float)Math.PI;
this.paddles[0] = this.makePaddle(true);
this.paddles[0].setRotationPoint(3.0F, -5.0F, 9.0F);
this.paddles[1] = this.makePaddle(false);
this.paddles[1].setRotationPoint(3.0F, -5.0F, -9.0F);
this.paddles[1].rotateAngleY = (float)Math.PI;
this.paddles[0].rotateAngleZ = 0.19634955F;
this.paddles[1].rotateAngleZ = 0.19634955F;
this.noWater = (new ModelRenderer(this, 0, 0)).setTextureSize(128, 64);
this.noWater.addBox(-14.0F, -9.0F, -3.0F, 28, 16, 3, 0.0F);
this.noWater.setRotationPoint(0.0F, -3.0F, 1.0F);
this.noWater.rotateAngleX = ((float)Math.PI / 2F);
}
/**
* Sets the models various rotation angles then renders the model.
*/
public void render(Entity entityIn, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scale) {
GlStateManager.rotatef(90.0F, 0.0F, 1.0F, 0.0F);
EntityBoatBOP entityboat = (EntityBoatBOP)entityIn;
this.setRotationAngles(limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scale, entityIn);
for(int i = 0; i < 5; ++i) {
this.boatSides[i].render(scale);
}
this.renderPaddle(entityboat, 0, scale, limbSwing);
this.renderPaddle(entityboat, 1, scale, limbSwing);
}
public void renderMultipass(Entity entityIn, float partialTicks, float p_187054_3_, float p_187054_4_, float p_187054_5_, float p_187054_6_, float scale) {
GlStateManager.rotatef(90.0F, 0.0F, 1.0F, 0.0F);
GlStateManager.colorMask(false, false, false, false);
this.noWater.render(scale);
GlStateManager.colorMask(true, true, true, true);
}
protected ModelRenderer makePaddle(boolean p_187056_1_) {
ModelRenderer modelrenderer = (new ModelRenderer(this, 62, p_187056_1_ ? 0 : 20)).setTextureSize(128, 64);
int i = 20;
int j = 7;
int k = 6;
float f = -5.0F;
modelrenderer.addBox(-1.0F, 0.0F, -5.0F, 2, 2, 18);
modelrenderer.addBox(p_187056_1_ ? -1.001F : 0.001F, -3.0F, 8.0F, 1, 6, 7);
return modelrenderer;
}
protected void renderPaddle(EntityBoatBOP boat, int paddle, float scale, float limbSwing) {
float f = boat.getRowingTime(paddle, limbSwing);
ModelRenderer modelrenderer = this.paddles[paddle];
modelrenderer.rotateAngleX = (float)MathHelper.clampedLerp((double)(-(float)Math.PI / 3F), (double)-0.2617994F, (double)((MathHelper.sin(-f) + 1.0F) / 2.0F));
modelrenderer.rotateAngleY = (float)MathHelper.clampedLerp((double)(-(float)Math.PI / 4F), (double)((float)Math.PI / 4F), (double)((MathHelper.sin(-f + 1.0F) + 1.0F) / 2.0F));
if (paddle == 1) {
modelrenderer.rotateAngleY = (float)Math.PI - modelrenderer.rotateAngleY;
}
modelrenderer.render(scale);
}
}

View File

@ -3,6 +3,7 @@ package biomesoplenty.common.entity.item;
import com.mojang.blaze3d.platform.GlStateManager;
import net.minecraft.client.renderer.entity.EntityRenderer;
import net.minecraft.client.renderer.entity.EntityRendererManager;
import net.minecraft.client.renderer.entity.model.BoatModel;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.MathHelper;
import net.minecraftforge.api.distmarker.Dist;
@ -13,7 +14,7 @@ public class RenderBoatBOP extends EntityRenderer<EntityBoatBOP>
{
private static final ResourceLocation[] BOAT_TEXTURES = new ResourceLocation[]{new ResourceLocation("biomesoplenty:textures/entity/boat/fir.png"), new ResourceLocation("biomesoplenty:textures/entity/boat/redwood.png"), new ResourceLocation("biomesoplenty:textures/entity/boat/cherry.png"), new ResourceLocation("biomesoplenty:textures/entity/boat/mahogany.png"), new ResourceLocation("biomesoplenty:textures/entity/boat/jacaranda.png"), new ResourceLocation("biomesoplenty:textures/entity/boat/palm.png"), new ResourceLocation("biomesoplenty:textures/entity/boat/willow.png"), new ResourceLocation("biomesoplenty:textures/entity/boat/dead.png"), new ResourceLocation("biomesoplenty:textures/entity/boat/magic.png"), new ResourceLocation("biomesoplenty:textures/entity/boat/umbran.png"), new ResourceLocation("biomesoplenty:textures/entity/boat/hellbark.png"), new ResourceLocation("biomesoplenty:textures/entity/boat/ethereal.png")};
/** instance of ModelBoat for rendering */
protected ModelBase modelBoat = new ModelBoatBOP();
protected BoatModel modelBoat = new BoatModel();
public RenderBoatBOP(EntityRendererManager renderManagerIn) {
super(renderManagerIn);
@ -30,12 +31,12 @@ public class RenderBoatBOP extends EntityRenderer<EntityBoatBOP>
this.bindEntityTexture(entity);
if (this.renderOutlines) {
GlStateManager.enableColorMaterial();
GlStateManager.enableOutlineMode(this.getTeamColor(entity));
GlStateManager.setupSolidRenderingTextureCombine(this.getTeamColor(entity));
}
this.modelBoat.render(entity, partialTicks, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F);
if (this.renderOutlines) {
GlStateManager.disableOutlineMode();
GlStateManager.tearDownSolidRenderingTextureCombine();
GlStateManager.disableColorMaterial();
}
@ -83,7 +84,7 @@ public class RenderBoatBOP extends EntityRenderer<EntityBoatBOP>
this.setupTranslation(x, y, z);
this.setupRotation(entityIn, entityYaw, partialTicks);
this.bindEntityTexture(entityIn);
((IMultipassModel)this.modelBoat).renderMultipass(entityIn, partialTicks, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F);
this.modelBoat.renderMultipass(entityIn, partialTicks, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F);
GlStateManager.popMatrix();
}
}

View File

@ -8,21 +8,26 @@
package biomesoplenty.common.entity.projectile;
import biomesoplenty.api.entity.BOPEntities;
import biomesoplenty.api.item.BOPItems;
import biomesoplenty.api.particle.BOPParticleTypes;
import biomesoplenty.core.BiomesOPlenty;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.projectile.EntityThrowable;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.projectile.ProjectileItemEntity;
import net.minecraft.item.Item;
import net.minecraft.util.DamageSource;
import net.minecraft.util.math.EntityRayTraceResult;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.world.World;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
public class EntityMudball extends EntityThrowable
public class EntityMudball extends ProjectileItemEntity
{
public EntityMudball(World world)
public EntityMudball(EntityType<? extends EntityMudball> type, World world)
{
super(BOPEntities.mudball, world);
super(type, world);
}
public EntityMudball(World world, double x, double y, double z)
@ -30,11 +35,17 @@ public class EntityMudball extends EntityThrowable
super(BOPEntities.mudball, x, y, z, world);
}
public EntityMudball(World world, EntityLivingBase thrower)
public EntityMudball(World world, LivingEntity thrower)
{
super(BOPEntities.mudball, thrower, world);
}
@Override
protected Item func_213885_i()
{
return BOPItems.mudball;
}
@OnlyIn(Dist.CLIENT)
@Override
public void handleStatusUpdate(byte id)
@ -51,9 +62,10 @@ public class EntityMudball extends EntityThrowable
@Override
protected void onImpact(RayTraceResult hit)
{
if (hit.entity != null)
if (hit.getType() == RayTraceResult.Type.ENTITY)
{
hit.entity.attackEntityFrom(DamageSource.causeThrownDamage(this, this.getThrower()), 0.0F);
Entity entity = ((EntityRayTraceResult)hit).getEntity();
entity.attackEntityFrom(DamageSource.causeThrownDamage(this, this.getThrower()), 0.0F);
}
if (!this.world.isRemote)

View File

@ -9,15 +9,11 @@ package biomesoplenty.common.item;
import biomesoplenty.common.entity.projectile.EntityMudball;
import biomesoplenty.common.util.inventory.ItemGroupBOP;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.SoundEvents;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.stats.StatList;
import net.minecraft.util.ActionResult;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumHand;
import net.minecraft.util.SoundCategory;
import net.minecraft.stats.Stats;
import net.minecraft.util.*;
import net.minecraft.world.World;
public class ItemMudball extends Item
@ -28,7 +24,7 @@ public class ItemMudball extends Item
}
@Override
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand)
public ActionResult<ItemStack> onItemRightClick(World world, PlayerEntity player, Hand hand)
{
ItemStack stack = player.getHeldItem(hand);
if (!player.abilities.isCreativeMode)
@ -45,7 +41,7 @@ public class ItemMudball extends Item
world.spawnEntity(mudball);
}
player.addStat(StatList.ITEM_USED.get(this));
return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, stack);
player.addStat(Stats.ITEM_USED.get(this));
return new ActionResult<ItemStack>(ActionResultType.SUCCESS, stack);
}
}

View File

@ -9,10 +9,10 @@ package biomesoplenty.common.item;
import biomesoplenty.common.util.inventory.ItemGroupBOP;
import net.minecraft.item.Item;
import net.minecraft.item.ItemRecord;
import net.minecraft.item.MusicDiscItem;
import net.minecraft.util.SoundEvent;
public class ItemRecordBOP extends ItemRecord
public class ItemRecordBOP extends MusicDiscItem
{
public ItemRecordBOP(SoundEvent record)
{

View File

@ -10,10 +10,10 @@ package biomesoplenty.common.world;
import biomesoplenty.common.world.layer.*;
import biomesoplenty.common.world.layer.traits.LazyAreaLayerContextBOP;
import com.google.common.collect.ImmutableList;
import net.minecraft.world.biome.Biomes;
import net.minecraft.util.registry.Registry;
import net.minecraft.world.WorldType;
import net.minecraft.world.gen.IContextExtended;
import net.minecraft.world.biome.Biomes;
import net.minecraft.world.gen.IExtendedNoiseRandom;
import net.minecraft.world.gen.OverworldGenSettings;
import net.minecraft.world.gen.area.IArea;
import net.minecraft.world.gen.area.IAreaFactory;
@ -35,30 +35,30 @@ public class BOPLayerUtil
public static final int DEEP_COLD_OCEAN = Registry.BIOME.getId(Biomes.DEEP_COLD_OCEAN);
public static final int DEEP_FROZEN_OCEAN = Registry.BIOME.getId(Biomes.DEEP_FROZEN_OCEAN);
public static <T extends IArea, C extends IContextExtended<T>> IAreaFactory<T> createInitialLandAndSeaFactory(LongFunction<C> contextFactory)
public static <T extends IArea, C extends IExtendedNoiseRandom<T>> IAreaFactory<T> createInitialLandAndSeaFactory(LongFunction<C> contextFactory)
{
// NOTE: Normally AddSnow, CoolWarm, HeatIce and Special GenLayers occur here, but we handle those ourselves
IAreaFactory<T> factory = GenLayerIsland.INSTANCE.apply(contextFactory.apply(1L));
factory = GenLayerZoom.FUZZY.apply(contextFactory.apply(2000L), factory);
factory = GenLayerAddIsland.INSTANCE.apply(contextFactory.apply(1L), factory);
factory = GenLayerZoom.NORMAL.apply(contextFactory.apply(2001L), factory);
factory = GenLayerAddIsland.INSTANCE.apply(contextFactory.apply(2L), factory);
factory = GenLayerAddIsland.INSTANCE.apply(contextFactory.apply(50L), factory);
factory = GenLayerAddIsland.INSTANCE.apply(contextFactory.apply(70L), factory);
factory = GenLayerRemoveTooMuchOcean.INSTANCE.apply(contextFactory.apply(2L), factory);
IAreaFactory<T> factory = IslandLayer.INSTANCE.apply(contextFactory.apply(1L));
factory = ZoomLayer.FUZZY.apply(contextFactory.apply(2000L), factory);
factory = AddIslandLayer.INSTANCE.apply(contextFactory.apply(1L), factory);
factory = ZoomLayer.NORMAL.apply(contextFactory.apply(2001L), factory);
factory = AddIslandLayer.INSTANCE.apply(contextFactory.apply(2L), factory);
factory = AddIslandLayer.INSTANCE.apply(contextFactory.apply(50L), factory);
factory = AddIslandLayer.INSTANCE.apply(contextFactory.apply(70L), factory);
factory = RemoveTooMuchOceanLayer.INSTANCE.apply(contextFactory.apply(2L), factory);
//factory = GenLayerAddSnow.INSTANCE.<T>apply((IContextExtended)contextFactory.apply(2L), factory);
factory = GenLayerAddIsland.INSTANCE.apply(contextFactory.apply(3L), factory);
factory = AddIslandLayer.INSTANCE.apply(contextFactory.apply(3L), factory);
//factory = GenLayerEdge.CoolWarm.INSTANCE.apply(contextFactory.apply(2L), factory);
//factory = GenLayerEdge.HeatIce.INSTANCE.apply(contextFactory.apply(2L), factory);
//factory = GenLayerEdge.Special.INSTANCE.apply(contextFactory.apply(3L), factory);
factory = GenLayerZoom.NORMAL.apply(contextFactory.apply(2002L), factory);
factory = GenLayerZoom.NORMAL.apply(contextFactory.apply(2003L), factory);
factory = GenLayerAddIsland.INSTANCE.apply(contextFactory.apply(4L), factory);
factory = ZoomLayer.NORMAL.apply(contextFactory.apply(2002L), factory);
factory = ZoomLayer.NORMAL.apply(contextFactory.apply(2003L), factory);
factory = AddIslandLayer.INSTANCE.apply(contextFactory.apply(4L), factory);
return factory;
}
// superimpose hot and cold regions an a land and sea layer
public static <T extends IArea, C extends IContextExtended<T>> IAreaFactory<T> createClimateFactory(LongFunction<C> contextFactory, BOPWorldSettings settings)
public static <T extends IArea, C extends IExtendedNoiseRandom<T>> IAreaFactory<T> createClimateFactory(LongFunction<C> contextFactory, BOPWorldSettings settings)
{
IAreaFactory<T> temperatureFactory;
@ -101,15 +101,15 @@ public class BOPLayerUtil
return GenLayerClimate.INSTANCE.apply(contextFactory.apply(103L), temperatureFactory, rainfallFactory);
}
public static <T extends IArea, C extends IContextExtended<T>> IAreaFactory<T> createBiomeFactory(IAreaFactory<T> landSeaAreaFactory, IAreaFactory<T> climateAreaFactory, LongFunction<C> contextFactory)
public static <T extends IArea, C extends IExtendedNoiseRandom<T>> IAreaFactory<T> createBiomeFactory(IAreaFactory<T> landSeaAreaFactory, IAreaFactory<T> climateAreaFactory, LongFunction<C> contextFactory)
{
IAreaFactory<T> biomeFactory = GenLayerBiomeBOP.INSTANCE.apply(contextFactory.apply(200L), landSeaAreaFactory, climateAreaFactory);
biomeFactory = LayerUtil.repeat(1000L, GenLayerZoom.NORMAL, biomeFactory, 2, contextFactory);
biomeFactory = LayerUtil.repeat(1000L, ZoomLayer.NORMAL, biomeFactory, 2, contextFactory);
biomeFactory = GenLayerBiomeEdgeBOP.INSTANCE.apply(contextFactory.apply(1000L), biomeFactory);
return biomeFactory;
}
public static <T extends IArea, C extends IContextExtended<T>> ImmutableList<IAreaFactory<T>> createAreaFactories(WorldType worldType, OverworldGenSettings settings, LongFunction<C> contextFactory)
public static <T extends IArea, C extends IExtendedNoiseRandom<T>> ImmutableList<IAreaFactory<T>> createAreaFactories(WorldType worldType, OverworldGenSettings settings, LongFunction<C> contextFactory)
{
// Create the initial land and sea layer. Is also responsible for adding deep oceans
// and mushroom islands
@ -117,7 +117,7 @@ public class BOPLayerUtil
// Determines positions for all of the new ocean subbiomes added in 1.13
IAreaFactory<T> oceanBiomeFactory = OceanLayer.INSTANCE.apply(contextFactory.apply(2L));
oceanBiomeFactory = LayerUtil.repeat(2001L, GenLayerZoom.NORMAL, oceanBiomeFactory, 6, contextFactory);
oceanBiomeFactory = LayerUtil.repeat(2001L, ZoomLayer.NORMAL, oceanBiomeFactory, 6, contextFactory);
int biomeSize = 4;
int riverSize = biomeSize;
@ -132,60 +132,58 @@ public class BOPLayerUtil
IAreaFactory<T> climateFactory = createClimateFactory(contextFactory, new BOPWorldSettings());
// Add islands and deep oceans
landSeaFactory = GenLayerAddMushroomIsland.INSTANCE.apply(contextFactory.apply(5L), landSeaFactory);
landSeaFactory = AddMushroomIslandLayer.INSTANCE.apply(contextFactory.apply(5L), landSeaFactory);
landSeaFactory = GenLayerLargeIsland.INSTANCE.apply(contextFactory.apply(5L), landSeaFactory, climateFactory);
landSeaFactory = GenLayerDeepOcean.INSTANCE.apply(contextFactory.apply(4L), landSeaFactory);
landSeaFactory = DeepOceanLayer.INSTANCE.apply(contextFactory.apply(4L), landSeaFactory);
// Allocate the biomes
IAreaFactory<T> biomesFactory = createBiomeFactory(landSeaFactory, climateFactory, contextFactory);
// Fork off a new branch as a seed for rivers and sub biomes
IAreaFactory<T> riverAndSubBiomesInitFactory = GenLayerRiverInit.INSTANCE.apply(contextFactory.apply(100L), landSeaFactory);
riverAndSubBiomesInitFactory = LayerUtil.repeat(1000L, GenLayerZoom.NORMAL, riverAndSubBiomesInitFactory, 2, contextFactory);
IAreaFactory<T> riverAndSubBiomesInitFactory = RiverLayer.INSTANCE.apply(contextFactory.apply(100L), landSeaFactory);
riverAndSubBiomesInitFactory = LayerUtil.repeat(1000L, ZoomLayer.NORMAL, riverAndSubBiomesInitFactory, 2, contextFactory);
biomesFactory = GenLayerSubBiome.INSTANCE.apply(contextFactory.apply(1000L), biomesFactory, riverAndSubBiomesInitFactory);
// Develop the rivers branch
IAreaFactory<T> riversInitFactory = LayerUtil.repeat(1000L, GenLayerZoom.NORMAL, riverAndSubBiomesInitFactory, riverSize, contextFactory);
riversInitFactory = GenLayerRiver.INSTANCE.apply(contextFactory.apply(1L), riversInitFactory);
riversInitFactory = GenLayerSmooth.INSTANCE.apply(contextFactory.apply(1000L), riversInitFactory);
IAreaFactory<T> riversInitFactory = LayerUtil.repeat(1000L, ZoomLayer.NORMAL, riverAndSubBiomesInitFactory, riverSize, contextFactory);
riversInitFactory = RiverLayer.INSTANCE.apply(contextFactory.apply(1L), riversInitFactory);
riversInitFactory = SmoothLayer.INSTANCE.apply(contextFactory.apply(1000L), riversInitFactory);
// Mix in rare biomes into biomes branch
biomesFactory = GenLayerRareBiome.INSTANCE.apply(contextFactory.apply(1001L), biomesFactory);
biomesFactory = RareBiomeLayer.INSTANCE.apply(contextFactory.apply(1001L), biomesFactory);
// Zoom more based on the biome size
for (int i = 0; i < biomeSize; ++i)
{
biomesFactory = GenLayerZoom.NORMAL.apply(contextFactory.apply((long)(1000 + i)), biomesFactory);
if (i == 0) biomesFactory = GenLayerAddIsland.INSTANCE.apply(contextFactory.apply(3L), biomesFactory);
biomesFactory = ZoomLayer.NORMAL.apply(contextFactory.apply((long)(1000 + i)), biomesFactory);
if (i == 0) biomesFactory = AddIslandLayer.INSTANCE.apply(contextFactory.apply(3L), biomesFactory);
if (i == 1 || biomeSize == 1) biomesFactory = GenLayerShoreBOP.INSTANCE.apply(contextFactory.apply(1000L), biomesFactory);
}
biomesFactory = GenLayerSmooth.INSTANCE.apply(contextFactory.apply(1000L), biomesFactory);
biomesFactory = SmoothLayer.INSTANCE.apply(contextFactory.apply(1000L), biomesFactory);
// Mix rivers into the biomes branch
biomesFactory = GenLayerRiverMixBOP.INSTANCE.apply(contextFactory.apply(100L), biomesFactory, riversInitFactory);
climateFactory = LayerUtil.repeat(2001L, GenLayerZoom.NORMAL, climateFactory, 6, contextFactory);
climateFactory = LayerUtil.repeat(2001L, ZoomLayer.NORMAL, climateFactory, 6, contextFactory);
biomesFactory = GenLayerMixOceansBOP.INSTANCE.apply(contextFactory.apply(100L), biomesFactory, oceanBiomeFactory, climateFactory);
// Finish biomes with Voroni zoom
IAreaFactory<T> voroniZoomBiomesFactory = GenLayerVoronoiZoom.INSTANCE.apply(contextFactory.apply(10L), biomesFactory);
IAreaFactory<T> voroniZoomBiomesFactory = VoroniZoomLayer.INSTANCE.apply(contextFactory.apply(10L), biomesFactory);
return ImmutableList.of(biomesFactory, voroniZoomBiomesFactory, biomesFactory);
}
public static GenLayer[] createGenLayers(long seed, WorldType worldType, OverworldGenSettings settings)
public static Layer[] createGenLayers(long seed, WorldType worldType, OverworldGenSettings settings)
{
int[] layerCount = new int[1]; // Do this as an array to enable incrementing it in the lambda
ImmutableList<IAreaFactory<LazyArea>> factoryList = createAreaFactories(worldType, settings, (seedModifier) ->
{
++layerCount[0];
return new LazyAreaLayerContextBOP(1, layerCount[0], seed, seedModifier);
return new LazyAreaLayerContextBOP(1, seed, seedModifier);
});
GenLayer biomesLayer = new GenLayer(factoryList.get(0));
GenLayer voroniZoomBiomesLayer = new GenLayer(factoryList.get(1));
GenLayer biomesLayer2 = new GenLayer(factoryList.get(2));
return new GenLayer[]{biomesLayer, voroniZoomBiomesLayer, biomesLayer2};
Layer biomesLayer = new Layer(factoryList.get(0));
Layer voroniZoomBiomesLayer = new Layer(factoryList.get(1));
Layer biomesLayer2 = new Layer(factoryList.get(2));
return new Layer[]{biomesLayer, voroniZoomBiomesLayer, biomesLayer2};
}
public static boolean isOcean(int biomeIn)

View File

@ -9,10 +9,10 @@ package biomesoplenty.common.world;
import net.minecraft.world.IWorld;
import net.minecraft.world.biome.provider.BiomeProvider;
import net.minecraft.world.gen.ChunkGeneratorOverworld;
import net.minecraft.world.gen.OverworldChunkGenerator;
import net.minecraft.world.gen.OverworldGenSettings;
public class ChunkGeneratorOverworldBOP extends ChunkGeneratorOverworld
public class ChunkGeneratorOverworldBOP extends OverworldChunkGenerator
{
public ChunkGeneratorOverworldBOP(IWorld world, BiomeProvider provider, OverworldGenSettings settings)
{

View File

@ -7,19 +7,11 @@
******************************************************************************/
package biomesoplenty.common.world;
import net.minecraft.block.Blocks;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraft.world.WorldType;
import net.minecraft.world.biome.provider.BiomeProviderType;
import net.minecraft.world.biome.provider.EndBiomeProvider;
import net.minecraft.world.biome.provider.EndBiomeProviderSettings;
import net.minecraft.world.biome.provider.OverworldBiomeProviderSettings;
import net.minecraft.world.dimension.DimensionType;
import net.minecraft.world.dimension.EndDimension;
import net.minecraft.world.gen.ChunkGeneratorType;
import net.minecraft.world.gen.EndGenSettings;
import net.minecraft.world.gen.IChunkGenerator;
import net.minecraft.world.gen.ChunkGenerator;
import net.minecraft.world.gen.OverworldGenSettings;
public class WorldTypeBOP extends WorldType
@ -30,7 +22,7 @@ public class WorldTypeBOP extends WorldType
}
@Override
public IChunkGenerator<?> createChunkGenerator(World world)
public ChunkGenerator<?> createChunkGenerator(World world)
{
if (world.getDimension().getType() == DimensionType.OVERWORLD)
{

View File

@ -7,42 +7,51 @@
******************************************************************************/
package biomesoplenty.common.world.gen.feature;
import java.util.Random;
import com.mojang.datafixers.Dynamic;
import net.minecraft.block.BlockState;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.biome.Biome;
import net.minecraft.world.chunk.IChunk;
import net.minecraft.world.gen.surfacebuilders.ISurfaceBuilder;
import net.minecraft.world.gen.surfacebuilders.SurfaceBuilder;
import net.minecraft.world.gen.surfacebuilders.SurfaceBuilderConfig;
public class MangroveSurfaceBuilder implements ISurfaceBuilder<SurfaceBuilderConfig> {
public void buildSurface(Random random, IChunk chunkIn, Biome biomeIn, int x, int z, int startHeight, double noise, BlockState defaultBlock, BlockState defaultFluid, int seaLevel, long seed, SurfaceBuilderConfig config) {
double d0 = Biome.INFO_NOISE.getValue((double)x * 0.25D, (double)z * 0.25D);
if (d0 > 0.2D) {
int i = x & 15;
int j = z & 15;
BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos();
import java.util.Random;
import java.util.function.Function;
for(int k = startHeight; k >= 0; --k) {
blockpos$mutableblockpos.setPos(i, k, j);
if (!chunkIn.getBlockState(blockpos$mutableblockpos).isAir()) {
if (k == 62 && chunkIn.getBlockState(blockpos$mutableblockpos).getBlock() != defaultFluid.getBlock()) {
chunkIn.setBlockState(blockpos$mutableblockpos, defaultFluid, false);
}
break;
}
}
}
if (noise > 0.1D)
{
Biome.DEFAULT_SURFACE_BUILDER.buildSurface(random, chunkIn, biomeIn, x, z, startHeight, noise, defaultBlock, defaultFluid, seaLevel, seed, BOPBiomeFeatures.MUD_SURFACE);
}
else
{
Biome.DEFAULT_SURFACE_BUILDER.buildSurface(random, chunkIn, biomeIn, x, z, startHeight, noise, defaultBlock, defaultFluid, seaLevel, seed, Biome.GRASS_DIRT_GRAVEL_SURFACE);
}
public class MangroveSurfaceBuilder extends SurfaceBuilder<SurfaceBuilderConfig>
{
public MangroveSurfaceBuilder(Function<Dynamic<?>, ? extends SurfaceBuilderConfig> deserializer)
{
super(deserializer);
}
}
}
@Override
public void buildSurface(Random random, IChunk chunkIn, Biome biomeIn, int x, int z, int startHeight, double noise, BlockState defaultBlock, BlockState defaultFluid, int seaLevel, long seed, SurfaceBuilderConfig config)
{
double d0 = Biome.INFO_NOISE.getValue((double)x * 0.25D, (double)z * 0.25D);
if (d0 > 0.2D) {
int i = x & 15;
int j = z & 15;
BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos();
for(int k = startHeight; k >= 0; --k) {
blockpos$mutableblockpos.setPos(i, k, j);
if (!chunkIn.getBlockState(blockpos$mutableblockpos).isAir()) {
if (k == 62 && chunkIn.getBlockState(blockpos$mutableblockpos).getBlock() != defaultFluid.getBlock()) {
chunkIn.setBlockState(blockpos$mutableblockpos, defaultFluid, false);
}
break;
}
}
}
if (noise > 0.1D)
{
SurfaceBuilder.DEFAULT.buildSurface(random, chunkIn, biomeIn, x, z, startHeight, noise, defaultBlock, defaultFluid, seaLevel, seed, BOPBiomeFeatures.MUD_SURFACE);
}
else
{
SurfaceBuilder.DEFAULT.buildSurface(random, chunkIn, biomeIn, x, z, startHeight, noise, defaultBlock, defaultFluid, seaLevel, seed, SurfaceBuilder.GRASS_DIRT_GRAVEL_CONFIG);
}
}
}

View File

@ -7,34 +7,44 @@
******************************************************************************/
package biomesoplenty.common.world.gen.feature;
import java.util.Random;
import com.mojang.datafixers.Dynamic;
import net.minecraft.block.BlockState;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.biome.Biome;
import net.minecraft.world.chunk.IChunk;
import net.minecraft.world.gen.surfacebuilders.ISurfaceBuilder;
import net.minecraft.world.gen.surfacebuilders.SurfaceBuilder;
import net.minecraft.world.gen.surfacebuilders.SurfaceBuilderConfig;
public class MarshSurfaceBuilder implements ISurfaceBuilder<SurfaceBuilderConfig> {
public void buildSurface(Random random, IChunk chunkIn, Biome biomeIn, int x, int z, int startHeight, double noise, BlockState defaultBlock, BlockState defaultFluid, int seaLevel, long seed, SurfaceBuilderConfig config) {
double d0 = Biome.INFO_NOISE.getValue((double)x * 0.25D, (double)z * 0.25D);
if (d0 > 0.0D) {
int i = x & 15;
int j = z & 15;
BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos();
import java.util.Random;
import java.util.function.Function;
for(int k = startHeight; k >= 0; --k) {
blockpos$mutableblockpos.setPos(i, k, j);
if (!chunkIn.getBlockState(blockpos$mutableblockpos).isAir()) {
if (k == 62 && chunkIn.getBlockState(blockpos$mutableblockpos).getBlock() != defaultFluid.getBlock()) {
chunkIn.setBlockState(blockpos$mutableblockpos, defaultFluid, false);
}
break;
}
}
}
public class MarshSurfaceBuilder extends SurfaceBuilder<SurfaceBuilderConfig>
{
public MarshSurfaceBuilder(Function<Dynamic<?>, ? extends SurfaceBuilderConfig> deserializer)
{
super(deserializer);
}
Biome.DEFAULT_SURFACE_BUILDER.buildSurface(random, chunkIn, biomeIn, x, z, startHeight, noise, defaultBlock, defaultFluid, seaLevel, seed, config);
}
}
@Override
public void buildSurface(Random random, IChunk chunkIn, Biome biomeIn, int x, int z, int startHeight, double noise, BlockState defaultBlock, BlockState defaultFluid, int seaLevel, long seed, SurfaceBuilderConfig config)
{
double d0 = Biome.INFO_NOISE.getValue((double)x * 0.25D, (double)z * 0.25D);
if (d0 > 0.0D) {
int i = x & 15;
int j = z & 15;
BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos();
for(int k = startHeight; k >= 0; --k) {
blockpos$mutableblockpos.setPos(i, k, j);
if (!chunkIn.getBlockState(blockpos$mutableblockpos).isAir()) {
if (k == 62 && chunkIn.getBlockState(blockpos$mutableblockpos).getBlock() != defaultFluid.getBlock()) {
chunkIn.setBlockState(blockpos$mutableblockpos, defaultFluid, false);
}
break;
}
}
}
SurfaceBuilder.DEFAULT.buildSurface(random, chunkIn, biomeIn, x, z, startHeight, noise, defaultBlock, defaultFluid, seaLevel, seed, config);
}
}

View File

@ -7,24 +7,33 @@
******************************************************************************/
package biomesoplenty.common.world.gen.feature;
import java.util.Random;
import com.mojang.datafixers.Dynamic;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper;
import net.minecraft.world.biome.Biome;
import net.minecraft.world.gen.feature.AbstractFlowersFeature;
import net.minecraft.world.gen.feature.FlowersFeature;
import net.minecraft.world.gen.feature.NoFeatureConfig;
public class MeadowFlowersFeature extends AbstractFlowersFeature
import java.util.Random;
import java.util.function.Function;
public class MeadowFlowersFeature extends FlowersFeature
{
private static final Block[] FLOWERS = new Block[]{Blocks.OXEYE_DAISY, Blocks.AZURE_BLUET, Blocks.DANDELION, Blocks.POPPY};
private static final Block[] FLOWERS = new Block[]{Blocks.OXEYE_DAISY, Blocks.AZURE_BLUET, Blocks.DANDELION, Blocks.POPPY};
public BlockState getRandomFlower(Random p_202355_1_, BlockPos p_202355_2_)
{
double d0 = MathHelper.clamp((1.0D + Biome.INFO_NOISE.getValue((double)p_202355_2_.getX() / 48.0D, (double)p_202355_2_.getZ() / 48.0D)) / 2.0D, 0.0D, 0.9999D);
Block block = FLOWERS[(int)(d0 * (double)FLOWERS.length)];
return block.getDefaultState();
}
}
public MeadowFlowersFeature(Function<Dynamic<?>, ? extends NoFeatureConfig> deserializer)
{
super(deserializer);
}
@Override
public BlockState getRandomFlower(Random p_202355_1_, BlockPos p_202355_2_)
{
double d0 = MathHelper.clamp((1.0D + Biome.INFO_NOISE.getValue((double)p_202355_2_.getX() / 48.0D, (double)p_202355_2_.getZ() / 48.0D)) / 2.0D, 0.0D, 0.9999D);
Block block = FLOWERS[(int)(d0 * (double)FLOWERS.length)];
return block.getDefaultState();
}
}

View File

@ -7,26 +7,35 @@
******************************************************************************/
package biomesoplenty.common.world.gen.feature;
import java.util.Random;
import biomesoplenty.api.block.BOPBlocks;
import com.mojang.datafixers.Dynamic;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.gen.feature.AbstractFlowersFeature;
import net.minecraft.world.gen.feature.FlowersFeature;
import net.minecraft.world.gen.feature.NoFeatureConfig;
public class MoorFlowersFeature extends AbstractFlowersFeature
import java.util.Random;
import java.util.function.Function;
public class MoorFlowersFeature extends FlowersFeature
{
public BlockState getRandomFlower(Random p_202355_1_, BlockPos p_202355_2_)
{
int j = p_202355_1_.nextInt(2);
switch(j)
{
case 0:
return BOPBlocks.violet.getDefaultState();
case 1:
default:
return Blocks.ALLIUM.getDefaultState();
}
}
public MoorFlowersFeature(Function<Dynamic<?>, ? extends NoFeatureConfig> deserializer)
{
super(deserializer);
}
@Override
public BlockState getRandomFlower(Random p_202355_1_, BlockPos p_202355_2_)
{
int j = p_202355_1_.nextInt(2);
switch(j)
{
case 0:
return BOPBlocks.violet.getDefaultState();
case 1:
default:
return Blocks.ALLIUM.getDefaultState();
}
}
}

View File

@ -7,24 +7,33 @@
******************************************************************************/
package biomesoplenty.common.world.gen.feature;
import java.util.Random;
import com.mojang.datafixers.Dynamic;
import net.minecraft.block.BlockState;
import net.minecraft.world.biome.Biome;
import net.minecraft.world.chunk.IChunk;
import net.minecraft.world.gen.surfacebuilders.ISurfaceBuilder;
import net.minecraft.world.gen.surfacebuilders.SurfaceBuilder;
import net.minecraft.world.gen.surfacebuilders.SurfaceBuilderConfig;
public class MudSurfaceBuilder implements ISurfaceBuilder<SurfaceBuilderConfig> {
public void buildSurface(Random random, IChunk chunkIn, Biome biomeIn, int x, int z, int startHeight, double noise, BlockState defaultBlock, BlockState defaultFluid, int seaLevel, long seed, SurfaceBuilderConfig config) {
if (noise > 1.7D)
{
Biome.DEFAULT_SURFACE_BUILDER.buildSurface(random, chunkIn, biomeIn, x, z, startHeight, noise, defaultBlock, defaultFluid, seaLevel, seed, BOPBiomeFeatures.MUD_SURFACE);
}
else
{
Biome.DEFAULT_SURFACE_BUILDER.buildSurface(random, chunkIn, biomeIn, x, z, startHeight, noise, defaultBlock, defaultFluid, seaLevel, seed, Biome.GRASS_DIRT_GRAVEL_SURFACE);
}
import java.util.Random;
import java.util.function.Function;
}
}
public class MudSurfaceBuilder extends SurfaceBuilder<SurfaceBuilderConfig>
{
public MudSurfaceBuilder(Function<Dynamic<?>, ? extends SurfaceBuilderConfig> deserializer)
{
super(deserializer);
}
@Override
public void buildSurface(Random random, IChunk chunkIn, Biome biomeIn, int x, int z, int startHeight, double noise, BlockState defaultBlock, BlockState defaultFluid, int seaLevel, long seed, SurfaceBuilderConfig config) {
if (noise > 1.7D)
{
SurfaceBuilder.DEFAULT.buildSurface(random, chunkIn, biomeIn, x, z, startHeight, noise, defaultBlock, defaultFluid, seaLevel, seed, BOPBiomeFeatures.MUD_SURFACE);
}
else
{
SurfaceBuilder.DEFAULT.buildSurface(random, chunkIn, biomeIn, x, z, startHeight, noise, defaultBlock, defaultFluid, seaLevel, seed, SurfaceBuilder.GRASS_DIRT_GRAVEL_CONFIG);
}
}
}

View File

@ -7,25 +7,34 @@
******************************************************************************/
package biomesoplenty.common.world.gen.feature;
import java.util.Random;
import biomesoplenty.api.block.BOPBlocks;
import com.mojang.datafixers.Dynamic;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper;
import net.minecraft.world.biome.Biome;
import net.minecraft.world.gen.feature.AbstractFlowersFeature;
import net.minecraft.world.gen.feature.FlowersFeature;
import net.minecraft.world.gen.feature.NoFeatureConfig;
public class MysticGroveFlowersFeature extends AbstractFlowersFeature
import java.util.Random;
import java.util.function.Function;
public class MysticGroveFlowersFeature extends FlowersFeature
{
private static final Block[] FLOWERS = new Block[]{BOPBlocks.blue_hydrangea, BOPBlocks.glowflower, BOPBlocks.pink_daffodil, Blocks.OXEYE_DAISY, Blocks.ALLIUM};
private static final Block[] FLOWERS = new Block[]{BOPBlocks.blue_hydrangea, BOPBlocks.glowflower, BOPBlocks.pink_daffodil, Blocks.OXEYE_DAISY, Blocks.ALLIUM};
public BlockState getRandomFlower(Random p_202355_1_, BlockPos p_202355_2_)
{
double d0 = MathHelper.clamp((1.0D + Biome.INFO_NOISE.getValue((double)p_202355_2_.getX() / 48.0D, (double)p_202355_2_.getZ() / 48.0D)) / 2.0D, 0.0D, 0.9999D);
Block block = FLOWERS[(int)(d0 * (double)FLOWERS.length)];
return block.getDefaultState();
}
}
public MysticGroveFlowersFeature(Function<Dynamic<?>, ? extends NoFeatureConfig> deserializer)
{
super(deserializer);
}
@Override
public BlockState getRandomFlower(Random p_202355_1_, BlockPos p_202355_2_)
{
double d0 = MathHelper.clamp((1.0D + Biome.INFO_NOISE.getValue((double)p_202355_2_.getX() / 48.0D, (double)p_202355_2_.getZ() / 48.0D)) / 2.0D, 0.0D, 0.9999D);
Block block = FLOWERS[(int)(d0 * (double)FLOWERS.length)];
return block.getDefaultState();
}
}

View File

@ -7,18 +7,27 @@
******************************************************************************/
package biomesoplenty.common.world.gen.feature;
import java.util.Random;
import biomesoplenty.api.block.BOPBlocks;
import com.mojang.datafixers.Dynamic;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.gen.feature.AbstractFlowersFeature;
import net.minecraft.world.gen.feature.FlowersFeature;
import net.minecraft.world.gen.feature.NoFeatureConfig;
public class OriginFlowersFeature extends AbstractFlowersFeature
import java.util.Random;
import java.util.function.Function;
public class OriginFlowersFeature extends FlowersFeature
{
public BlockState getRandomFlower(Random p_202355_1_, BlockPos p_202355_2_)
{
return p_202355_1_.nextFloat() > 0.6666667F ? Blocks.DANDELION.getDefaultState() : BOPBlocks.rose.getDefaultState();
}
}
public OriginFlowersFeature(Function<Dynamic<?>, ? extends NoFeatureConfig> deserializer)
{
super(deserializer);
}
@Override
public BlockState getRandomFlower(Random p_202355_1_, BlockPos p_202355_2_)
{
return p_202355_1_.nextFloat() > 0.6666667F ? Blocks.DANDELION.getDefaultState() : BOPBlocks.rose.getDefaultState();
}
}

View File

@ -7,21 +7,30 @@
******************************************************************************/
package biomesoplenty.common.world.gen.feature;
import java.util.Random;
import com.mojang.datafixers.Dynamic;
import net.minecraft.block.BlockState;
import net.minecraft.world.biome.Biome;
import net.minecraft.world.chunk.IChunk;
import net.minecraft.world.gen.surfacebuilders.ISurfaceBuilder;
import net.minecraft.world.gen.surfacebuilders.SurfaceBuilder;
import net.minecraft.world.gen.surfacebuilders.SurfaceBuilderConfig;
public class PodzolSurfaceBuilder implements ISurfaceBuilder<SurfaceBuilderConfig> {
public void buildSurface(Random random, IChunk chunkIn, Biome biomeIn, int x, int z, int startHeight, double noise, BlockState defaultBlock, BlockState defaultFluid, int seaLevel, long seed, SurfaceBuilderConfig config) {
if (noise > 1.9D) {
Biome.DEFAULT_SURFACE_BUILDER.buildSurface(random, chunkIn, biomeIn, x, z, startHeight, noise, defaultBlock, defaultFluid, seaLevel, seed, Biome.PODZOL_DIRT_GRAVEL_SURFACE);
} else {
Biome.DEFAULT_SURFACE_BUILDER.buildSurface(random, chunkIn, biomeIn, x, z, startHeight, noise, defaultBlock, defaultFluid, seaLevel, seed, Biome.GRASS_DIRT_GRAVEL_SURFACE);
}
import java.util.Random;
import java.util.function.Function;
}
}
public class PodzolSurfaceBuilder extends SurfaceBuilder<SurfaceBuilderConfig>
{
public PodzolSurfaceBuilder(Function<Dynamic<?>, ? extends SurfaceBuilderConfig> deserializer)
{
super(deserializer);
}
@Override
public void buildSurface(Random random, IChunk chunkIn, Biome biomeIn, int x, int z, int startHeight, double noise, BlockState defaultBlock, BlockState defaultFluid, int seaLevel, long seed, SurfaceBuilderConfig config)
{
if (noise > 1.9D) {
SurfaceBuilder.DEFAULT.buildSurface(random, chunkIn, biomeIn, x, z, startHeight, noise, defaultBlock, defaultFluid, seaLevel, seed, SurfaceBuilder.PODZOL_DIRT_GRAVEL_CONFIG);
} else {
SurfaceBuilder.DEFAULT.buildSurface(random, chunkIn, biomeIn, x, z, startHeight, noise, defaultBlock, defaultFluid, seaLevel, seed, SurfaceBuilder.GRASS_DIRT_GRAVEL_CONFIG);
}
}
}

View File

@ -7,24 +7,33 @@
******************************************************************************/
package biomesoplenty.common.world.gen.feature;
import java.util.Random;
import biomesoplenty.api.block.BOPBlocks;
import com.mojang.datafixers.Dynamic;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper;
import net.minecraft.world.biome.Biome;
import net.minecraft.world.gen.feature.AbstractFlowersFeature;
import net.minecraft.world.gen.feature.FlowersFeature;
import net.minecraft.world.gen.feature.NoFeatureConfig;
public class PrairieFlowersFeature extends AbstractFlowersFeature
import java.util.Random;
import java.util.function.Function;
public class PrairieFlowersFeature extends FlowersFeature
{
private static final Block[] FLOWERS = new Block[]{BOPBlocks.goldenrod};
private static final Block[] FLOWERS = new Block[]{BOPBlocks.goldenrod};
public BlockState getRandomFlower(Random p_202355_1_, BlockPos p_202355_2_)
{
double d0 = MathHelper.clamp((1.0D + Biome.INFO_NOISE.getValue((double)p_202355_2_.getX() / 48.0D, (double)p_202355_2_.getZ() / 48.0D)) / 2.0D, 0.0D, 0.9999D);
Block block = FLOWERS[(int)(d0 * (double)FLOWERS.length)];
return block.getDefaultState();
}
}
public PrairieFlowersFeature(Function<Dynamic<?>, ? extends NoFeatureConfig> deserializer)
{
super(deserializer);
}
@Override
public BlockState getRandomFlower(Random p_202355_1_, BlockPos p_202355_2_)
{
double d0 = MathHelper.clamp((1.0D + Biome.INFO_NOISE.getValue((double)p_202355_2_.getX() / 48.0D, (double)p_202355_2_.getZ() / 48.0D)) / 2.0D, 0.0D, 0.9999D);
Block block = FLOWERS[(int)(d0 * (double)FLOWERS.length)];
return block.getDefaultState();
}
}

View File

@ -1,56 +1,64 @@
package biomesoplenty.common.world.gen.feature;
import java.util.Random;
import net.minecraft.block.BlockCarvedPumpkin;
import net.minecraft.block.BlockLeaves;
import com.mojang.datafixers.Dynamic;
import net.minecraft.block.Blocks;
import net.minecraft.block.CarvedPumpkinBlock;
import net.minecraft.block.LeavesBlock;
import net.minecraft.util.Direction;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IWorld;
import net.minecraft.world.gen.IChunkGenSettings;
import net.minecraft.world.gen.IChunkGenerator;
import net.minecraft.world.gen.ChunkGenerator;
import net.minecraft.world.gen.GenerationSettings;
import net.minecraft.world.gen.feature.Feature;
import net.minecraft.world.gen.feature.NoFeatureConfig;
import java.util.Random;
import java.util.function.Function;
public class PumpkinPatchFeature extends Feature<NoFeatureConfig>
{
public boolean place(IWorld p_212245_1_, IChunkGenerator<? extends IChunkGenSettings> p_212245_2_, Random p_212245_3_, BlockPos p_212245_4_, NoFeatureConfig p_212245_5_)
{
int i = 0;
public PumpkinPatchFeature(Function<Dynamic<?>, ? extends NoFeatureConfig> deserializer)
{
super(deserializer);
}
for(int j = 0; j < 64; ++j)
{
BlockPos blockpos = p_212245_4_.add(p_212245_3_.nextInt(8) - p_212245_3_.nextInt(8), p_212245_3_.nextInt(4) - p_212245_3_.nextInt(4), p_212245_3_.nextInt(8) - p_212245_3_.nextInt(8));
if (p_212245_1_.getBlockState(blockpos).canBeReplacedByLeaves(p_212245_1_, blockpos) && p_212245_1_.getBlockState(blockpos.down()).getBlock() == Blocks.GRASS_BLOCK)
{
if (p_212245_3_.nextInt(3) == 0)
{
int rand = p_212245_3_.nextInt(50);
if (rand > 10)
{
p_212245_1_.setBlockState(blockpos, Blocks.PUMPKIN.getDefaultState(), 2);
}
else if (rand > 1)
{
p_212245_1_.setBlockState(blockpos, Blocks.CARVED_PUMPKIN.getDefaultState().with(BlockCarvedPumpkin.FACING, Direction.byIndex(2 + p_212245_3_.nextInt(4))), 2);
}
else
{
p_212245_1_.setBlockState(blockpos, Blocks.JACK_O_LANTERN.getDefaultState().with(BlockCarvedPumpkin.FACING, Direction.byIndex(2 + p_212245_3_.nextInt(4))), 2);
}
}
else
{
p_212245_1_.setBlockState(blockpos, Blocks.OAK_LEAVES.getDefaultState().with(BlockLeaves.PERSISTENT, true), 2);
}
++i;
}
}
@Override
public boolean place(IWorld p_212245_1_, ChunkGenerator<? extends GenerationSettings> p_212245_2_, Random p_212245_3_, BlockPos p_212245_4_, NoFeatureConfig p_212245_5_)
{
int i = 0;
return i > 0;
}
for(int j = 0; j < 64; ++j)
{
BlockPos blockpos = p_212245_4_.add(p_212245_3_.nextInt(8) - p_212245_3_.nextInt(8), p_212245_3_.nextInt(4) - p_212245_3_.nextInt(4), p_212245_3_.nextInt(8) - p_212245_3_.nextInt(8));
if (p_212245_1_.getBlockState(blockpos).canBeReplacedByLeaves(p_212245_1_, blockpos) && p_212245_1_.getBlockState(blockpos.down()).getBlock() == Blocks.GRASS_BLOCK)
{
if (p_212245_3_.nextInt(3) == 0)
{
int rand = p_212245_3_.nextInt(50);
if (rand > 10)
{
p_212245_1_.setBlockState(blockpos, Blocks.PUMPKIN.getDefaultState(), 2);
}
else if (rand > 1)
{
p_212245_1_.setBlockState(blockpos, Blocks.CARVED_PUMPKIN.getDefaultState().with(CarvedPumpkinBlock.FACING, Direction.byIndex(2 + p_212245_3_.nextInt(4))), 2);
}
else
{
p_212245_1_.setBlockState(blockpos, Blocks.JACK_O_LANTERN.getDefaultState().with(CarvedPumpkinBlock.FACING, Direction.byIndex(2 + p_212245_3_.nextInt(4))), 2);
}
}
else
{
p_212245_1_.setBlockState(blockpos, Blocks.OAK_LEAVES.getDefaultState().with(LeavesBlock.PERSISTENT, true), 2);
}
++i;
}
}
return i > 0;
}
}

View File

@ -7,25 +7,34 @@
******************************************************************************/
package biomesoplenty.common.world.gen.feature;
import java.util.Random;
import biomesoplenty.api.block.BOPBlocks;
import com.mojang.datafixers.Dynamic;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper;
import net.minecraft.world.biome.Biome;
import net.minecraft.world.gen.feature.AbstractFlowersFeature;
import net.minecraft.world.gen.feature.FlowersFeature;
import net.minecraft.world.gen.feature.NoFeatureConfig;
public class RainforestFlowersFeature extends AbstractFlowersFeature
import java.util.Random;
import java.util.function.Function;
public class RainforestFlowersFeature extends FlowersFeature
{
private static final Block[] FLOWERS = new Block[]{BOPBlocks.pink_daffodil, BOPBlocks.blue_hydrangea, Blocks.BLUE_ORCHID, Blocks.OXEYE_DAISY, Blocks.DANDELION, Blocks.POPPY};
private static final Block[] FLOWERS = new Block[]{BOPBlocks.pink_daffodil, BOPBlocks.blue_hydrangea, Blocks.BLUE_ORCHID, Blocks.OXEYE_DAISY, Blocks.DANDELION, Blocks.POPPY};
public BlockState getRandomFlower(Random p_202355_1_, BlockPos p_202355_2_)
{
double d0 = MathHelper.clamp((1.0D + Biome.INFO_NOISE.getValue((double)p_202355_2_.getX() / 48.0D, (double)p_202355_2_.getZ() / 48.0D)) / 2.0D, 0.0D, 0.9999D);
Block block = FLOWERS[(int)(d0 * (double)FLOWERS.length)];
return block.getDefaultState();
}
}
public RainforestFlowersFeature(Function<Dynamic<?>, ? extends NoFeatureConfig> deserializer)
{
super(deserializer);
}
@Override
public BlockState getRandomFlower(Random p_202355_1_, BlockPos p_202355_2_)
{
double d0 = MathHelper.clamp((1.0D + Biome.INFO_NOISE.getValue((double)p_202355_2_.getX() / 48.0D, (double)p_202355_2_.getZ() / 48.0D)) / 2.0D, 0.0D, 0.9999D);
Block block = FLOWERS[(int)(d0 * (double)FLOWERS.length)];
return block.getDefaultState();
}
}

View File

@ -1,19 +1,27 @@
package biomesoplenty.common.world.gen.feature;
import java.util.Random;
import net.minecraft.block.BlockLeaves;
import com.mojang.datafixers.Dynamic;
import net.minecraft.block.Blocks;
import net.minecraft.block.LeavesBlock;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IWorld;
import net.minecraft.world.gen.IChunkGenSettings;
import net.minecraft.world.gen.IChunkGenerator;
import net.minecraft.world.gen.ChunkGenerator;
import net.minecraft.world.gen.GenerationSettings;
import net.minecraft.world.gen.feature.Feature;
import net.minecraft.world.gen.feature.NoFeatureConfig;
import java.util.Random;
import java.util.function.Function;
public class ScrubFeature extends Feature<NoFeatureConfig>
{
public boolean place(IWorld p_212245_1_, IChunkGenerator<? extends IChunkGenSettings> p_212245_2_, Random p_212245_3_, BlockPos p_212245_4_, NoFeatureConfig p_212245_5_)
public ScrubFeature(Function<Dynamic<?>, ? extends NoFeatureConfig> deserializer)
{
super(deserializer);
}
@Override
public boolean place(IWorld p_212245_1_, ChunkGenerator<? extends GenerationSettings> p_212245_2_, Random p_212245_3_, BlockPos p_212245_4_, NoFeatureConfig p_212245_5_)
{
int i = 0;
@ -22,7 +30,7 @@ public class ScrubFeature extends Feature<NoFeatureConfig>
BlockPos blockpos = p_212245_4_.add(p_212245_3_.nextInt(8) - p_212245_3_.nextInt(8), p_212245_3_.nextInt(4) - p_212245_3_.nextInt(4), p_212245_3_.nextInt(8) - p_212245_3_.nextInt(8));
if (p_212245_1_.getBlockState(blockpos).canBeReplacedByLeaves(p_212245_1_, blockpos) && p_212245_1_.getBlockState(blockpos.down()).getBlock() == Blocks.GRASS_BLOCK)
{
p_212245_1_.setBlockState(blockpos, Blocks.OAK_LEAVES.getDefaultState().with(BlockLeaves.PERSISTENT, true), 2);
p_212245_1_.setBlockState(blockpos, Blocks.OAK_LEAVES.getDefaultState().with(LeavesBlock.PERSISTENT, true), 2);
++i;
}

View File

@ -7,24 +7,33 @@
******************************************************************************/
package biomesoplenty.common.world.gen.feature;
import java.util.Random;
import com.mojang.datafixers.Dynamic;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper;
import net.minecraft.world.biome.Biome;
import net.minecraft.world.gen.feature.AbstractFlowersFeature;
import net.minecraft.world.gen.feature.FlowersFeature;
import net.minecraft.world.gen.feature.NoFeatureConfig;
public class ShrublandFlowersFeature extends AbstractFlowersFeature
import java.util.Random;
import java.util.function.Function;
public class ShrublandFlowersFeature extends FlowersFeature
{
private static final Block[] FLOWERS = new Block[]{Blocks.ALLIUM};
private static final Block[] FLOWERS = new Block[]{Blocks.ALLIUM};
public BlockState getRandomFlower(Random p_202355_1_, BlockPos p_202355_2_)
{
double d0 = MathHelper.clamp((1.0D + Biome.INFO_NOISE.getValue((double)p_202355_2_.getX() / 48.0D, (double)p_202355_2_.getZ() / 48.0D)) / 2.0D, 0.0D, 0.9999D);
Block block = FLOWERS[(int)(d0 * (double)FLOWERS.length)];
return block.getDefaultState();
}
}
public ShrublandFlowersFeature(Function<Dynamic<?>, ? extends NoFeatureConfig> deserializer)
{
super(deserializer);
}
@Override
public BlockState getRandomFlower(Random p_202355_1_, BlockPos p_202355_2_)
{
double d0 = MathHelper.clamp((1.0D + Biome.INFO_NOISE.getValue((double)p_202355_2_.getX() / 48.0D, (double)p_202355_2_.getZ() / 48.0D)) / 2.0D, 0.0D, 0.9999D);
Block block = FLOWERS[(int)(d0 * (double)FLOWERS.length)];
return block.getDefaultState();
}
}

View File

@ -7,31 +7,37 @@
******************************************************************************/
package biomesoplenty.common.world.gen.feature;
import java.util.Random;
import biomesoplenty.api.block.BOPBlocks;
import net.minecraft.block.Block;
import com.mojang.datafixers.Dynamic;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper;
import net.minecraft.world.biome.Biome;
import net.minecraft.world.gen.feature.AbstractFlowersFeature;
import net.minecraft.world.gen.feature.FlowersFeature;
import net.minecraft.world.gen.feature.NoFeatureConfig;
public class SnowyFlowersFeature extends AbstractFlowersFeature
import java.util.Random;
import java.util.function.Function;
public class SnowyFlowersFeature extends FlowersFeature
{
public BlockState getRandomFlower(Random p_202355_1_, BlockPos p_202355_2_)
{
int j = p_202355_1_.nextInt(3);
switch(j)
{
case 0:
return BOPBlocks.violet.getDefaultState();
case 1:
return Blocks.POPPY.getDefaultState();
case 2:
default:
return Blocks.DANDELION.getDefaultState();
}
}
public SnowyFlowersFeature(Function<Dynamic<?>, ? extends NoFeatureConfig> deserializer)
{
super(deserializer);
}
@Override
public BlockState getRandomFlower(Random p_202355_1_, BlockPos p_202355_2_)
{
int j = p_202355_1_.nextInt(3);
switch(j)
{
case 0:
return BOPBlocks.violet.getDefaultState();
case 1:
return Blocks.POPPY.getDefaultState();
case 2:
default:
return Blocks.DANDELION.getDefaultState();
}
}
}

View File

@ -1,20 +1,33 @@
package biomesoplenty.common.world.gen.feature;
import com.google.common.collect.ImmutableMap;
import com.mojang.datafixers.Dynamic;
import com.mojang.datafixers.types.DynamicOps;
import net.minecraft.block.BlockState;
import net.minecraft.world.gen.feature.IFeatureConfig;
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.world.gen.feature.IFeatureConfig;
public class SplotchConfig implements IFeatureConfig
{
public final BlockState state;
public final int radius;
public final int ySize;
public final List<BlockState> targets;
public class SplotchConfig implements IFeatureConfig {
public final Block block;
public final int radius;
public final int ySize;
public final List<Block> targets;
public SplotchConfig(BlockState state, int radius, int ySize, List<BlockState> targets)
{
this.state = state;
this.radius = radius;
this.ySize = ySize;
this.targets = targets;
}
public SplotchConfig(Block p_i48684_1_, int p_i48684_2_, int p_i48684_3_, List<Block> p_i48684_4_) {
this.block = p_i48684_1_;
this.radius = p_i48684_2_;
this.ySize = p_i48684_3_;
this.targets = p_i48684_4_;
}
}
@Override
public <T> Dynamic<T> serialize(DynamicOps<T> dynamicOps)
{
return new Dynamic<>(dynamicOps, dynamicOps.createMap(ImmutableMap.of(dynamicOps.createString("state"), BlockState.serialize(dynamicOps, this.state).getValue(), dynamicOps.createString("radius"), dynamicOps.createInt(this.radius), dynamicOps.createString("y_size"), dynamicOps.createInt(this.ySize), dynamicOps.createString("targets"), dynamicOps.createList(this.targets.stream().map((p_214692_1_) -> {
return BlockState.serialize(dynamicOps, p_214692_1_).getValue();
})))));
}
}

View File

@ -1,58 +1,66 @@
package biomesoplenty.common.world.gen.feature;
import java.util.Random;
import com.mojang.datafixers.Dynamic;
import net.minecraft.block.Block;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IWorld;
import net.minecraft.world.gen.IChunkGenSettings;
import net.minecraft.world.gen.IChunkGenerator;
import net.minecraft.world.gen.ChunkGenerator;
import net.minecraft.world.gen.GenerationSettings;
import net.minecraft.world.gen.feature.Feature;
import java.util.Random;
import java.util.function.Function;
public class SplotchFeature extends Feature<SplotchConfig>
{
public boolean place(IWorld p_212245_1_, IChunkGenerator<? extends IChunkGenSettings> p_212245_2_, Random p_212245_3_, BlockPos p_212245_4_, SplotchConfig p_212245_5_)
public SplotchFeature(Function<Dynamic<?>, ? extends SplotchConfig> deserializer)
{
int i = 0;
int j = p_212245_3_.nextInt(p_212245_5_.radius - 2) + 2;
super(deserializer);
}
for(int k = p_212245_4_.getX() - j; k <= p_212245_4_.getX() + j; ++k) {
for(int l = p_212245_4_.getZ() - j; l <= p_212245_4_.getZ() + j; ++l) {
int i1 = k - p_212245_4_.getX();
int j1 = l - p_212245_4_.getZ();
if (i1 * i1 + j1 * j1 <= j * j) {
for(int k1 = p_212245_4_.getY() - p_212245_5_.ySize; k1 <= p_212245_4_.getY() + p_212245_5_.ySize; ++k1) {
BlockPos blockpos = new BlockPos(k, k1, l);
BlockPos blockpos1 = blockpos.north();
BlockPos blockpos2 = blockpos.south();
BlockPos blockpos3 = blockpos.east();
BlockPos blockpos4 = blockpos.west();
BlockPos blockpos5 = blockpos.north().east();
BlockPos blockpos6 = blockpos.south().east();
BlockPos blockpos7 = blockpos.north().west();
BlockPos blockpos8 = blockpos.south().west();
BlockPos blockpos9 = blockpos.down();
Block block = p_212245_1_.getBlockState(blockpos).getBlock();
Block block1 = p_212245_1_.getBlockState(blockpos1).getBlock();
Block block2 = p_212245_1_.getBlockState(blockpos2).getBlock();
Block block3 = p_212245_1_.getBlockState(blockpos3).getBlock();
Block block4 = p_212245_1_.getBlockState(blockpos4).getBlock();
Block block5 = p_212245_1_.getBlockState(blockpos5).getBlock();
Block block6 = p_212245_1_.getBlockState(blockpos6).getBlock();
Block block7 = p_212245_1_.getBlockState(blockpos7).getBlock();
Block block8 = p_212245_1_.getBlockState(blockpos8).getBlock();
Block block9 = p_212245_1_.getBlockState(blockpos9).getBlock();
if (p_212245_5_.targets.contains(block) && p_212245_5_.targets.contains(block1) && p_212245_5_.targets.contains(block2) && p_212245_5_.targets.contains(block3) && p_212245_5_.targets.contains(block4) && p_212245_5_.targets.contains(block5) && p_212245_5_.targets.contains(block6) && p_212245_5_.targets.contains(block7) && p_212245_5_.targets.contains(block8) && p_212245_5_.targets.contains(block9))
{
p_212245_1_.setBlockState(blockpos, p_212245_5_.block.getDefaultState(), 2);
++i;
}
}
}
}
}
@Override
public boolean place(IWorld p_212245_1_, ChunkGenerator<? extends GenerationSettings> p_212245_2_, Random p_212245_3_, BlockPos p_212245_4_, SplotchConfig p_212245_5_)
{
int i = 0;
int j = p_212245_3_.nextInt(p_212245_5_.radius - 2) + 2;
return i > 0;
for(int k = p_212245_4_.getX() - j; k <= p_212245_4_.getX() + j; ++k) {
for(int l = p_212245_4_.getZ() - j; l <= p_212245_4_.getZ() + j; ++l) {
int i1 = k - p_212245_4_.getX();
int j1 = l - p_212245_4_.getZ();
if (i1 * i1 + j1 * j1 <= j * j) {
for(int k1 = p_212245_4_.getY() - p_212245_5_.ySize; k1 <= p_212245_4_.getY() + p_212245_5_.ySize; ++k1) {
BlockPos blockpos = new BlockPos(k, k1, l);
BlockPos blockpos1 = blockpos.north();
BlockPos blockpos2 = blockpos.south();
BlockPos blockpos3 = blockpos.east();
BlockPos blockpos4 = blockpos.west();
BlockPos blockpos5 = blockpos.north().east();
BlockPos blockpos6 = blockpos.south().east();
BlockPos blockpos7 = blockpos.north().west();
BlockPos blockpos8 = blockpos.south().west();
BlockPos blockpos9 = blockpos.down();
Block block = p_212245_1_.getBlockState(blockpos).getBlock();
Block block1 = p_212245_1_.getBlockState(blockpos1).getBlock();
Block block2 = p_212245_1_.getBlockState(blockpos2).getBlock();
Block block3 = p_212245_1_.getBlockState(blockpos3).getBlock();
Block block4 = p_212245_1_.getBlockState(blockpos4).getBlock();
Block block5 = p_212245_1_.getBlockState(blockpos5).getBlock();
Block block6 = p_212245_1_.getBlockState(blockpos6).getBlock();
Block block7 = p_212245_1_.getBlockState(blockpos7).getBlock();
Block block8 = p_212245_1_.getBlockState(blockpos8).getBlock();
Block block9 = p_212245_1_.getBlockState(blockpos9).getBlock();
if (p_212245_5_.targets.contains(block) && p_212245_5_.targets.contains(block1) && p_212245_5_.targets.contains(block2) && p_212245_5_.targets.contains(block3) && p_212245_5_.targets.contains(block4) && p_212245_5_.targets.contains(block5) && p_212245_5_.targets.contains(block6) && p_212245_5_.targets.contains(block7) && p_212245_5_.targets.contains(block8) && p_212245_5_.targets.contains(block9))
{
p_212245_1_.setBlockState(blockpos, p_212245_5_.state, 2);
++i;
}
}
}
}
}
return i > 0;
}
}

View File

@ -7,47 +7,54 @@
******************************************************************************/
package biomesoplenty.common.world.gen.feature;
import java.util.Random;
import com.mojang.datafixers.Dynamic;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.tags.BlockTags;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IWorld;
import net.minecraft.world.gen.IChunkGenSettings;
import net.minecraft.world.gen.IChunkGenerator;
import net.minecraft.world.gen.ChunkGenerator;
import net.minecraft.world.gen.GenerationSettings;
import net.minecraft.world.gen.feature.Feature;
import net.minecraft.world.gen.feature.NoFeatureConfig;
import java.util.Random;
import java.util.function.Function;
public class StandardGrassFeature extends Feature<NoFeatureConfig>
{
public BlockState chooseGrassState(Random rand)
{
return Blocks.GRASS.getDefaultState();
}
public StandardGrassFeature(Function<Dynamic<?>, ? extends NoFeatureConfig> deserializer)
{
super(deserializer);
}
@Override
public boolean place(IWorld world, IChunkGenerator<? extends IChunkGenSettings> generator, Random rand, BlockPos pos, NoFeatureConfig config)
{
BlockState BlockState = this.chooseGrassState(rand);
public BlockState chooseGrassState(Random rand)
{
return Blocks.GRASS.getDefaultState();
}
for (BlockState BlockState1 = world.getBlockState(pos); (BlockState1.isAir(world, pos) || BlockState1.isIn(BlockTags.LEAVES)) && pos.getY() > 0; BlockState1 = world.getBlockState(pos))
{
pos = pos.down();
}
@Override
public boolean place(IWorld world, ChunkGenerator<? extends GenerationSettings> generator, Random rand, BlockPos pos, NoFeatureConfig config)
{
BlockState BlockState = this.chooseGrassState(rand);
int i = 0;
for (BlockState BlockState1 = world.getBlockState(pos); (BlockState1.isAir(world, pos) || BlockState1.isIn(BlockTags.LEAVES)) && pos.getY() > 0; BlockState1 = world.getBlockState(pos))
{
pos = pos.down();
}
for (int j = 0; j < 128; ++j)
{
BlockPos blockpos = pos.add(rand.nextInt(8) - rand.nextInt(8), rand.nextInt(4) - rand.nextInt(4), rand.nextInt(8) - rand.nextInt(8));
if (world.isAirBlock(blockpos) && BlockState.isValidPosition(world, blockpos))
{
world.setBlockState(blockpos, BlockState, 2);
++i;
}
}
int i = 0;
return i > 0;
}
}
for (int j = 0; j < 128; ++j)
{
BlockPos blockpos = pos.add(rand.nextInt(8) - rand.nextInt(8), rand.nextInt(4) - rand.nextInt(4), rand.nextInt(8) - rand.nextInt(8));
if (world.isAirBlock(blockpos) && BlockState.isValidPosition(world, blockpos))
{
world.setBlockState(blockpos, BlockState, 2);
++i;
}
}
return i > 0;
}
}

View File

@ -7,25 +7,34 @@
******************************************************************************/
package biomesoplenty.common.world.gen.feature;
import java.util.Random;
import biomesoplenty.api.block.BOPBlocks;
import com.mojang.datafixers.Dynamic;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper;
import net.minecraft.world.biome.Biome;
import net.minecraft.world.gen.feature.AbstractFlowersFeature;
import net.minecraft.world.gen.feature.FlowersFeature;
import net.minecraft.world.gen.feature.NoFeatureConfig;
public class TropicsFlowersFeature extends AbstractFlowersFeature
import java.util.Random;
import java.util.function.Function;
public class TropicsFlowersFeature extends FlowersFeature
{
private static final Block[] FLOWERS = new Block[]{BOPBlocks.pink_hibiscus, BOPBlocks.blue_hydrangea, Blocks.DANDELION, Blocks.POPPY};
private static final Block[] FLOWERS = new Block[]{BOPBlocks.pink_hibiscus, BOPBlocks.blue_hydrangea, Blocks.DANDELION, Blocks.POPPY};
public BlockState getRandomFlower(Random p_202355_1_, BlockPos p_202355_2_)
{
double d0 = MathHelper.clamp((1.0D + Biome.INFO_NOISE.getValue((double)p_202355_2_.getX() / 48.0D, (double)p_202355_2_.getZ() / 48.0D)) / 2.0D, 0.0D, 0.9999D);
Block block = FLOWERS[(int)(d0 * (double)FLOWERS.length)];
return block.getDefaultState();
}
}
public TropicsFlowersFeature(Function<Dynamic<?>, ? extends NoFeatureConfig> deserializer)
{
super(deserializer);
}
@Override
public BlockState getRandomFlower(Random p_202355_1_, BlockPos p_202355_2_)
{
double d0 = MathHelper.clamp((1.0D + Biome.INFO_NOISE.getValue((double)p_202355_2_.getX() / 48.0D, (double)p_202355_2_.getZ() / 48.0D)) / 2.0D, 0.0D, 0.9999D);
Block block = FLOWERS[(int)(d0 * (double)FLOWERS.length)];
return block.getDefaultState();
}
}

View File

@ -11,16 +11,16 @@ import java.util.Random;
import java.util.Set;
import biomesoplenty.common.util.block.IBlockPosQuery;
import net.minecraft.block.Block;
import net.minecraft.block.*;
import net.minecraft.block.BlockCocoa;
import net.minecraft.block.BlockSapling;
import net.minecraft.block.BlockVine;
import net.minecraft.block.material.Material;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.util.Direction;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MutableBoundingBox;
import net.minecraft.world.IWorld;
import net.minecraft.world.gen.IWorldGenerationReader;
public class BasicTreeFeature extends TreeFeatureBase
{
@ -289,7 +289,7 @@ public class BasicTreeFeature extends TreeFeatureBase
}
}
protected void generateTrunk(Set<BlockPos> changedBlocks, IWorld world, BlockPos start, int height)
protected void generateTrunk(Set<BlockPos> changedBlocks, MutableBoundingBox boundingBox, IWorld world, BlockPos start, int height)
{
//Create the trunk from the bottom up, using < to ensure it is covered with one layer of leaves
for (int layer = 0; layer < height; ++layer)
@ -297,7 +297,7 @@ public class BasicTreeFeature extends TreeFeatureBase
BlockPos blockpos2 = start.up(layer);
if (this.replace.matches(world, blockpos2))
{
this.setLog(changedBlocks, world, start.up(layer));
this.setLog(changedBlocks, world, start.up(layer), boundingBox);
}
}
}
@ -325,17 +325,17 @@ public class BasicTreeFeature extends TreeFeatureBase
{
if (this.trunkFruit == Blocks.COCOA.getDefaultState())
{
this.setBlockState(world, pos, this.trunkFruit.with(BlockCocoa.AGE, Integer.valueOf(age)).with(BlockCocoa.HORIZONTAL_FACING, direction));
this.setBlockState(world, pos, this.trunkFruit.with(CocoaBlock.AGE, Integer.valueOf(age)).with(CocoaBlock.HORIZONTAL_FACING, direction));
}
else
{
this.setBlockState(world, pos, this.trunkFruit.with(BlockCocoa.HORIZONTAL_FACING, direction));
this.setBlockState(world, pos, this.trunkFruit.with(CocoaBlock.HORIZONTAL_FACING, direction));
}
}
private BlockState getVineStateForSide(Direction side)
{
return this.vine.getBlock() instanceof BlockVine ? this.vine.with(BlockVine.getPropertyFor(side), Boolean.valueOf(true)) : this.vine;
return this.vine.getBlock() instanceof VineBlock ? this.vine.with(VineBlock.getPropertyFor(side), Boolean.valueOf(true)) : this.vine;
}
private void extendVines(IWorld world, BlockPos pos, Direction side)

View File

@ -7,20 +7,20 @@
******************************************************************************/
package biomesoplenty.common.world.gen.feature.tree;
import java.util.List;
import java.util.Random;
import java.util.Set;
import com.google.common.collect.Lists;
import biomesoplenty.common.util.block.IBlockPosQuery;
import net.minecraft.block.BlockSapling;
import com.google.common.collect.Lists;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.util.Direction;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.MutableBoundingBox;
import net.minecraft.world.IWorld;
import net.minecraft.world.gen.IWorldGenerationReader;
import java.util.List;
import java.util.Random;
import java.util.Set;
/*This class is heavily based on https://gist.github.com/grum/62cfdec0537e8db24eb3#file-bigtreefeature-java
additional information has been added from http://pastebin.com/XBLdGqXQ. This class has been cross-checked*/
@ -259,7 +259,7 @@ public class BigTreeFeature extends TreeFeatureBase
}
}
private void limb(Set<BlockPos> changedBlocks, BlockPos startPos, BlockPos endPos, BlockState state)
private void limb(Set<BlockPos> changedBlocks, MutableBoundingBox boundingBox, BlockPos startPos, BlockPos endPos, BlockState state)
{
// Create a limb from the start position to the end position.
// Used for creating the branches and trunk.
@ -285,7 +285,7 @@ public class BigTreeFeature extends TreeFeatureBase
BlockPos blockPos = startPos.add(.5f + i * dx, .5f + i * dy, .5f + i * dz);
Direction.Axis logAxis = getLogAxis(startPos, blockPos);
this.setLog(changedBlocks, this.world, blockPos, logAxis);
this.setLog(changedBlocks, this.world, blockPos, logAxis, boundingBox);
}
}
@ -362,39 +362,39 @@ public class BigTreeFeature extends TreeFeatureBase
return localY >= height * 0.2;
}
private void makeTrunk(Set<BlockPos> changedBlocks)
private void makeTrunk(Set<BlockPos> changedBlocks, MutableBoundingBox boundingBox)
{
// Create the trunk of the tree.
BlockPos start = origin;
BlockPos end = origin.up(trunkHeight);
BlockState materialState = this.log;
limb(changedBlocks, start, end, materialState);
limb(changedBlocks, boundingBox, start, end, materialState);
if (trunkWidth == 2)
{
limb(changedBlocks, start.east(), end.east(), materialState);
limb(changedBlocks, start.east().south(), end.east().south(), materialState);
limb(changedBlocks, start.south(), end.south(), materialState);
limb(changedBlocks, boundingBox, start.east(), end.east(), materialState);
limb(changedBlocks, boundingBox, start.east().south(), end.east().south(), materialState);
limb(changedBlocks, boundingBox, start.south(), end.south(), materialState);
}
if (trunkWidth == 4)
{
limb(changedBlocks, start.east(), end.east(), materialState);
limb(changedBlocks, start.east().south(), end.east().south(), materialState);
limb(changedBlocks, start.south(), end.south(), materialState);
limb(changedBlocks, start.north(), end.north(), materialState);
limb(changedBlocks, start.north().east(), end.north().east(), materialState);
limb(changedBlocks, start.east().east(), end.east().east(), materialState);
limb(changedBlocks, start.south().east().east(), end.south().east().east(), materialState);
limb(changedBlocks, start.south().south().east(), end.south().south().east(), materialState);
limb(changedBlocks, start.south().south(), end.south().south(), materialState);
limb(changedBlocks, start.west().south(), end.west().south(), materialState);
limb(changedBlocks, start.west(), end.west(), materialState);
limb(changedBlocks, boundingBox, start.east(), end.east(), materialState);
limb(changedBlocks, boundingBox, start.east().south(), end.east().south(), materialState);
limb(changedBlocks, boundingBox, start.south(), end.south(), materialState);
limb(changedBlocks, boundingBox, start.north(), end.north(), materialState);
limb(changedBlocks, boundingBox, start.north().east(), end.north().east(), materialState);
limb(changedBlocks, boundingBox, start.east().east(), end.east().east(), materialState);
limb(changedBlocks, boundingBox, start.south().east().east(), end.south().east().east(), materialState);
limb(changedBlocks, boundingBox, start.south().south().east(), end.south().south().east(), materialState);
limb(changedBlocks, boundingBox, start.south().south(), end.south().south(), materialState);
limb(changedBlocks, boundingBox, start.west().south(), end.west().south(), materialState);
limb(changedBlocks, boundingBox, start.west(), end.west(), materialState);
}
}
private void makeBranches(Set<BlockPos> changedBlocks)
private void makeBranches(Set<BlockPos> changedBlocks, MutableBoundingBox boundingBox)
{
for (FoliageCoords endCoord : foliageCoords)
{
@ -403,7 +403,7 @@ public class BigTreeFeature extends TreeFeatureBase
if (this.trimBranches(branchBase - this.origin.getY()))
{
this.limb(changedBlocks, baseCoord, endCoord, this.log);
this.limb(changedBlocks, boundingBox, baseCoord, endCoord, this.log);
}
}
}
@ -453,12 +453,10 @@ public class BigTreeFeature extends TreeFeatureBase
return -1;
}
@Override
protected boolean place(Set<BlockPos> changedBlocks, IWorld world, Random random, BlockPos startPos)
protected boolean place(Set<BlockPos> changedBlocks, IWorldGenerationReader world, Random random, BlockPos startPos, MutableBoundingBox boundingBox)
{
this.world = world;
this.world = (IWorld)world; // Fuck this bullshit, we want an IWorld
this.origin = startPos;
this.random = new Random(random.nextLong());
@ -474,8 +472,8 @@ public class BigTreeFeature extends TreeFeatureBase
try {
prepare();
makeFoliage();
makeTrunk(changedBlocks);
makeBranches(changedBlocks);
makeTrunk(changedBlocks, boundingBox);
makeBranches(changedBlocks, boundingBox);
} catch (RuntimeException e) {
// TODO: deal with this.
}

View File

@ -7,22 +7,24 @@
******************************************************************************/
package biomesoplenty.common.world.gen.feature.tree;
import java.util.Random;
import java.util.Set;
import biomesoplenty.common.util.block.BlockUtil;
import biomesoplenty.common.util.block.IBlockPosQuery;
import net.minecraft.block.BlockSapling;
import net.minecraft.block.BlockVine;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.block.SaplingBlock;
import net.minecraft.block.VineBlock;
import net.minecraft.state.IProperty;
import net.minecraft.util.Direction;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MutableBoundingBox;
import net.minecraft.world.IWorld;
import net.minecraft.world.gen.IWorldGenerationReader;
import net.minecraft.world.gen.feature.AbstractTreeFeature;
import net.minecraft.world.gen.feature.NoFeatureConfig;
import java.util.Random;
import java.util.Set;
public abstract class TreeFeatureBase extends AbstractTreeFeature<NoFeatureConfig>
{
protected static abstract class BuilderBase<T extends BuilderBase, F extends TreeFeatureBase>
@ -41,7 +43,7 @@ public abstract class TreeFeatureBase extends AbstractTreeFeature<NoFeatureConfi
public BuilderBase()
{
this.placeOn = (world, pos) -> world.getBlockState(pos).canSustainPlant(world, pos, Direction.UP, (BlockSapling)Blocks.OAK_SAPLING);
this.placeOn = (world, pos) -> world.getBlockState(pos).canSustainPlant(world, pos, Direction.UP, (SaplingBlock)Blocks.OAK_SAPLING);
this.replace = (world, pos) -> world.getBlockState(pos).canBeReplacedByLeaves(world, pos);
this.log = Blocks.OAK_LOG.getDefaultState();
this.leaves = Blocks.OAK_LEAVES.getDefaultState();
@ -103,7 +105,7 @@ public abstract class TreeFeatureBase extends AbstractTreeFeature<NoFeatureConfi
protected TreeFeatureBase(boolean notify, IBlockPosQuery placeOn, IBlockPosQuery replace, BlockState log, BlockState leaves, BlockState altLeaves, BlockState vine, BlockState hanging, BlockState trunkFruit, int minHeight, int maxHeight)
{
super(notify);
super(NoFeatureConfig::deserialize, notify);
this.placeOn = placeOn;
this.replace = replace;
@ -128,19 +130,19 @@ public abstract class TreeFeatureBase extends AbstractTreeFeature<NoFeatureConfi
return false;
}
public boolean setLog(Set<BlockPos> changedBlocks, IWorld world, BlockPos pos)
public boolean setLog(Set<BlockPos> changedBlocks, IWorld world, BlockPos pos, MutableBoundingBox boundingBox)
{
return this.setLog(changedBlocks, world, pos, null);
return this.setLog(changedBlocks, world, pos, null, boundingBox);
}
public boolean setLog(Set<BlockPos> changedBlocks, IWorld world, BlockPos pos, Direction.Axis axis)
public boolean setLog(Set<BlockPos> changedBlocks, IWorld world, BlockPos pos, Direction.Axis axis, MutableBoundingBox boundingBox)
{
BlockState directedLog = (axis != null && this.logAxisProperty != null) ? this.log.with(this.logAxisProperty, axis) : this.log;
if (this.replace.matches(world, pos))
{
// Logs must be added to the "changedBlocks" so that the leaves have their distance property updated,
// preventing incorrect decay
this.setLogState(changedBlocks, world, pos, directedLog);
this.func_208520_a(changedBlocks, world, pos, directedLog, boundingBox);
return true;
}
return false;
@ -148,7 +150,7 @@ public abstract class TreeFeatureBase extends AbstractTreeFeature<NoFeatureConfi
public boolean setVine(IWorld world, Random rand, BlockPos pos, Direction side, int length)
{
BlockState vineState = this.vine.getBlock() instanceof BlockVine ? this.vine.with(BlockVine.NORTH, Boolean.valueOf(side == Direction.NORTH)).with(BlockVine.EAST, Boolean.valueOf(side == Direction.EAST)).with(BlockVine.SOUTH, Boolean.valueOf(side == Direction.SOUTH)).with(BlockVine.WEST, Boolean.valueOf(side == Direction.WEST)) : this.vine;
BlockState vineState = this.vine.getBlock() instanceof VineBlock ? this.vine.with(VineBlock.NORTH, Boolean.valueOf(side == Direction.NORTH)).with(VineBlock.EAST, Boolean.valueOf(side == Direction.EAST)).with(VineBlock.SOUTH, Boolean.valueOf(side == Direction.SOUTH)).with(VineBlock.WEST, Boolean.valueOf(side == Direction.WEST)) : this.vine;
boolean setOne = false;
while (world.getBlockState(pos).getBlock().isAir(world.getBlockState(pos), world, pos) && length > 0 && rand.nextInt(12) > 0)
{
@ -188,4 +190,15 @@ public abstract class TreeFeatureBase extends AbstractTreeFeature<NoFeatureConfi
}
return false;
}
@Override
protected boolean place(Set<BlockPos> changedBlocks, IWorldGenerationReader world, Random rand, BlockPos position, MutableBoundingBox boundingBox)
{
return place(changedBlocks, world, rand, position, boundingBox);
}
protected boolean place(Set<BlockPos> changedBlocks, IWorld world, Random rand, BlockPos position, MutableBoundingBox boundingBox)
{
return false;
}
}

View File

@ -15,11 +15,11 @@ import net.minecraft.client.Minecraft;
import net.minecraft.client.particle.Particle;
import net.minecraft.client.renderer.color.BlockColors;
import net.minecraft.client.renderer.color.ItemColors;
import net.minecraft.init.Particles;
import net.minecraft.item.BlockItem;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.particles.ItemParticleData;
import net.minecraft.particles.ParticleTypes;
import net.minecraft.util.math.MathHelper;
import net.minecraft.world.FoliageColors;
import net.minecraft.world.GrassColors;
@ -52,7 +52,7 @@ public class ClientProxy extends CommonProxy
//Item Coloring
itemColors.register((stack, tintIndex) -> {
BlockState BlockState = ((ItemBlock)stack.getItem()).getBlock().getDefaultState();
BlockState BlockState = ((BlockItem)stack.getItem()).getBlock().getDefaultState();
return blockColors.getColor(BlockState, null, null, tintIndex); },
BOPBlocks.bush, BOPBlocks.flowering_oak_leaves, BOPBlocks.mahogany_leaves,
BOPBlocks.palm_leaves, BOPBlocks.willow_leaves, BOPBlocks.willow_vine);
@ -67,7 +67,7 @@ public class ClientProxy extends CommonProxy
{
case MUD:
int itemId = Item.getIdFromItem(BOPItems.mudball);
minecraft.world.addParticle(new ItemParticleData(Particles.ITEM, new ItemStack(BOPItems.mudball)), x, y, z, MathHelper.nextDouble(parWorld.rand, -0.08D, 0.08D), MathHelper.nextDouble(parWorld.rand, -0.08D, 0.08D), MathHelper.nextDouble(parWorld.rand, -0.08D, 0.08D));
minecraft.world.addParticle(new ItemParticleData(ParticleTypes.ITEM, new ItemStack(BOPItems.mudball)), x, y, z, MathHelper.nextDouble(parWorld.rand, -0.08D, 0.08D), MathHelper.nextDouble(parWorld.rand, -0.08D, 0.08D), MathHelper.nextDouble(parWorld.rand, -0.08D, 0.08D));
return;
/*case PLAYER_TRAIL:
if (info.length < 1)

View File

@ -7,38 +7,35 @@
******************************************************************************/
package biomesoplenty.init;
import static biomesoplenty.api.entity.BOPEntities.boat_bop;
import static biomesoplenty.api.entity.BOPEntities.mudball;
import java.util.function.Function;
import biomesoplenty.api.item.BOPItems;
import biomesoplenty.common.entity.item.EntityBoatBOP;
import biomesoplenty.common.entity.item.RenderBoatBOP;
import biomesoplenty.common.entity.projectile.EntityMudball;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.entity.RenderSprite;
import net.minecraft.client.renderer.entity.SpriteRenderer;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityClassification;
import net.minecraft.entity.EntityType;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.fml.client.registry.RenderingRegistry;
import net.minecraftforge.registries.ForgeRegistries;
import static biomesoplenty.api.entity.BOPEntities.boat_bop;
import static biomesoplenty.api.entity.BOPEntities.mudball;
public class ModEntities
{
public static void init()
{
mudball = createEntity(EntityMudball.class, EntityMudball::new, "mudball", 64, 10, true);
boat_bop = createEntity(EntityBoatBOP.class, EntityBoatBOP::new, "boat_bop", 80, 3, true);
mudball = createEntity(EntityMudball::new, EntityClassification.MISC, "mudball", 64, 10, true);
boat_bop = createEntity(EntityBoatBOP::new, EntityClassification.MISC, "boat_bop", 80, 3, true);
}
public static <T extends Entity> EntityType<T> createEntity(Class<T> entityClass, Function<? super World, T> entityInstance, String name, int trackingRange, int updateFrequency, boolean sendsVelocityUpdates)
public static <T extends Entity> EntityType<T> createEntity(EntityType.IFactory<T> factory, EntityClassification classification, String name, int trackingRange, int updateFrequency, boolean sendsVelocityUpdates)
{
ResourceLocation location = new ResourceLocation("biomesoplenty", name);
EntityType<T> type = EntityType.Builder.<T>create(entityClass, entityInstance).tracker(trackingRange, updateFrequency, sendsVelocityUpdates).build(location.toString());
EntityType<T> type = EntityType.Builder.create(factory, classification).setTrackingRange(trackingRange).setUpdateInterval(updateFrequency).setShouldReceiveVelocityUpdates(sendsVelocityUpdates).build(location.toString());
type.setRegistryName(name);
ForgeRegistries.ENTITIES.register(type);
return type;
@ -47,7 +44,7 @@ public class ModEntities
@OnlyIn(Dist.CLIENT)
public static void registerRendering()
{
RenderingRegistry.registerEntityRenderingHandler(EntityMudball.class, manager -> new RenderSprite<>(manager, BOPItems.mudball, Minecraft.getInstance().getItemRenderer()));
RenderingRegistry.registerEntityRenderingHandler(EntityMudball.class, manager -> new SpriteRenderer<>(manager, Minecraft.getInstance().getItemRenderer()));
RenderingRegistry.registerEntityRenderingHandler(EntityBoatBOP.class, manager -> new RenderBoatBOP(manager));
}
}