light staff, part 1

This commit is contained in:
Ellpeck 2020-04-27 18:30:44 +02:00
parent d854be3e34
commit bf4a76431e
17 changed files with 234 additions and 10 deletions

View file

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

View file

@ -0,0 +1,6 @@
{
"parent": "block/air",
"textures": {
"particle": "naturesaura:block/light"
}
}

View file

@ -0,0 +1,6 @@
{
"parent": "item/generated",
"textures": {
"layer0": "naturesaura:item/light_staff"
}
}

View file

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

View file

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

View file

@ -0,0 +1,19 @@
{
"type": "minecraft:block",
"pools": [
{
"rolls": 1,
"entries": [
{
"type": "minecraft:item",
"name": "minecraft:air"
}
],
"conditions": [
{
"condition": "minecraft:survives_explosion"
}
]
}
]
}

View file

@ -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<RenderType> getRenderType() {
return RenderType::cutout;
}
}

View file

@ -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);

View file

@ -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));
}
}

View file

@ -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<? extends ThrowableEntity> type, World worldIn) {
super(type, worldIn);
}
public EntityLightProjectile(EntityType<? extends ThrowableEntity> 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);
}
}

View file

@ -6,4 +6,5 @@ import net.minecraft.entity.EntityType;
public final class ModEntities {
public static EntityType<EntityMoverMinecart> MOVER_CART;
public static EntityType<EntityEffectInhibitor> EFFECT_INHIBITOR;
public static EntityType<EntityLightProjectile> LIGHT_PROJECTILE;
}

View file

@ -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<Entity> {
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;
}
}

View file

@ -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<ItemStack> 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);
}
}

View file

@ -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;
}

View file

@ -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.<EntityLightProjectile>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

Binary file not shown.

After

Width:  |  Height:  |  Size: 91 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 441 B