Skip to content

Commit

Permalink
feat: add primal orifice block
Browse files Browse the repository at this point in the history
  • Loading branch information
Elenterius committed Dec 10, 2023
1 parent 6c48122 commit 02a2c84
Show file tree
Hide file tree
Showing 14 changed files with 219 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -503,6 +503,7 @@ private void addBlockTranslations() {
addBlock(ModBlocks.MALIGNANT_FLESH_WALL, "Malignant Flesh Wall", "Wall of malignant flesh.\nIt's coming for you! ;)");
addBlock(ModBlocks.MALIGNANT_FLESH_VEINS, "Malignant Flesh Veins", "They look almost feral...\nyou better not touch them.");
addBlock(ModBlocks.MALIGNANT_BLOOM, "Malignant Bloom", "An exotic flower of primordial beauty.\n\nIt will spread itself by launching it's ripe berry into the air.\nOn impact the berry explodes and spreads malignant veins as well.");
addBlock(ModBlocks.PRIMAL_ORIFICE, "Primal Orifice", "A primitive piece full of holes. It seems to leak an acidic substance.");
}

private void addEntityTranslations() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ protected void addTables() {
dropSelf(ModBlocks.MALIGNANT_FLESH_WALL.get());
add(ModBlocks.MALIGNANT_FLESH_VEINS.get(), block -> createMultifaceBlockDrops(block, HAS_SHEARS_OR_SILK_TOUCH));
add(ModBlocks.MALIGNANT_BLOOM.get(), noDrop());
dropSelf(ModBlocks.PRIMAL_ORIFICE.get());

dropSelf(ModBlocks.VOICE_BOX.get());
dropSelf(ModBlocks.IMPERMEABLE_MEMBRANE.get());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.github.elenterius.biomancy.block.*;
import com.github.elenterius.biomancy.block.fleshspike.FleshSpikeBlock;
import com.github.elenterius.biomancy.block.malignantbloom.MalignantBloomBlock;
import com.github.elenterius.biomancy.block.orifice.OrificeBlock;
import com.github.elenterius.biomancy.block.ownable.OwnablePressurePlateBlock;
import com.github.elenterius.biomancy.block.property.DirectionalSlabType;
import com.github.elenterius.biomancy.block.property.Orientation;
Expand Down Expand Up @@ -91,6 +92,7 @@ protected void registerStatesAndModels() {
wallBlock(ModBlocks.MALIGNANT_FLESH_WALL, ModBlocks.MALIGNANT_FLESH);
veinsBlock(ModBlocks.MALIGNANT_FLESH_VEINS);
malignantBloom(ModBlocks.MALIGNANT_BLOOM);
orifice(ModBlocks.PRIMAL_ORIFICE);

irisDoor(ModBlocks.FLESH_IRIS_DOOR, true);
fleshDoor(ModBlocks.FLESH_DOOR);
Expand Down Expand Up @@ -327,6 +329,33 @@ public void directionalBlock(Block block, Function<BlockState, ModelFile> modelF
}, ignored);
}

public <T extends OrificeBlock> void orifice(RegistryObject<T> block) {
orifice(block.get());
}

public void orifice(OrificeBlock block) {
ResourceLocation model = blockAsset(block);

ModelFile.ExistingModelFile defaultModel = models().getExistingFile(model);
ModelFile.ExistingModelFile leakingModel = models().getExistingFile(extend(model, "_leaking"));

ModelFile.ExistingModelFile[] models = {
defaultModel,
defaultModel,
leakingModel
};

getVariantBuilder(block)
.forAllStatesExcept(blockState -> {
Integer age = OrificeBlock.AGE.getValue(blockState);
return ConfiguredModel.builder()
.modelFile(models[age])
.build();
});

simpleBlockItem(block, models[0]);
}

public <T extends MalignantBloomBlock> void malignantBloom(RegistryObject<T> block) {
malignantBloom(block.get());
}
Expand Down
2 changes: 2 additions & 0 deletions src/generated/resources/assets/biomancy/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,8 @@
"block.biomancy.malignant_flesh_veins.tooltip": "They look almost feral...\nyou better not touch them.",
"block.biomancy.malignant_bloom": "Malignant Bloom",
"block.biomancy.malignant_bloom.tooltip": "An exotic flower of primordial beauty.\n\nIt will spread itself by launching it's ripe berry into the air.\nOn impact the berry explodes and spreads malignant veins as well.",
"block.biomancy.primal_orifice": "Primal Orifice",
"block.biomancy.primal_orifice.tooltip": "A primitive piece full of holes. It seems to leak an acidic substance.",
"entity.biomancy.hungry_flesh_blob": "Hungry Flesh Blob",
"entity.biomancy.flesh_blob": "Flesh Blob",
"entity.biomancy.legacy_flesh_blob": "Legacy Flesh Blob",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
package com.github.elenterius.biomancy.block.orifice;

