diff --git a/src/generated/resources/assets/naturesaura/blockstates/animal_container.json b/src/generated/resources/assets/naturesaura/blockstates/animal_container.json new file mode 100644 index 00000000..b55b2c04 --- /dev/null +++ b/src/generated/resources/assets/naturesaura/blockstates/animal_container.json @@ -0,0 +1,7 @@ +{ + "variants": { + "": { + "model": "naturesaura:block/animal_container" + } + } +} \ No newline at end of file diff --git a/src/generated/resources/assets/naturesaura/models/item/animal_container.json b/src/generated/resources/assets/naturesaura/models/item/animal_container.json new file mode 100644 index 00000000..167f2a85 --- /dev/null +++ b/src/generated/resources/assets/naturesaura/models/item/animal_container.json @@ -0,0 +1,3 @@ +{ + "parent": "naturesaura:block/animal_container" +} \ No newline at end of file diff --git a/src/generated/resources/data/naturesaura/loot_tables/blocks/animal_container.json b/src/generated/resources/data/naturesaura/loot_tables/blocks/animal_container.json new file mode 100644 index 00000000..063c4dd4 --- /dev/null +++ b/src/generated/resources/data/naturesaura/loot_tables/blocks/animal_container.json @@ -0,0 +1,19 @@ +{ + "type": "minecraft:block", + "pools": [ + { + "rolls": 1, + "entries": [ + { + "type": "minecraft:item", + "name": "naturesaura:animal_container" + } + ], + "conditions": [ + { + "condition": "minecraft:survives_explosion" + } + ] + } + ] +} \ No newline at end of file diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/BlockAnimalContainer.java b/src/main/java/de/ellpeck/naturesaura/blocks/BlockAnimalContainer.java index 2a2295b6..7526351b 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/BlockAnimalContainer.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/BlockAnimalContainer.java @@ -2,17 +2,31 @@ package de.ellpeck.naturesaura.blocks; import de.ellpeck.naturesaura.api.render.IVisualizable; import de.ellpeck.naturesaura.blocks.tiles.TileEntityAnimalContainer; -import net.minecraft.block.material.Material; +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.tileentity.TileEntity; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.shapes.ISelectionContext; +import net.minecraft.util.math.shapes.VoxelShape; +import net.minecraft.world.IBlockReader; import net.minecraft.world.World; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; -public class BlockAnimalContainer extends BlockContainerImpl implements IVisualizable { +public class BlockAnimalContainer extends BlockContainerImpl implements IVisualizable, ICustomBlockState { + + private static final VoxelShape SHAPE = makeCuboidShape(5, 0, 5, 11, 13, 11); + public BlockAnimalContainer() { - super("animal_container", TileEntityAnimalContainer::new, ModBlocks.prop(Material.WOOD).hardnessAndResistance(2)); + super("animal_container", TileEntityAnimalContainer::new, ModBlocks.prop(Blocks.STONE)); + } + + @Override + public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) { + return SHAPE; } @Override @@ -32,4 +46,9 @@ public class BlockAnimalContainer extends BlockContainerImpl implements IVisuali public int getVisualizationColor(World world, BlockPos pos) { return 0x42ddf5; } + + @Override + public void generateCustomBlockState(BlockStateGenerator generator) { + generator.simpleBlock(this, generator.models().getExistingFile(generator.modLoc(this.getBaseName()))); + } } diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityAnimalContainer.java b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityAnimalContainer.java index 28568ff2..1365497f 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityAnimalContainer.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/tiles/TileEntityAnimalContainer.java @@ -1,5 +1,7 @@ package de.ellpeck.naturesaura.blocks.tiles; +import de.ellpeck.naturesaura.packet.PacketHandler; +import de.ellpeck.naturesaura.packet.PacketParticles; import net.minecraft.entity.passive.AnimalEntity; import net.minecraft.tileentity.ITickableTileEntity; import net.minecraft.util.math.AxisAlignedBB; @@ -40,6 +42,12 @@ public class TileEntityAnimalContainer extends TileEntityImpl implements ITickab Vec3d distance = pos.subtract(this.pos.getX(), pos.getY(), this.pos.getZ()); distance = distance.normalize().scale(-0.15F); animal.setMotion(distance); + + if (this.world.rand.nextBoolean()) { + Vec3d eye = animal.getEyePosition(1).add(animal.getLookVec()); + PacketHandler.sendToAllAround(this.world, this.pos, 32, + new PacketParticles((float) eye.getX(), (float) eye.getY(), (float) eye.getZ(), PacketParticles.Type.ANIMAL_CONTAINER)); + } } } } diff --git a/src/main/java/de/ellpeck/naturesaura/packet/PacketParticles.java b/src/main/java/de/ellpeck/naturesaura/packet/PacketParticles.java index a2a5484d..fc714d24 100644 --- a/src/main/java/de/ellpeck/naturesaura/packet/PacketParticles.java +++ b/src/main/java/de/ellpeck/naturesaura/packet/PacketParticles.java @@ -450,6 +450,15 @@ public class PacketParticles { 0.25F, color, 0.5F + world.rand.nextFloat() ); } + }), + ANIMAL_CONTAINER((message, world) -> { + for (int i = world.rand.nextInt(2) + 1; i > 0; i--) + NaturesAuraAPI.instance().spawnMagicParticle( + message.posX + world.rand.nextGaussian() * 0.15F, + message.posY - world.rand.nextFloat() * 0.5F, + message.posZ + world.rand.nextGaussian() * 0.15F, + 0, 0, 0, 0x42e9f5, 1 + world.rand.nextFloat() * 2, 40, 0, false, true + ); }); public final BiConsumer action; diff --git a/src/main/resources/assets/naturesaura/lang/en_us.json b/src/main/resources/assets/naturesaura/lang/en_us.json index 52cbdf13..c803c22a 100644 --- a/src/main/resources/assets/naturesaura/lang/en_us.json +++ b/src/main/resources/assets/naturesaura/lang/en_us.json @@ -55,6 +55,7 @@ "block.naturesaura.projectile_generator": "Shooting Mark", "block.naturesaura.blast_furnace_booster": "Armorer's Aid", "block.naturesaura.nether_wart_mushroom": "Nether Wart Mushroom", + "block.naturesaura.animal_container": "Corporeal Eye", "item.naturesaura.eye": "Environmental Eye", "item.naturesaura.eye_improved": "Environmental Ocular", "item.naturesaura.gold_fiber": "Brilliant Fiber", diff --git a/src/main/resources/assets/naturesaura/models/block/animal_container.json b/src/main/resources/assets/naturesaura/models/block/animal_container.json new file mode 100644 index 00000000..500fb2ae --- /dev/null +++ b/src/main/resources/assets/naturesaura/models/block/animal_container.json @@ -0,0 +1,63 @@ +{ + "credit": "Made with Blockbench", + "parent": "minecraft:block/block", + "textures": { + "0": "naturesaura:block/infused_brick", + "1": "naturesaura:block/animal_container_eye", + "particle": "naturesaura:block/infused_brick" + }, + "elements": [ + { + "name": "base", + "from": [3, 0, 3], + "to": [13, 1, 13], + "faces": { + "north": {"uv": [0, 0, 10, 1], "texture": "#0"}, + "east": {"uv": [0, 0, 10, 1], "texture": "#0"}, + "south": {"uv": [0, 0, 10, 1], "texture": "#0"}, + "west": {"uv": [0, 0, 10, 1], "texture": "#0"}, + "up": {"uv": [0, 0, 10, 10], "texture": "#0"}, + "down": {"uv": [0, 0, 10, 10], "texture": "#0"} + } + }, + { + "name": "base2", + "from": [4, 1, 4], + "to": [12, 2, 12], + "faces": { + "north": {"uv": [0, 0, 8, 1], "texture": "#0"}, + "east": {"uv": [0, 0, 8, 1], "texture": "#0"}, + "south": {"uv": [0, 0, 8, 1], "texture": "#0"}, + "west": {"uv": [0, 0, 8, 1], "texture": "#0"}, + "up": {"uv": [0, 0, 8, 8], "texture": "#0"}, + "down": {"uv": [0, 0, 8, 8], "texture": "#0"} + } + }, + { + "name": "stem", + "from": [6, 2, 6], + "to": [10, 7, 10], + "faces": { + "north": {"uv": [0, 0, 4, 5], "texture": "#0"}, + "east": {"uv": [0, 0, 4, 5], "texture": "#0"}, + "south": {"uv": [0, 0, 4, 5], "texture": "#0"}, + "west": {"uv": [0, 0, 4, 5], "texture": "#0"}, + "up": {"uv": [0, 0, 4, 4], "texture": "#0"}, + "down": {"uv": [0, 0, 4, 4], "texture": "#0"} + } + }, + { + "name": "eye", + "from": [5, 7, 5], + "to": [11, 13, 11], + "faces": { + "north": {"uv": [0, 0, 6, 6], "texture": "#1"}, + "east": {"uv": [0, 0, 6, 6], "texture": "#1"}, + "south": {"uv": [0, 0, 6, 6], "texture": "#1"}, + "west": {"uv": [0, 0, 6, 6], "texture": "#1"}, + "up": {"uv": [6, 0, 12, 6], "texture": "#1"}, + "down": {"uv": [6, 0, 12, 6], "texture": "#1"} + } + } + ] +} \ No newline at end of file diff --git a/src/main/resources/assets/naturesaura/textures/block/animal_container_eye.png b/src/main/resources/assets/naturesaura/textures/block/animal_container_eye.png new file mode 100644 index 00000000..8c66a2b4 Binary files /dev/null and b/src/main/resources/assets/naturesaura/textures/block/animal_container_eye.png differ diff --git a/src/main/resources/data/naturesaura/patchouli_books/book/en_us/entries/devices/animal_container.json b/src/main/resources/data/naturesaura/patchouli_books/book/en_us/entries/devices/animal_container.json new file mode 100644 index 00000000..01869e31 --- /dev/null +++ b/src/main/resources/data/naturesaura/patchouli_books/book/en_us/entries/devices/animal_container.json @@ -0,0 +1,17 @@ +{ + "name": "Corporeal Eye", + "icon": "naturesaura:animal_container", + "category": "devices", + "advancement": "naturesaura:eye", + "pages": [ + { + "type": "text", + "text": "Sometimes, as a farmer, one wants their $(thing)animals$() to be contained in a small area as to prevent them from running away.$(br)The $(item)Corporeal Eye$() prevents any animals from exiting its area of effect without needing any blocks around it. Its $(thing)range$() for this containment is determined by the $(thing)redstone signal$() applied to it - the stronger it is, the bigger the area." + }, + { + "type": "crafting", + "text": "Creating the $(item)Corporeal Eye$()", + "recipe": "naturesaura:animal_container" + } + ] +} \ No newline at end of file diff --git a/src/main/resources/data/naturesaura/recipes/animal_container.json b/src/main/resources/data/naturesaura/recipes/animal_container.json new file mode 100644 index 00000000..8b1a5cf3 --- /dev/null +++ b/src/main/resources/data/naturesaura/recipes/animal_container.json @@ -0,0 +1,25 @@ +{ + "type": "minecraft:crafting_shaped", + "pattern": [ + "SES", + "WBW", + "BBB" + ], + "key": { + "W": { + "item": "minecraft:wheat" + }, + "S": { + "item": "minecraft:wheat_seeds" + }, + "E": { + "item": "naturesaura:eye" + }, + "B": { + "item": "naturesaura:infused_brick" + } + }, + "result": { + "item": "naturesaura:animal_container" + } +} \ No newline at end of file