diff --git a/src/generated/resources/assets/naturesaura/blockstates/light.json b/src/generated/resources/assets/naturesaura/blockstates/light.json new file mode 100644 index 00000000..96d67e7f --- /dev/null +++ b/src/generated/resources/assets/naturesaura/blockstates/light.json @@ -0,0 +1,7 @@ +{ + "variants": { + "": { + "model": "naturesaura:block/light" + } + } +} \ No newline at end of file diff --git a/src/generated/resources/assets/naturesaura/models/block/light.json b/src/generated/resources/assets/naturesaura/models/block/light.json new file mode 100644 index 00000000..d6918522 --- /dev/null +++ b/src/generated/resources/assets/naturesaura/models/block/light.json @@ -0,0 +1,6 @@ +{ + "parent": "block/air", + "textures": { + "particle": "naturesaura:block/light" + } +} \ No newline at end of file diff --git a/src/generated/resources/assets/naturesaura/models/item/light_staff.json b/src/generated/resources/assets/naturesaura/models/item/light_staff.json new file mode 100644 index 00000000..6e4a66de --- /dev/null +++ b/src/generated/resources/assets/naturesaura/models/item/light_staff.json @@ -0,0 +1,6 @@ +{ + "parent": "item/generated", + "textures": { + "layer0": "naturesaura:item/light_staff" + } +} \ No newline at end of file diff --git a/src/generated/resources/assets/naturesaura/models/item/potted_aura_bloom.json b/src/generated/resources/assets/naturesaura/models/item/potted_aura_bloom.json deleted file mode 100644 index 0290f89f..00000000 --- a/src/generated/resources/assets/naturesaura/models/item/potted_aura_bloom.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "parent": "naturesaura:block/potted_aura_bloom" -} \ No newline at end of file diff --git a/src/generated/resources/assets/naturesaura/models/item/potted_aura_cactus.json b/src/generated/resources/assets/naturesaura/models/item/potted_aura_cactus.json deleted file mode 100644 index 86e7aceb..00000000 --- a/src/generated/resources/assets/naturesaura/models/item/potted_aura_cactus.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "parent": "naturesaura:block/potted_aura_cactus" -} \ No newline at end of file diff --git a/src/generated/resources/data/naturesaura/loot_tables/blocks/light.json b/src/generated/resources/data/naturesaura/loot_tables/blocks/light.json new file mode 100644 index 00000000..78793172 --- /dev/null +++ b/src/generated/resources/data/naturesaura/loot_tables/blocks/light.json @@ -0,0 +1,19 @@ +{ + "type": "minecraft:block", + "pools": [ + { + "rolls": 1, + "entries": [ + { + "type": "minecraft:item", + "name": "minecraft:air" + } + ], + "conditions": [ + { + "condition": "minecraft:survives_explosion" + } + ] + } + ] +} \ No newline at end of file diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/BlockLight.java b/src/main/java/de/ellpeck/naturesaura/blocks/BlockLight.java new file mode 100644 index 00000000..ea1e1ebf --- /dev/null +++ b/src/main/java/de/ellpeck/naturesaura/blocks/BlockLight.java @@ -0,0 +1,62 @@ +package de.ellpeck.naturesaura.blocks; + +import de.ellpeck.naturesaura.api.NaturesAuraAPI; +import de.ellpeck.naturesaura.data.BlockStateGenerator; +import de.ellpeck.naturesaura.reg.ICustomBlockState; +import de.ellpeck.naturesaura.reg.ICustomRenderType; +import de.ellpeck.naturesaura.reg.INoItemBlock; +import net.minecraft.block.BlockState; +import net.minecraft.block.material.Material; +import net.minecraft.client.renderer.RenderType; +import net.minecraft.item.BlockItemUseContext; +import net.minecraft.util.ResourceLocation; +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; + +import java.util.Random; +import java.util.function.Supplier; + +public class BlockLight extends BlockImpl implements ICustomBlockState, INoItemBlock, ICustomRenderType { + + private static final VoxelShape SHAPE = makeCuboidShape(4, 4, 4, 12, 12, 12); + + public BlockLight() { + super("light", Properties.create(Material.WOOL).doesNotBlockMovement().lightValue(15)); + } + + @Override + @OnlyIn(Dist.CLIENT) + public void animateTick(BlockState stateIn, World worldIn, BlockPos pos, Random rand) { + for (int i = 0; i < 2; i++) + NaturesAuraAPI.instance().spawnMagicParticle( + pos.getX() + 0.5F, pos.getY() + 0.5F, pos.getZ() + 0.5F, + rand.nextGaussian() * 0.015F, 0, rand.nextGaussian() * 0.015F, + 0xffcb5c, rand.nextFloat() * 2 + 1, 50, -0.015F, true, true); + } + + @Override + public VoxelShape getShape(BlockState state, IBlockReader worldIn, BlockPos pos, ISelectionContext context) { + return SHAPE; + } + + @Override + public boolean isReplaceable(BlockState state, BlockItemUseContext useContext) { + return true; + } + + @Override + public void generateCustomBlockState(BlockStateGenerator generator) { + generator.simpleBlock(this, generator.models().withExistingParent("light", generator.mcLoc("block/air")) + .texture("particle", "block/light")); + } + + @Override + public Supplier getRenderType() { + return RenderType::cutout; + } +} diff --git a/src/main/java/de/ellpeck/naturesaura/blocks/ModBlocks.java b/src/main/java/de/ellpeck/naturesaura/blocks/ModBlocks.java index 9cccd994..01d36709 100644 --- a/src/main/java/de/ellpeck/naturesaura/blocks/ModBlocks.java +++ b/src/main/java/de/ellpeck/naturesaura/blocks/ModBlocks.java @@ -67,6 +67,7 @@ public final class ModBlocks { public static Block AURA_CACTUS; public static Block TAINTED_GOLD_BLOCK; public static Block NETHER_GRASS; + public static Block LIGHT; public static Block.Properties prop(Material material, MaterialColor color) { return Block.Properties.create(material, color); diff --git a/src/main/java/de/ellpeck/naturesaura/data/ItemModelGenerator.java b/src/main/java/de/ellpeck/naturesaura/data/ItemModelGenerator.java index 8912f27c..43317cd6 100644 --- a/src/main/java/de/ellpeck/naturesaura/data/ItemModelGenerator.java +++ b/src/main/java/de/ellpeck/naturesaura/data/ItemModelGenerator.java @@ -3,6 +3,7 @@ package de.ellpeck.naturesaura.data; import de.ellpeck.naturesaura.NaturesAura; import de.ellpeck.naturesaura.reg.ICustomItemModel; import de.ellpeck.naturesaura.reg.IModItem; +import de.ellpeck.naturesaura.reg.INoItemBlock; import de.ellpeck.naturesaura.reg.ModRegistry; import net.minecraft.block.Block; import net.minecraft.data.DataGenerator; @@ -23,7 +24,7 @@ public class ItemModelGenerator extends ItemModelProvider { ((ICustomItemModel) modItem).generateCustomItemModel(this); } else if (modItem instanceof Item) { this.withExistingParent(name, "item/generated").texture("layer0", "item/" + name); - } else if (modItem instanceof Block) { + } else if (modItem instanceof Block && !(modItem instanceof INoItemBlock)) { this.withExistingParent(name, this.modLoc("block/" + name)); } } diff --git a/src/main/java/de/ellpeck/naturesaura/entities/EntityLightProjectile.java b/src/main/java/de/ellpeck/naturesaura/entities/EntityLightProjectile.java new file mode 100644 index 00000000..533b12ab --- /dev/null +++ b/src/main/java/de/ellpeck/naturesaura/entities/EntityLightProjectile.java @@ -0,0 +1,65 @@ +package de.ellpeck.naturesaura.entities; + +import de.ellpeck.naturesaura.api.NaturesAuraAPI; +import de.ellpeck.naturesaura.blocks.ModBlocks; +import net.minecraft.block.BlockState; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityType; +import net.minecraft.entity.LivingEntity; +import net.minecraft.entity.projectile.ThrowableEntity; +import net.minecraft.network.IPacket; +import net.minecraft.util.math.*; +import net.minecraft.world.World; +import net.minecraftforge.fml.network.NetworkHooks; + +public class EntityLightProjectile extends ThrowableEntity { + public EntityLightProjectile(EntityType type, World worldIn) { + super(type, worldIn); + } + + public EntityLightProjectile(EntityType type, LivingEntity livingEntityIn, World worldIn) { + super(type, livingEntityIn, worldIn); + } + + @Override + public void tick() { + super.tick(); + if (this.world.isRemote && this.ticksExisted > 1) { + for (float i = 0; i <= 1; i += 0.2F) { + NaturesAuraAPI.instance().spawnMagicParticle( + MathHelper.lerp(i, this.prevPosX, this.getPosX()), + MathHelper.lerp(i, this.prevPosY, this.getPosY()), + MathHelper.lerp(i, this.prevPosZ, this.getPosZ()), + this.rand.nextGaussian() * 0.01F, this.rand.nextGaussian() * 0.01F, this.rand.nextGaussian() * 0.01F, + 0xffcb5c, this.rand.nextFloat() * 0.5F + 1, 20, 0, false, true); + } + } + } + + @Override + protected void onImpact(RayTraceResult result) { + if (!this.world.isRemote) { + if (result instanceof BlockRayTraceResult) { + BlockRayTraceResult res = (BlockRayTraceResult) result; + BlockPos pos = res.getPos().offset(res.getFace()); + BlockState state = this.world.getBlockState(pos); + if (state.getMaterial().isReplaceable()) + this.world.setBlockState(pos, ModBlocks.LIGHT.getDefaultState()); + } else if (result instanceof EntityRayTraceResult) { + Entity entity = ((EntityRayTraceResult) result).getEntity(); + entity.setFire(5); + } + } + this.remove(); + } + + @Override + protected void registerData() { + + } + + @Override + public IPacket createSpawnPacket() { + return NetworkHooks.getEntitySpawningPacket(this); + } +} diff --git a/src/main/java/de/ellpeck/naturesaura/entities/ModEntities.java b/src/main/java/de/ellpeck/naturesaura/entities/ModEntities.java index 54be89bb..61945b48 100644 --- a/src/main/java/de/ellpeck/naturesaura/entities/ModEntities.java +++ b/src/main/java/de/ellpeck/naturesaura/entities/ModEntities.java @@ -6,4 +6,5 @@ import net.minecraft.entity.EntityType; public final class ModEntities { public static EntityType MOVER_CART; public static EntityType EFFECT_INHIBITOR; + public static EntityType LIGHT_PROJECTILE; } diff --git a/src/main/java/de/ellpeck/naturesaura/entities/render/RenderStub.java b/src/main/java/de/ellpeck/naturesaura/entities/render/RenderStub.java new file mode 100644 index 00000000..394d8bdb --- /dev/null +++ b/src/main/java/de/ellpeck/naturesaura/entities/render/RenderStub.java @@ -0,0 +1,24 @@ +package de.ellpeck.naturesaura.entities.render; + +import net.minecraft.client.renderer.culling.ClippingHelperImpl; +import net.minecraft.client.renderer.entity.EntityRenderer; +import net.minecraft.client.renderer.entity.EntityRendererManager; +import net.minecraft.client.renderer.texture.AtlasTexture; +import net.minecraft.entity.Entity; +import net.minecraft.util.ResourceLocation; + +public class RenderStub extends EntityRenderer { + public RenderStub(EntityRendererManager renderManager) { + super(renderManager); + } + + @Override + public boolean shouldRender(Entity livingEntityIn, ClippingHelperImpl camera, double camX, double camY, double camZ) { + return false; + } + + @Override + public ResourceLocation getEntityTexture(Entity entity) { + return AtlasTexture.LOCATION_BLOCKS_TEXTURE; + } +} diff --git a/src/main/java/de/ellpeck/naturesaura/items/ItemLightStaff.java b/src/main/java/de/ellpeck/naturesaura/items/ItemLightStaff.java new file mode 100644 index 00000000..170cc366 --- /dev/null +++ b/src/main/java/de/ellpeck/naturesaura/items/ItemLightStaff.java @@ -0,0 +1,28 @@ +package de.ellpeck.naturesaura.items; + +import de.ellpeck.naturesaura.api.NaturesAuraAPI; +import de.ellpeck.naturesaura.entities.EntityLightProjectile; +import de.ellpeck.naturesaura.entities.ModEntities; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.item.ItemStack; +import net.minecraft.util.ActionResult; +import net.minecraft.util.ActionResultType; +import net.minecraft.util.Hand; +import net.minecraft.world.World; + +public class ItemLightStaff extends ItemImpl { + public ItemLightStaff() { + super("light_staff"); + } + + @Override + public ActionResult onItemRightClick(World worldIn, PlayerEntity playerIn, Hand handIn) { + ItemStack stack = playerIn.getHeldItem(handIn); + if (!worldIn.isRemote && NaturesAuraAPI.instance().extractAuraFromPlayer(playerIn, 1000, false)) { + EntityLightProjectile projectile = new EntityLightProjectile(ModEntities.LIGHT_PROJECTILE, playerIn, worldIn); + projectile.shoot(playerIn, playerIn.rotationPitch, playerIn.rotationYaw, 0, 1.5F, 0); + worldIn.addEntity(projectile); + } + return new ActionResult<>(ActionResultType.SUCCESS, stack); + } +} diff --git a/src/main/java/de/ellpeck/naturesaura/items/ModItems.java b/src/main/java/de/ellpeck/naturesaura/items/ModItems.java index 865bfbf0..f4f99c20 100644 --- a/src/main/java/de/ellpeck/naturesaura/items/ModItems.java +++ b/src/main/java/de/ellpeck/naturesaura/items/ModItems.java @@ -48,4 +48,5 @@ public final class ModItems { public static Item DEATH_RING; public static Item TAINTED_GOLD; public static Item LOOT_FINDER; + public static Item LIGHT_STAFF; } diff --git a/src/main/java/de/ellpeck/naturesaura/reg/ModRegistry.java b/src/main/java/de/ellpeck/naturesaura/reg/ModRegistry.java index da294e6e..418759cd 100644 --- a/src/main/java/de/ellpeck/naturesaura/reg/ModRegistry.java +++ b/src/main/java/de/ellpeck/naturesaura/reg/ModRegistry.java @@ -12,10 +12,12 @@ import de.ellpeck.naturesaura.blocks.tiles.TileEntityEnderCrate; import de.ellpeck.naturesaura.enchant.AuraMendingEnchantment; import de.ellpeck.naturesaura.enchant.ModEnchantments; import de.ellpeck.naturesaura.entities.EntityEffectInhibitor; +import de.ellpeck.naturesaura.entities.EntityLightProjectile; import de.ellpeck.naturesaura.entities.EntityMoverMinecart; import de.ellpeck.naturesaura.entities.ModEntities; import de.ellpeck.naturesaura.entities.render.RenderEffectInhibitor; import de.ellpeck.naturesaura.entities.render.RenderMoverMinecart; +import de.ellpeck.naturesaura.entities.render.RenderStub; import de.ellpeck.naturesaura.gen.ModFeatures; import de.ellpeck.naturesaura.gen.WorldGenAncientTree; import de.ellpeck.naturesaura.gen.WorldGenAuraBloom; @@ -131,7 +133,8 @@ public final class ModRegistry { temp = new BlockAuraBloom("aura_cactus", TileEntityAuraCactus::new), createFlowerPot(temp), new BlockImpl("tainted_gold_block", ModBlocks.prop(Material.IRON).sound(SoundType.METAL).hardnessAndResistance(3F)), - new BlockNetherGrass() + new BlockNetherGrass(), + new BlockLight() ); if (ModConfig.instance.rfConverter.get()) @@ -197,7 +200,8 @@ public final class ModRegistry { new ItemCrimsonMeal(), new ItemDeathRing(), new ItemImpl("tainted_gold"), - new ItemLootFinder() + new ItemLootFinder(), + new ItemLightStaff() ); Helper.populateObjectHolders(ModItems.class, event.getRegistry()); } @@ -254,12 +258,17 @@ public final class ModRegistry { EntityType.Builder.create(EntityEffectInhibitor::new, EntityClassification.MISC) .size(1, 1).setShouldReceiveVelocityUpdates(true) .setTrackingRange(64).setUpdateInterval(20).immuneToFire().build(NaturesAura.MOD_ID + ":effect_inhibitor") - .setRegistryName("effect_inhibitor") + .setRegistryName("effect_inhibitor"), + EntityType.Builder.create(EntityLightProjectile::new, EntityClassification.MISC) + .size(0.5F, 0.5F).setShouldReceiveVelocityUpdates(true) + .setTrackingRange(64).setUpdateInterval(3).immuneToFire().build(NaturesAura.MOD_ID + ":light_projectile") + .setRegistryName("light_projectile") ); Helper.populateObjectHolders(ModEntities.class, event.getRegistry()); NaturesAura.proxy.registerEntityRenderer(ModEntities.MOVER_CART, () -> RenderMoverMinecart::new); NaturesAura.proxy.registerEntityRenderer(ModEntities.EFFECT_INHIBITOR, () -> RenderEffectInhibitor::new); + NaturesAura.proxy.registerEntityRenderer(ModEntities.LIGHT_PROJECTILE, () -> RenderStub::new); } @SubscribeEvent diff --git a/src/main/resources/assets/naturesaura/textures/block/light.png b/src/main/resources/assets/naturesaura/textures/block/light.png new file mode 100644 index 00000000..926ed235 Binary files /dev/null and b/src/main/resources/assets/naturesaura/textures/block/light.png differ diff --git a/src/main/resources/assets/naturesaura/textures/item/light_staff.png b/src/main/resources/assets/naturesaura/textures/item/light_staff.png new file mode 100644 index 00000000..8716ec2a Binary files /dev/null and b/src/main/resources/assets/naturesaura/textures/item/light_staff.png differ