import com.github.elenterius.biomancy.init.ModParticleTypes;
import com.github.elenterius.biomancy.init.ModPlantTypes;
import com.github.elenterius.biomancy.util.EnhancedIntegerProperty;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.util.RandomSource;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.StateDefinition;
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
import net.minecraft.world.phys.BlockHitResult;
import net.minecraftforge.common.IPlantable;
import net.minecraftforge.common.PlantType;

public class OrificeBlock extends Block {

public static final EnhancedIntegerProperty AGE = EnhancedIntegerProperty.wrap(BlockStateProperties.AGE_2);

public OrificeBlock(Properties properties) {
super(properties);
registerDefaultState(defaultBlockState().setValue(AGE.get(), AGE.getMin()));
}

@Override
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> builder) {
super.createBlockStateDefinition(builder);
builder.add(AGE.get());
}

@Override
public boolean canSustainPlant(BlockState state, BlockGetter world, BlockPos pos, Direction facing, IPlantable plantable) {
PlantType type = plantable.getPlantType(world, pos.relative(facing));
return type == ModPlantTypes.FLESH_PLANT_TYPE;
}

@Override
public void randomTick(BlockState state, ServerLevel level, BlockPos pos, RandomSource random) {
if (!level.isAreaLoaded(pos, 1)) return;

if (random.nextFloat() < 0.3f) {
int age = AGE.getValue(state);
if (age < AGE.getMax()) {
level.setBlock(pos, AGE.addValue(state, 1), Block.UPDATE_CLIENTS);
}
else {
if (random.nextFloat() < 0.5f) {
level.setBlock(pos, AGE.setValue(state, AGE.getMin()), Block.UPDATE_CLIENTS);
}
//TODO: accumulate acid below the block on the floor,
// drop a acid blob entity/projectile?
}
}
}

@Override
public InteractionResult use(BlockState state, Level level, BlockPos pos, Player player, InteractionHand hand, BlockHitResult hit) {
//TODO: allow players to harvest acid from full orifices?
return super.use(state, level, pos, player, hand, hit);
}

