Skip to content

Commit

Permalink
add fog diffuser model and recipe
Browse files Browse the repository at this point in the history
  • Loading branch information
Cheaterpaul committed Oct 31, 2023
1 parent 4e2e74e commit 9f0cfa3
Show file tree
Hide file tree
Showing 20 changed files with 293 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"variants": {
"": {
"model": "vampirism:block/fog_diffuser_normal"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"parent": "vampirism:block/fog_diffuser",
"render_type": "minecraft:cutout"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"parent": "vampirism:block/fog_diffuser"
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"vampirism:garlic_diffuser_weak",
"vampirism:garlic_diffuser_normal",
"vampirism:garlic_diffuser_improved",
"vampirism:fog_diffuser",
"vampirism:chandelier",
"vampirism:candelabra",
"vampirism:candelabra_wall",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"vampirism:garlic_diffuser_weak",
"vampirism:garlic_diffuser_normal",
"vampirism:garlic_diffuser_improved",
"vampirism:fog_diffuser",
"#vampirism:totem_top_crafted"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
{
"parent": "minecraft:recipes/root",
"criteria": {
"has_cursed_plank": {
"conditions": {
"items": [
{
"items": [
"vampirism:cursed_spruce_planks"
]
}
]
},
"trigger": "minecraft:inventory_changed"
},
"has_diamond": {
"conditions": {
"items": [
{
"tag": "forge:gems/diamond"
}
]
},
"trigger": "minecraft:inventory_changed"
},
"has_mother_core": {
"conditions": {
"items": [
{
"items": [
"vampirism:mother_core"
]
}
]
},
"trigger": "minecraft:inventory_changed"
},
"has_the_recipe": {
"conditions": {
"recipe": "vampirism:vampire/fog_diffuser"
},
"trigger": "minecraft:recipe_unlocked"
}
},
"requirements": [
[
"has_diamond",
"has_cursed_plank",
"has_mother_core",
"has_the_recipe"
]
],
"rewards": {
"recipes": [
"vampirism:vampire/fog_diffuser"
]
},
"sends_telemetry_event": false
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"type": "minecraft:block",
"pools": [
{
"bonus_rolls": 0.0,
"conditions": [
{
"condition": "minecraft:survives_explosion"
}
],
"entries": [
{
"type": "minecraft:item",
"name": "vampirism:fog_diffuser"
}
],
"rolls": 1.0
}
],
"random_sequence": "vampirism:blocks/fog_diffuser"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"type": "minecraft:crafting_shaped",
"category": "misc",
"key": {
"O": {
"tag": "forge:obsidian"
},
"X": {
"item": "vampirism:cursed_spruce_planks"
},
"Y": {
"tag": "forge:gems/diamond"
},
"Z": {
"item": "vampirism:mother_core"
}
},
"pattern": [
"XYX",
"YZY",
"OOO"
],
"result": {
"item": "vampirism:fog_diffuser"
},
"show_notification": true
}
19 changes: 19 additions & 0 deletions src/main/java/de/teamlapen/vampirism/blocks/FogDiffuserBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,33 @@
import net.minecraft.world.InteractionResult;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
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.RenderShape;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.entity.BlockEntityTicker;
import net.minecraft.world.level.block.entity.BlockEntityType;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.BlockHitResult;
import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.Shapes;
import net.minecraft.world.phys.shapes.VoxelShape;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.Optional;

public class FogDiffuserBlock extends VampirismBlockContainer {

private static final VoxelShape shape = makeShape();

private static @NotNull VoxelShape makeShape() {
VoxelShape a = Block.box(1, 0, 1, 15, 2, 15);
VoxelShape b = Block.box(3, 2, 3, 13, 12, 13);
return Shapes.or(a, b);
}

public FogDiffuserBlock(@NotNull Properties properties) {
super(properties);
}
Expand Down Expand Up @@ -57,6 +70,12 @@ public BlockEntity newBlockEntity(@NotNull BlockPos pPos, @NotNull BlockState pS
return RenderShape.MODEL;
}

@NotNull
@Override
public VoxelShape getShape(@NotNull BlockState state, @NotNull BlockGetter worldIn, @NotNull BlockPos pos, @NotNull CollisionContext context) {
return shape;
}

@Override
public void onRemove(@NotNull BlockState state, @NotNull Level worldIn, @NotNull BlockPos pos, @NotNull BlockState newState, boolean isMoving) {
super.onRemove(state, worldIn, pos, newState, isMoving);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public class GarlicDiffuserBlock extends VampirismBlockContainer {
private final Type type;

public GarlicDiffuserBlock(Type type) {
super(Properties.of().mapColor(MapColor.STONE).strength(3f).sound(SoundType.STONE).noOcclusion());
super(Properties.of().mapColor(MapColor.STONE).strength(40.0F, 1200.0F).sound(SoundType.STONE).noOcclusion());
this.type = type;
this.registerDefaultState(this.getStateDefinition().any().setValue(FACING, Direction.NORTH));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ static void registerBlockEntityRenderers(EntityRenderersEvent.@NotNull RegisterR
event.registerBlockEntityRenderer(ModTiles.BLOOD_PEDESTAL.get(), PedestalBESR::new);
event.registerBlockEntityRenderer(ModTiles.TOTEM.get(), TotemBESR::new);
event.registerBlockEntityRenderer(ModTiles.GARLIC_DIFFUSER.get(), GarlicDiffuserBESR::new);
event.registerBlockEntityRenderer(ModTiles.FOG_DIFFUSER.get(), FogDiffuserBESR::new);
}

private static void registerRenderType() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package de.teamlapen.vampirism.client.renderer.blockentity;

import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.math.Axis;
import de.teamlapen.vampirism.blockentity.FogDiffuserBlockEntity;
import de.teamlapen.vampirism.core.ModItems;
import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider;
import net.minecraft.client.renderer.entity.ItemRenderer;
import net.minecraft.world.item.ItemDisplayContext;
import net.minecraft.world.item.ItemStack;
import org.jetbrains.annotations.NotNull;

public class FogDiffuserBESR extends VampirismBESR<FogDiffuserBlockEntity> {

private final ItemRenderer itemRenderer;
private final ItemStack motherCore;

public FogDiffuserBESR(BlockEntityRendererProvider.Context context) {
this.itemRenderer = context.getItemRenderer();
motherCore = ModItems.MOTHER_CORE.get().getDefaultInstance();
}

@Override
public void render(@NotNull FogDiffuserBlockEntity pBlockEntity, float pPartialTick, @NotNull PoseStack pPoseStack, @NotNull MultiBufferSource pBuffer, int pPackedLight, int pPackedOverlay) {
pPoseStack.pushPose();
pPoseStack.translate(0.5, 0.3, 0.5);
pPoseStack.mulPose(Axis.YP.rotationDegrees(pBlockEntity.getLevel().getGameTime() + pPartialTick));
this.itemRenderer.renderStatic(motherCore, ItemDisplayContext.GROUND, pPackedLight, pPackedOverlay, pPoseStack, pBuffer, pBlockEntity.getLevel(), 0);
pPoseStack.popPose();
}
}
5 changes: 2 additions & 3 deletions src/main/java/de/teamlapen/vampirism/core/ModBlocks.java
Original file line number Diff line number Diff line change
Expand Up @@ -168,9 +168,8 @@ public class ModBlocks {
((FireBlock) Blocks.FIRE).setFlammable(block, 30, 60);
return block;
});
public static final RegistryObject<MotherBlock> MOTHER = registerWithItem("mother", MotherBlock::new); //TODO remove item, add models/textures

public static final RegistryObject<FogDiffuserBlock> FOG_DIFFUSER = registerWithItem("fog_diffuser", () -> new FogDiffuserBlock(BlockBehaviour.Properties.of().mapColor(MapColor.STONE).strength(3.5F).sound(SoundType.STONE)));
public static final RegistryObject<MotherBlock> MOTHER = registerWithItem("mother", MotherBlock::new);
public static final RegistryObject<FogDiffuserBlock> FOG_DIFFUSER = registerWithItem("fog_diffuser", () -> new FogDiffuserBlock(BlockBehaviour.Properties.of().noOcclusion().mapColor(MapColor.STONE).strength(40.0F, 1200.0F).sound(SoundType.STONE)));


/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,8 @@ protected void registerStatesAndModels() {
simpleBlock(ModBlocks.CURSED_HANGING_ROOTS.get(), models().cross("cursed_hanging_roots", modLoc("block/cursed_hanging_roots")));
simpleBlock(ModBlocks.MOTHER.get(), models().cubeAll("mother", modLoc("block/mother")));

simpleBlock(ModBlocks.FOG_DIFFUSER.get(), models().withExistingParent("fog_diffuser_normal", modLoc("block/fog_diffuser")).renderType(cutout));

}

private void createWoodStates() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,7 @@ protected void registerModels() {
withExistingParent(ModBlocks.ALCHEMY_TABLE.get(), modLoc("block/alchemy_table/alchemy_table"));
withExistingParent(ModBlocks.CASTLE_BLOCK_PURPLE_BRICK_WALL.get(), mcLoc("block/wall_inventory")).texture("wall", modLoc("block/castle_block_purple_brick"));
withExistingParent(ModBlocks.CASTLE_BLOCK_DARK_BRICK_WALL.get(), mcLoc("block/wall_inventory")).texture("wall", modLoc("block/castle_block_dark_brick"));
block(ModBlocks.FOG_DIFFUSER.get(), "fog_diffuser");
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,7 @@ protected void generate() {
.add(LootItem.lootTableItem(ModItems.HUMAN_HEART.get()).setQuality(10))
.add(LootItem.lootTableItem(Items.DIAMOND_BLOCK))
.add(LootItem.lootTableItem(ModItems.VAMPIRE_BLOOD_BOTTLE.get()).setQuality(10))));
this.dropSelf(ModBlocks.FOG_DIFFUSER.get());
}

@NotNull
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ protected void buildRecipes(@NotNull Consumer<FinishedRecipe> consumer) {
ItemLike obi_belt = ModItems.OBI_BELT.get();
ItemLike blood_container = ModBlocks.BLOOD_CONTAINER.get();
ItemLike basalt = Blocks.BASALT;
ItemLike mother_core = ModItems.MOTHER_CORE.get();
ItemLike cursed_spruce_planks = ModBlocks.CURSED_SPRUCE_PLANKS.get();
TagKey<Item> planks = ItemTags.PLANKS;
TagKey<Item> glass = Tags.Items.GLASS;
TagKey<Item> glass_pane = Tags.Items.GLASS_PANES;
Expand Down Expand Up @@ -417,6 +419,7 @@ protected void buildRecipes(@NotNull Consumer<FinishedRecipe> consumer) {
hangingSign(consumer, ModItems.CURSED_SPRUCE_HANGING_SIGN.get(), ModBlocks.STRIPPED_CURSED_SPRUCE_LOG.get());
stonecutterResultFromBase(consumer, RecipeCategory.DECORATIONS, ModBlocks.CASTLE_BLOCK_DARK_BRICK_WALL.get(), ModBlocks.CASTLE_BLOCK_DARK_BRICK.get());
stonecutterResultFromBase(consumer, RecipeCategory.DECORATIONS, ModBlocks.CASTLE_BLOCK_PURPLE_BRICK_WALL.get(), ModBlocks.CASTLE_BLOCK_PURPLE_BRICK.get());
ShapedRecipeBuilder.shaped(RecipeCategory.DECORATIONS, ModBlocks.FOG_DIFFUSER.get()).pattern("XYX").pattern("YZY").pattern("OOO").define('X', cursed_spruce_planks).define('Y', diamond).define('O', obsidian).define('Z', mother_core).unlockedBy("has_diamond", has(diamond)).unlockedBy("has_cursed_plank", has(cursed_spruce_planks)).unlockedBy("has_mother_core", has(mother_core)).save(consumer, vampire("fog_diffuser"));
}

private @NotNull JsonObject enchantment(int level, Enchantment enchantment) {
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/de/teamlapen/vampirism/data/TagGenerator.java
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ protected void addTags(HolderLookup.Provider holderLookup) {
.add(ModBlocks.GARLIC_DIFFUSER_WEAK.get())
.add(ModBlocks.GARLIC_DIFFUSER_NORMAL.get())
.add(ModBlocks.GARLIC_DIFFUSER_IMPROVED.get())
.add(ModBlocks.FOG_DIFFUSER.get())
.add(ModBlocks.CHANDELIER.get())
.add(ModBlocks.CANDELABRA.get())
.add(ModBlocks.CANDELABRA_WALL.get())
Expand Down Expand Up @@ -148,6 +149,7 @@ protected void addTags(HolderLookup.Provider holderLookup) {
.add(ModBlocks.GARLIC_DIFFUSER_WEAK.get())
.add(ModBlocks.GARLIC_DIFFUSER_NORMAL.get())
.add(ModBlocks.GARLIC_DIFFUSER_IMPROVED.get())
.add(ModBlocks.FOG_DIFFUSER.get())
.addTag(ModTags.Blocks.TOTEM_TOP_CRAFTED)
;

Expand Down
Loading

0 comments on commit 9f0cfa3

Please sign in to comment.