added grassy netherrack generation

This commit is contained in:
Ellpeck 2020-02-26 19:32:42 +01:00
parent cf1302e5dd
commit 3c6f350f4c
19 changed files with 278 additions and 9 deletions

View file

@ -0,0 +1,7 @@
{
"variants": {
"": {
"model": "naturesaura:block/nether_grass"
}
}
}

View file

@ -0,0 +1,8 @@
{
"parent": "block/cube_bottom_top",
"textures": {
"side": "naturesaura:block/nether_grass",
"bottom": "block/netherrack",
"top": "naturesaura:block/nether_grass_top"
}
}

View file

@ -0,0 +1,3 @@
{
"parent": "naturesaura:block/nether_grass"
}

View file

@ -0,0 +1,6 @@
{
"replace": false,
"values": [
"naturesaura:nether_grass"
]
}

View file

@ -0,0 +1,38 @@
{
"type": "minecraft:block",
"pools": [
{
"rolls": 1,
"entries": [
{
"type": "minecraft:alternatives",
"children": [
{
"type": "minecraft:item",
"conditions": [
{
"condition": "minecraft:match_tool",
"predicate": {
"enchantments": [
{
"enchantment": "minecraft:silk_touch",
"levels": {
"min": 1
}
}
]
}
}
],
"name": "naturesaura:nether_grass"
},
{
"type": "minecraft:item",
"name": "minecraft:netherrack"
}
]
}
]
}
]
}

View file