@Override
public void animateTick(BlockState state, Level level, BlockPos pos, RandomSource random) {
if (random.nextInt(5) == 0 && AGE.getValue(state) == AGE.getMax()) {
Direction direction = Direction.getRandom(random);

if (direction == Direction.UP) {
return;
}

BlockPos neighborPos = pos.relative(direction);
BlockState neighborState = level.getBlockState(neighborPos);

if (!state.canOcclude() || !neighborState.isFaceSturdy(level, neighborPos, direction.getOpposite())) {
double x = direction.getStepX() == 0 ? random.nextDouble() : 0.5d + direction.getStepX() * 0.6d;
double y = direction.getStepY() == 0 ? random.nextDouble() : 0.5d + direction.getStepY() * 0.6d;
double z = direction.getStepZ() == 0 ? random.nextDouble() : 0.5d + direction.getStepZ() * 0.6d;
// TODO: implement acid particle
level.addParticle(ModParticleTypes.FALLING_BLOOD.get(), pos.getX() + x, pos.getY() + y, pos.getZ() + z, 0, 0, 0);
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
@ParametersAreNonnullByDefault
@MethodsReturnNonnullByDefault
package com.github.elenterius.biomancy.block.orifice;

import net.minecraft.MethodsReturnNonnullByDefault;

import javax.annotation.ParametersAreNonnullByDefault;
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import com.github.elenterius.biomancy.block.mawhopper.MawHopperBlock;
import com.github.elenterius.biomancy.block.modularlarynx.VoiceBoxBlock;
import com.github.elenterius.biomancy.block.neural.NeuralInterceptorBlock;
import com.github.elenterius.biomancy.block.orifice.OrificeBlock;
import com.github.elenterius.biomancy.block.ownable.OwnablePressurePlateBlock;
import com.github.elenterius.biomancy.block.storagesac.StorageSacBlock;
import com.github.elenterius.biomancy.block.tongue.TongueBlock;
Expand Down Expand Up @@ -82,6 +83,7 @@ public final class ModBlocks {
public static final RegistryObject<FleshVeinsBlock> MALIGNANT_FLESH_VEINS = register("malignant_flesh_veins", properties -> new FleshVeinsBlock(properties.noCollission().noOcclusion()));
public static final RegistryObject<MalignantBloomBlock> MALIGNANT_BLOOM = register("malignant_bloom", properties -> new MalignantBloomBlock(properties.randomTicks().noOcclusion().lightLevel(MalignantBloomBlock::getLightEmission)));
public static final RegistryObject<Block> BLOOMLIGHT = register("bloomlight", properties -> new Block(properties.sound(SoundType.SHROOMLIGHT).lightLevel(x -> 15)));
public static final RegistryObject<OrificeBlock> PRIMAL_ORIFICE = register("primal_orifice", properties -> new OrificeBlock(properties.randomTicks()));

//## Utility
public static final RegistryObject<VoiceBoxBlock> VOICE_BOX = register("voice_box", VoiceBoxBlock::new);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ public final class ModItems {
public static final RegistryObject<ObfuscatedTooltipBlockItem> MALIGNANT_FLESH_WALL = registerBlockItem(ModBlocks.MALIGNANT_FLESH_WALL, ObfuscatedTooltipBlockItem::new);
public static final RegistryObject<ObfuscatedTooltipBlockItem> MALIGNANT_FLESH_VEINS = registerBlockItem(ModBlocks.MALIGNANT_FLESH_VEINS, ObfuscatedTooltipBlockItem::new);
public static final RegistryObject<ObfuscatedTooltipBlockItem> MALIGNANT_BLOOM = registerBlockItem(ModBlocks.MALIGNANT_BLOOM, ObfuscatedTooltipBlockItem::new);
public static final RegistryObject<ObfuscatedTooltipBlockItem> PRIMAL_ORIFICE = registerBlockItem(ModBlocks.PRIMAL_ORIFICE, ObfuscatedTooltipBlockItem::new);

//## Utility
public static final RegistryObject<SimpleBlockItem> VOICE_BOX = registerSimpleBlockItem(ModBlocks.VOICE_BOX, () -> createProperties().tab(null));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{
"credit": "Made by Elenterius",
"parent": "block/block",
"render_type": "minecraft:solid",
"textures": {
"0": "biomancy:block/primal_orifice",
"1": "biomancy:block/primal_flesh",
"2": "biomancy:block/primal_orifice_2",
"particle": "biomancy:block/primal_orifice"
},
"elements": [
{
"from": [ 0, 0, 0 ],
"to": [ 16, 16, 16 ],
"faces": {
"north": {
"uv": [ 0, 0, 16, 16 ],
"texture": "#0"
},
"east": {
"uv": [ 0, 0, 16, 16 ],
"texture": "#0"
},
"south": {
"uv": [ 0, 0, 16, 16 ],
"texture": "#0"
},
"west": {
"uv": [ 0, 0, 16, 16 ],
"texture": "#0"
},
"up": {
"uv": [ 0, 0, 16, 16 ],
"texture": "#1"
},
"down": {
"uv": [ 0, 0, 16, 16 ],
"texture": "#2"
}
}
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{
"credit": "Made by Elenterius",
"parent": "block/block",
"render_type": "minecraft:solid",
"textures": {
"1": "biomancy:block/primal_flesh",
"3": "biomancy:block/primal_orifice_leaking",
"4": "biomancy:block/primal_orifice_2_full",
"particle": "biomancy:block/primal_orifice"
},
"elements": [
{
"from": [ 0, 0, 0 ],
"to": [ 16, 16, 16 ],
"faces": {
"north": {
"uv": [ 0, 0, 16, 16 ],
"texture": "#3"
},
"east": {
"uv": [ 0, 0, 16, 16 ],
"texture": "#3"
},
"south": {
"uv": [ 0, 0, 16, 16 ],
"texture": "#3"
},
"west": {
"uv": [ 0, 0, 16, 16 ],
"texture": "#3"
},
"up": {
"uv": [ 0, 0, 16, 16 ],
"texture": "#1"
},
"down": {
"uv": [ 0, 0, 16, 16 ],
"texture": "#4"
}
}
}
]
}
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 02a2c84

Please sign in to comment.