@ -127,15 +127,12 @@ public final class Helper {
public static void renderItemInGui(ItemStack stack, int x, int y, float scale) {
RenderSystem.pushMatrix();
GlStateManager.enableBlend();
GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
RenderHelper.setupGuiFlatDiffuseLighting();
GlStateManager.enableDepthTest();
RenderSystem.enableRescaleNormal();
RenderSystem.translatef(x, y, 0);
RenderSystem.scalef(scale, scale, scale);
Minecraft.getInstance().getItemRenderer().renderItemAndEffectIntoGUI(stack, 0, 0);
Minecraft.getInstance().getItemRenderer().renderItemOverlayIntoGUI(Minecraft.getInstance().fontRenderer, stack, 0, 0, null);
RenderHelper.disableStandardItemLighting();
RenderSystem.popMatrix();
}

View file

@ -39,6 +39,7 @@ public final class ModConfig {
public ForgeConfigSpec.ConfigValue<Boolean> animalEffect;
public ForgeConfigSpec.ConfigValue<Boolean> oreEffect;
public ForgeConfigSpec.ConfigValue<Boolean> auraBlooms;
public ForgeConfigSpec.ConfigValue<Boolean> netherGrassEffect;
public ForgeConfigSpec.ConfigValue<Double> particleAmount;
public ForgeConfigSpec.ConfigValue<Boolean> respectVanillaParticleSettings;
@ -124,6 +125,10 @@ public final class ModConfig {
.comment("If Aura Blooms and Aura Cacti should generate in the world")
.translation("config." + NaturesAura.MOD_ID + ".auraBlooms")
.define("auraBlooms", true);
this.netherGrassEffect = builder
.comment("If the Aura Imbalance effect of grass growing on netherrack if the Aura levels are high enough should occur")
.translation("config." + NaturesAura.MOD_ID + ".netherGrassEffect")
.define("netherGrassEffect", true);
builder.pop();
builder.push("client");

View file

@ -0,0 +1,84 @@
package de.ellpeck.naturesaura.blocks;
import de.ellpeck.naturesaura.data.BlockStateGenerator;
import de.ellpeck.naturesaura.reg.ICustomBlockState;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.block.IGrowable;
import net.minecraft.util.Direction;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockReader;
import net.minecraft.world.World;
import net.minecraft.world.server.ServerWorld;
import java.util.Random;
public class BlockNetherGrass extends BlockImpl implements ICustomBlockState, IGrowable {
public BlockNetherGrass() {
super("nether_grass", ModBlocks.prop(Blocks.NETHERRACK).tickRandomly());
}
@Override
public void randomTick(BlockState state, ServerWorld worldIn, BlockPos pos, Random random) {
BlockPos up = pos.up();
BlockState upState = worldIn.getBlockState(up);
if (upState.isSolidSide(worldIn, up, Direction.DOWN))
worldIn.setBlockState(pos, Blocks.NETHERRACK.getDefaultState());
}
@Override
public void generateCustomBlockState(BlockStateGenerator generator) {
generator.simpleBlock(this, generator.models().cubeBottomTop(this.getBaseName(),
generator.modLoc("block/" + this.getBaseName()),
generator.mcLoc("block/netherrack"),
generator.modLoc("block/" + this.getBaseName() + "_top")));
}
@Override
public boolean canGrow(IBlockReader worldIn, BlockPos pos, BlockState state, boolean isClient) {
return worldIn.getBlockState(pos.up()).isAir(worldIn, pos.up());
}
@Override
public boolean canUseBonemeal(World worldIn, Random rand, BlockPos pos, BlockState state) {
return true;
}
@Override
public void grow(ServerWorld world, Random rand, BlockPos pos, BlockState state) {
BlockPos blockpos = pos.up();
BlockState blockstate = Blocks.GRASS.getDefaultState();
for (int i = 0; i < 128; ++i) {
BlockPos blockpos1 = blockpos;
int j = 0;
while (true) {
if (j >= i / 16) {
BlockState blockstate2 = world.getBlockState(blockpos1);
if (blockstate2.getBlock() == blockstate.getBlock() && rand.nextInt(10) == 0) {
((IGrowable) blockstate.getBlock()).grow(world, rand, blockpos1, blockstate2);
}
if (!blockstate2.isAir()) {
break;
}
if (blockstate.isValidPosition(world, blockpos1)) {
world.setBlockState(blockpos1, blockstate, 3);
}
break;
}
blockpos1 = blockpos1.add(rand.nextInt(3) - 1, (rand.nextInt(3) - 1) * rand.nextInt(3) / 2, rand.nextInt(3) - 1);
if (world.getBlockState(blockpos1.down()).getBlock() != this || world.getBlockState(blockpos1).isCollisionShapeOpaque(world, blockpos1)) {
break;
}
++j;
}
}
}
}

View file

@ -66,6 +66,7 @@ public final class ModBlocks {
public static Block AURA_BLOOM;
public static Block AURA_CACTUS;
public static Block TAINTED_GOLD_BLOCK;
public static Block NETHER_GRASS;
public static Block.Properties prop(Material material, MaterialColor color) {
return Block.Properties.create(material, color);

View file

@ -15,10 +15,12 @@ public final class DrainSpotEffects {
NaturesAuraAPI.DRAIN_SPOT_EFFECTS.put(CacheRechargeEffect.NAME, CacheRechargeEffect::new);
NaturesAuraAPI.DRAIN_SPOT_EFFECTS.put(AnimalEffect.NAME, AnimalEffect::new);
NaturesAuraAPI.DRAIN_SPOT_EFFECTS.put(OreSpawnEffect.NAME, OreSpawnEffect::new);
NaturesAuraAPI.DRAIN_SPOT_EFFECTS.put(NetherGrassEffect.NAME, NetherGrassEffect::new);
NaturesAuraAPI.EFFECT_POWDERS.put(PlantBoostEffect.NAME, 0xc2f442);
NaturesAuraAPI.EFFECT_POWDERS.put(CacheRechargeEffect.NAME, 0x1fb0d1);
NaturesAuraAPI.EFFECT_POWDERS.put(AnimalEffect.NAME, 0xc842f4);
NaturesAuraAPI.EFFECT_POWDERS.put(OreSpawnEffect.NAME, 0x74edd8);
NaturesAuraAPI.EFFECT_POWDERS.put(NetherGrassEffect.NAME, 0xe05226);
}
}

View file

@ -72,6 +72,8 @@ public class GrassDieEffect implements IDrainSpotEffect {
newState = Blocks.COARSE_DIRT.getDefaultState();
} else if (block instanceof BushBlock) {
newState = Blocks.AIR.getDefaultState();
} else if (block == ModBlocks.NETHER_GRASS) {
newState = Blocks.NETHERRACK.getDefaultState();
}
if (newState != null)
world.setBlockState(grassPos, newState);
@ -81,7 +83,7 @@ public class GrassDieEffect implements IDrainSpotEffect {
@Override
public boolean appliesHere(Chunk chunk, IAuraChunk auraChunk, IAuraType type) {
return ModConfig.instance.grassDieEffect.get() && type.isSimilar(NaturesAuraAPI.TYPE_OVERWORLD);
return ModConfig.instance.grassDieEffect.get() && (type.isSimilar(NaturesAuraAPI.TYPE_OVERWORLD) || type.isSimilar(NaturesAuraAPI.TYPE_NETHER));
}
@Override

View file

@ -0,0 +1,104 @@
package de.ellpeck.naturesaura.chunk.effect;
import de.ellpeck.naturesaura.ModConfig;
import de.ellpeck.naturesaura.NaturesAura;
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk;
import de.ellpeck.naturesaura.api.aura.chunk.IDrainSpotEffect;
import de.ellpeck.naturesaura.api.aura.type.IAuraType;
import de.ellpeck.naturesaura.blocks.ModBlocks;
import de.ellpeck.naturesaura.packet.PacketHandler;
import de.ellpeck.naturesaura.packet.PacketParticles;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.util.Direction;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper;
import net.minecraft.world.World;
import net.minecraft.world.chunk.Chunk;
import net.minecraftforge.common.Tags;
public class NetherGrassEffect implements IDrainSpotEffect {
public static final ResourceLocation NAME = new ResourceLocation(NaturesAura.MOD_ID, "nether_grass");
private int amount;
private int dist;
private boolean calcValues(World world, BlockPos pos, Integer spot) {
if (spot <= 0)
return false;
int aura = IAuraChunk.getAuraInArea(world, pos, 30);
if (aura < 1500000)
return false;
this.amount = Math.min(20, MathHelper.ceil(Math.abs(aura) / 100000F / IAuraChunk.getSpotAmountInArea(world, pos, 30)));
if (this.amount <= 1)
return false;
this.dist = MathHelper.clamp(Math.abs(aura) / 100000, 5, 35);
return true;
}
@Override
public ActiveType isActiveHere(PlayerEntity player, Chunk chunk, IAuraChunk auraChunk, BlockPos pos, Integer spot) {
if (!this.calcValues(player.world, pos, spot))
return ActiveType.INACTIVE;
if (player.getDistanceSq(pos.getX(), pos.getY(), pos.getZ()) > this.dist * this.dist)
return ActiveType.INACTIVE;
if (NaturesAuraAPI.instance().isEffectPowderActive(player.world, player.getPosition(), NAME))
return ActiveType.INHIBITED;
return ActiveType.ACTIVE;
}
@Override
public ItemStack getDisplayIcon() {
return new ItemStack(ModBlocks.NETHER_GRASS);
}
@Override
public void update(World world, Chunk chunk, IAuraChunk auraChunk, BlockPos pos, Integer spot) {
if (!this.calcValues(world, pos, spot))
return;
for (int i = this.amount / 2 + world.rand.nextInt(this.amount / 2); i >= 0; i--) {
int x = MathHelper.floor(pos.getX() + world.rand.nextGaussian() * this.dist);
int y = MathHelper.floor(pos.getY() + world.rand.nextGaussian() * this.dist);
int z = MathHelper.floor(pos.getZ() + world.rand.nextGaussian() * this.dist);
for (int yOff = -5; yOff <= 5; yOff++) {
BlockPos goalPos = new BlockPos(x, y + yOff, z);
if (goalPos.distanceSq(pos) <= this.dist * this.dist && world.isBlockLoaded(goalPos)) {
if (NaturesAuraAPI.instance().isEffectPowderActive(world, goalPos, NAME))
continue;
BlockPos up = goalPos.up();
if (world.getBlockState(up).isSolidSide(world, up, Direction.DOWN))
continue;
BlockState state = world.getBlockState(goalPos);
Block block = state.getBlock();
if (Tags.Blocks.NETHERRACK.contains(block)) {
world.setBlockState(goalPos, ModBlocks.NETHER_GRASS.getDefaultState());
BlockPos closestSpot = IAuraChunk.getHighestSpot(world, goalPos, 25, pos);
IAuraChunk.getAuraChunk(world, closestSpot).drainAura(closestSpot, 500);
PacketHandler.sendToAllAround(world, goalPos, 32,
new PacketParticles(goalPos.getX(), goalPos.getY() + 0.5F, goalPos.getZ(), PacketParticles.Type.PLANT_BOOST));
break;
}
}
}
}
}
@Override
public boolean appliesHere(Chunk chunk, IAuraChunk auraChunk, IAuraType type) {
return ModConfig.instance.netherGrassEffect.get() && type.isSimilar(NaturesAuraAPI.TYPE_NETHER);
}
@Override
public ResourceLocation getName() {
return NAME;
}
}

View file

@ -11,6 +11,7 @@ import de.ellpeck.naturesaura.reg.IModItem;
import de.ellpeck.naturesaura.reg.ModRegistry;
import net.minecraft.advancements.criterion.StatePropertiesPredicate;
import net.minecraft.block.Block;
import net.minecraft.block.Blocks;
import net.minecraft.block.FlowerPotBlock;
import net.minecraft.data.DataGenerator;
import net.minecraft.data.DirectoryCache;
@ -55,6 +56,7 @@ public class BlockLootProvider implements IDataProvider {
this.lootFunctions.put(ModBlocks.DECAYED_LEAVES, LootTableHooks::genSilkOnly);
this.lootFunctions.put(ModBlocks.GOLDEN_LEAVES, b -> LootTable.builder().addLootPool(LootPool.builder().rolls(ConstantRange.of(1)).addEntry(LootTableHooks.survivesExplosion(b, ItemLootEntry.builder(ModItems.GOLD_LEAF)).acceptCondition(BlockStateProperty.builder(b).fromProperties(StatePropertiesPredicate.Builder.newBuilder().withIntProp(BlockGoldenLeaves.STAGE, BlockGoldenLeaves.HIGHEST_STAGE)))).acceptCondition(RandomChance.builder(0.75F))));
this.lootFunctions.put(ModBlocks.NETHER_WART_MUSHROOM, b -> LootTableHooks.genSilkOr(b, ItemLootEntry.builder(Items.NETHER_WART).acceptFunction(SetCount.builder(RandomValueRange.of(1, 2)))));
this.lootFunctions.put(ModBlocks.NETHER_GRASS, b -> LootTableHooks.genSilkOr(b, ItemLootEntry.builder(Blocks.NETHERRACK)));
}
private static Path getPath(Path root, ResourceLocation res) {

View file

@ -4,6 +4,7 @@ import de.ellpeck.naturesaura.blocks.ModBlocks;
import net.minecraft.data.BlockTagsProvider;
import net.minecraft.data.DataGenerator;
import net.minecraft.tags.BlockTags;
import net.minecraftforge.common.Tags;
public class BlockTagProvider extends BlockTagsProvider {
public BlockTagProvider(DataGenerator generatorIn) {
@ -18,5 +19,6 @@ public class BlockTagProvider extends BlockTagsProvider {
this.getBuilder(BlockTags.LEAVES).add(ModBlocks.GOLDEN_LEAVES, ModBlocks.ANCIENT_LEAVES, ModBlocks.DECAYED_LEAVES);
this.getBuilder(BlockTags.RAILS).add(ModBlocks.DIMENSION_RAIL_END, ModBlocks.DIMENSION_RAIL_NETHER, ModBlocks.DIMENSION_RAIL_OVERWORLD);
this.getBuilder(BlockTags.SLABS).add(ModBlocks.ANCIENT_SLAB, ModBlocks.INFUSED_SLAB, ModBlocks.INFUSED_BRICK_SLAB);
this.getBuilder(Tags.Blocks.DIRT).add(ModBlocks.NETHER_GRASS);
}
}

View file

@ -6,10 +6,7 @@ import de.ellpeck.naturesaura.api.recipes.*;
import de.ellpeck.naturesaura.api.recipes.ing.AmountIngredient;
import de.ellpeck.naturesaura.api.recipes.ing.NBTIngredient;
import de.ellpeck.naturesaura.blocks.ModBlocks;
import de.ellpeck.naturesaura.chunk.effect.AnimalEffect;
import de.ellpeck.naturesaura.chunk.effect.CacheRechargeEffect;
import de.ellpeck.naturesaura.chunk.effect.OreSpawnEffect;
import de.ellpeck.naturesaura.chunk.effect.PlantBoostEffect;
import de.ellpeck.naturesaura.chunk.effect.*;
import de.ellpeck.naturesaura.items.ItemAuraBottle;
import de.ellpeck.naturesaura.items.ItemEffectPowder;
import de.ellpeck.naturesaura.items.ModItems;
@ -122,6 +119,13 @@ public final class ModRecipes {
ing(ModBlocks.GOLD_POWDER),
ing(Blocks.DIAMOND_ORE),
ing(Blocks.REDSTONE_ORE)).register();
new TreeRitualRecipe(res("nether_grass_powder"),
ing(Blocks.OAK_SAPLING),
ItemEffectPowder.setEffect(new ItemStack(ModItems.EFFECT_POWDER, 4), NetherGrassEffect.NAME), 400,
ing(ModBlocks.GOLD_POWDER),
ing(ModBlocks.GOLD_POWDER),
ing(Blocks.NETHERRACK),
ing(Blocks.GRASS)).register();
new TreeRitualRecipe(res("token_joy"),
ing(Blocks.OAK_SAPLING), new ItemStack(ModItems.TOKEN_JOY, 2), 200,
nbtIng(ItemAuraBottle.setType(new ItemStack(ModItems.AURA_BOTTLE), NaturesAuraAPI.TYPE_OVERWORLD)),

View file

@ -130,7 +130,9 @@ public final class ModRegistry {
createFlowerPot(temp),
temp = new BlockAuraBloom("aura_cactus", TileEntityAuraCactus::new),
createFlowerPot(temp),
new BlockImpl("tainted_gold_block", ModBlocks.prop(Material.IRON).sound(SoundType.METAL).hardnessAndResistance(3F)));
new BlockImpl("tainted_gold_block", ModBlocks.prop(Material.IRON).sound(SoundType.METAL).hardnessAndResistance(3F)),
new BlockNetherGrass()
);
if (ModConfig.instance.rfConverter.get())
event.getRegistry().register(new BlockRFConverter());

View file

@ -62,6 +62,7 @@
"block.naturesaura.aura_bloom": "Aura Bloom",
"block.naturesaura.aura_cactus": "Aura Cactus",
"block.naturesaura.tainted_gold_block": "Tainted Gold Block",
"block.naturesaura.nether_grass": "Grassy Netherrack",
"item.naturesaura.eye": "Environmental Eye",
"item.naturesaura.eye_improved": "Environmental Ocular",
"item.naturesaura.gold_fiber": "Brilliant Fiber",
@ -95,6 +96,7 @@
"item.naturesaura.effect_powder.naturesaura:cache_recharge": "Powder of no Storage",
"item.naturesaura.effect_powder.naturesaura:animal": "Powder of Fertility",
"item.naturesaura.effect_powder.naturesaura:ore_spawn": "Powder of the Bountiful Core",
"item.naturesaura.effect_powder.naturesaura:nether_grass": "Powder of Barrens",
"item.naturesaura.mover_cart": "Aura Attraction Cart",
"item.naturesaura.range_visualizer": "Mystical Magnifier",
"item.naturesaura.clock_hand": "Hand of Time",

Binary file not shown.

After

Width:  |  Height:  |  Size: 650 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 828 B