eyes of the shulker and blaze

This commit is contained in:
Ellpeck 2020-05-20 14:55:59 +02:00
parent ec5e38a7a4
commit b4990a6664
17 changed files with 325 additions and 10 deletions

View file

@ -110,7 +110,7 @@ dependencies {
compileOnly fg.deobf("top.theillusivec4.curios:curios:FORGE-1.15.2-2.0-beta2:api")
compile fg.deobf("com.blamejared.crafttweaker:CraftTweaker-1.15.1:6.0.0.4")
compile fg.deobf("quarris.enchantability:enchantability:5.0.1")
compile fg.deobf("quarris.enchantability:enchantability:8.1.15")
}
// Example for how to get properties into the manifest for reading by the runtime..

View file

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

View file

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

View file

@ -14,9 +14,8 @@ public class EnchantibilityCompat implements ICompat {
@Override
public void setup() {
DeferredWorkQueue.runLater(() -> {
IInternals api = EnchantabilityApi.getInstance();
api.registerEnchantEffect(EnchantibilityAuraMending.RES, ModEnchantments.AURA_MENDING, EnchantibilityAuraMending::new);
api.registerEffectComponent(EnchantibilityAuraMending.RES, TickEvent.PlayerTickEvent.class, EnchantibilityAuraMending::onPlayerTick, e -> Collections.singletonList(e.player));
EnchantabilityApi.registerEnchantEffect(EnchantibilityAuraMending.RES, ModEnchantments.AURA_MENDING, EnchantibilityAuraMending::new);
EnchantabilityApi.registerEffectComponent(EnchantibilityAuraMending.RES, TickEvent.PlayerTickEvent.class, EnchantibilityAuraMending::onPlayerTick, e -> Collections.singletonList(e.player));
});
}

View file

@ -0,0 +1,144 @@
package de.ellpeck.naturesaura.entities;
import de.ellpeck.naturesaura.api.NaturesAuraAPI;
import de.ellpeck.naturesaura.packet.PacketHandler;
import de.ellpeck.naturesaura.packet.PacketParticles;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.item.EyeOfEnderEntity;
import net.minecraft.entity.item.ItemEntity;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.network.IPacket;
import net.minecraft.network.datasync.DataParameter;
import net.minecraft.network.datasync.DataSerializers;
import net.minecraft.network.datasync.EntityDataManager;
import net.minecraft.particles.ParticleTypes;
import net.minecraft.util.SoundEvents;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.World;
import net.minecraftforge.common.ForgeHooks;
import net.minecraftforge.fml.network.NetworkHooks;
public class EntityStructureFinder extends EyeOfEnderEntity {
public static final DataParameter<Integer> COLOR = EntityDataManager.createKey(EntityStructureFinder.class, DataSerializers.VARINT);
private double targetX;
private double targetY;
private double targetZ;
private int despawnTimer;
private boolean shatterOrDrop;
public EntityStructureFinder(EntityType<? extends EyeOfEnderEntity> type, World world) {
super(type, world);
}
@Override
protected void registerData() {
super.registerData();
this.dataManager.register(COLOR, 0);
}
@Override
public void writeAdditional(CompoundNBT compound) {
super.writeAdditional(compound);
compound.putInt("color", this.dataManager.get(COLOR));
}
@Override
public void readAdditional(CompoundNBT compound) {
super.readAdditional(compound);
this.dataManager.set(COLOR, compound.getInt("color"));
}
@Override
public void moveTowards(BlockPos pos) {
double d0 = pos.getX();
int i = pos.getY();
double d1 = pos.getZ();
double d2 = d0 - this.getPosX();
double d3 = d1 - this.getPosZ();
float f = MathHelper.sqrt(d2 * d2 + d3 * d3);
if (f > 12.0F) {
this.targetX = this.getPosX() + d2 / (double) f * 12.0D;
this.targetZ = this.getPosZ() + d3 / (double) f * 12.0D;
this.targetY = this.getPosY() + 8.0D;
} else {
this.targetX = d0;
this.targetY = i;
this.targetZ = d1;
}
this.despawnTimer = 0;
this.shatterOrDrop = this.rand.nextInt(4) > 0;
}
@Override
public void tick() {
this.baseTick();
Vec3d vec3d = this.getMotion();
double d0 = this.getPosX() + vec3d.x;
double d1 = this.getPosY() + vec3d.y;
double d2 = this.getPosZ() + vec3d.z;
float f = MathHelper.sqrt(horizontalMag(vec3d));
this.rotationYaw = (float) (MathHelper.atan2(vec3d.x, vec3d.z) * (double) (180F / (float) Math.PI));
this.rotationPitch = (float) (MathHelper.atan2(vec3d.y, f) * (double) (180F / (float) Math.PI));
while (this.rotationPitch - this.prevRotationPitch < -180.0F)
this.prevRotationPitch -= 360.0F;
while (this.rotationPitch - this.prevRotationPitch >= 180.0F)
this.prevRotationPitch += 360.0F;
while (this.rotationYaw - this.prevRotationYaw < -180.0F)
this.prevRotationYaw -= 360.0F;
while (this.rotationYaw - this.prevRotationYaw >= 180.0F)
this.prevRotationYaw += 360.0F;
this.rotationPitch = MathHelper.lerp(0.2F, this.prevRotationPitch, this.rotationPitch);
this.rotationYaw = MathHelper.lerp(0.2F, this.prevRotationYaw, this.rotationYaw);
if (!this.world.isRemote) {
double d3 = this.targetX - d0;
double d4 = this.targetZ - d2;
float f1 = (float) Math.sqrt(d3 * d3 + d4 * d4);
float f2 = (float) MathHelper.atan2(d4, d3);
double d5 = MathHelper.lerp(0.0025D, f, f1);
double d6 = vec3d.y;
if (f1 < 1.0F) {
d5 *= 0.8D;
d6 *= 0.8D;
}
int j = this.getPosY() < this.targetY ? 1 : -1;
vec3d = new Vec3d(Math.cos(f2) * d5, d6 + ((double) j - d6) * (double) 0.015F, Math.sin(f2) * d5);
this.setMotion(vec3d);
}
if (this.isInWater()) {
for (int i = 0; i < 4; ++i)
this.world.addParticle(ParticleTypes.BUBBLE, d0 - vec3d.x * 0.25D, d1 - vec3d.y * 0.25D, d2 - vec3d.z * 0.25D, vec3d.x, vec3d.y, vec3d.z);
} else if (this.world.isRemote) {
NaturesAuraAPI.instance().spawnMagicParticle(d0 - vec3d.x * 0.25D + this.rand.nextDouble() * 0.6D - 0.3D, d1 - vec3d.y * 0.25D - 0.5D, d2 - vec3d.z * 0.25D + this.rand.nextDouble() * 0.6D - 0.3D, vec3d.x * 0.25F, vec3d.y * 0.25F, vec3d.z * 0.25F, this.dataManager.get(COLOR), 1, 50, 0, false, true);
}
if (!this.world.isRemote) {
this.setPosition(d0, d1, d2);
++this.despawnTimer;
if (this.despawnTimer > 80 && !this.world.isRemote) {
this.playSound(SoundEvents.ENTITY_ENDER_EYE_DEATH, 1.0F, 1.0F);
this.remove();
if (this.shatterOrDrop) {
this.world.addEntity(new ItemEntity(this.world, this.getPosX(), this.getPosY(), this.getPosZ(), this.getItem()));
} else {
PacketHandler.sendToAllAround(this.world, this.getPosition(), 32, new PacketParticles((float) this.getPosX(), (float) this.getPosY(), (float) this.getPosZ(), PacketParticles.Type.STRUCTURE_FINDER, this.getEntityId()));
}
}
} else {
this.setRawPosition(d0, d1, d2);
}
}
@Override
public IPacket<?> createSpawnPacket() {
return NetworkHooks.getEntitySpawningPacket(this);
}
}

View file

@ -7,4 +7,5 @@ public final class ModEntities {
public static EntityType<EntityMoverMinecart> MOVER_CART;
public static EntityType<EntityEffectInhibitor> EFFECT_INHIBITOR;
public static EntityType<EntityLightProjectile> LIGHT_PROJECTILE;
public static EntityType<EntityStructureFinder> STRUCTURE_FINDER;
}

View file

@ -0,0 +1,42 @@
package de.ellpeck.naturesaura.items;
import de.ellpeck.naturesaura.entities.EntityStructureFinder;
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.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraft.world.server.ServerWorld;
public class ItemStructureFinder extends ItemImpl {
private final String structureName;
private final int color;
public ItemStructureFinder(String baseName, String structureName, int color) {
super(baseName);
this.structureName = structureName;
this.color = color;
}
@Override
public ActionResult<ItemStack> onItemRightClick(World worldIn, PlayerEntity playerIn, Hand handIn) {
ItemStack stack = playerIn.getHeldItem(handIn);
if (!worldIn.isRemote) {
BlockPos pos = ((ServerWorld) worldIn).getChunkProvider().getChunkGenerator().findNearestStructure(worldIn, this.structureName, playerIn.getPosition(), 1024, false);
if (pos != null) {
EntityStructureFinder entity = new EntityStructureFinder(ModEntities.STRUCTURE_FINDER, worldIn);
entity.setPosition(playerIn.getPosX(), playerIn.getPosYHeight(0.5D), playerIn.getPosZ());
entity.func_213863_b(stack);
entity.getDataManager().set(EntityStructureFinder.COLOR, this.color);
entity.moveTowards(pos.up(64));
worldIn.addEntity(entity);
stack.shrink(1);
}
}
return new ActionResult<>(ActionResultType.SUCCESS, stack);
}
}

View file

@ -58,4 +58,6 @@ public final class ModItems {
public static Item SKY_CHEST;
public static Item SKY_PANTS;
public static Item SKY_SHOES;
public static Item FORTRESS_FINDER;
public static Item END_CITY_FINDER;
}

View file

@ -4,9 +4,14 @@ import de.ellpeck.naturesaura.api.NaturesAuraAPI;
import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk;
import de.ellpeck.naturesaura.api.aura.type.IAuraType;
import de.ellpeck.naturesaura.blocks.multi.Multiblocks;
import de.ellpeck.naturesaura.entities.EntityStructureFinder;
import net.minecraft.block.BlockState;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.WorldRenderer;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.network.PacketBuffer;
import net.minecraft.particles.ItemParticleData;
import net.minecraft.particles.ParticleTypes;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
@ -513,6 +518,22 @@ public class PacketParticles {
message.posY + 2 / 16F + world.rand.nextFloat() * 8 / 16F,
message.posZ + 5 / 16F + world.rand.nextFloat() * 6 / 16F,
0, 0, 0, color, 2, 40 + world.rand.nextInt(20), 0, false, true);
}),
STRUCTURE_FINDER((message, world) -> {
EntityStructureFinder entity = (EntityStructureFinder) world.getEntityByID(message.data[0]);
WorldRenderer renderer = Minecraft.getInstance().worldRenderer;
double d0 = message.posX + 0.5D;
double d13 = message.posY;
double d18 = message.posZ + 0.5D;
for (int j2 = 0; j2 < 8; ++j2)
renderer.addParticle(new ItemParticleData(ParticleTypes.ITEM, entity.getItem()), false, d0, d13, d18, world.rand.nextGaussian() * 0.15D, world.rand.nextDouble() * 0.2D, world.rand.nextGaussian() * 0.15D);
int color = entity.getDataManager().get(EntityStructureFinder.COLOR);
for (double d24 = 0.0D; d24 < (Math.PI * 2D); d24 += 0.15707963267948966D) {
NaturesAuraAPI.instance().spawnMagicParticle(d0 + Math.cos(d24) * 5.0D, d13 - 0.4D, d18 + Math.sin(d24) * 5.0D, Math.cos(d24) * -2, 0.0D, Math.sin(d24) * -2, color, 2, 60, 0, false, true);
NaturesAuraAPI.instance().spawnMagicParticle(d0 + Math.cos(d24) * 5.0D, d13 - 0.4D, d18 + Math.sin(d24) * 5.0D, Math.cos(d24) * -2.5, 0.0D, Math.sin(d24) * -2.5, color, 2, 60, 0, false, true);
}
});
public final BiConsumer<PacketParticles, World> action;

View file

@ -11,10 +11,7 @@ import de.ellpeck.naturesaura.blocks.tiles.TileEntityAuraBloom.TileEntityAuraCac
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.*;
import de.ellpeck.naturesaura.entities.render.RenderEffectInhibitor;
import de.ellpeck.naturesaura.entities.render.RenderMoverMinecart;
import de.ellpeck.naturesaura.entities.render.RenderStub;
@ -34,6 +31,8 @@ import net.minecraft.block.Blocks;
import net.minecraft.block.FlowerPotBlock;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.entity.SpriteRenderer;
import net.minecraft.enchantment.Enchantment;
import net.minecraft.entity.EntityClassification;
import net.minecraft.entity.EntityType;
@ -214,7 +213,9 @@ public final class ModRegistry {
new ItemArmor("sky_helmet", ModArmorMaterial.SKY, EquipmentSlotType.HEAD),
new ItemArmor("sky_chest", ModArmorMaterial.SKY, EquipmentSlotType.CHEST),
new ItemArmor("sky_pants", ModArmorMaterial.SKY, EquipmentSlotType.LEGS),
new ItemArmor("sky_shoes", ModArmorMaterial.SKY, EquipmentSlotType.FEET)
new ItemArmor("sky_shoes", ModArmorMaterial.SKY, EquipmentSlotType.FEET),
new ItemStructureFinder("fortress_finder", "Fortress", 0xba2800),
new ItemStructureFinder("end_city_finder", "EndCity", 0xca5cd6)
);
Helper.populateObjectHolders(ModItems.class, event.getRegistry());
}
@ -275,13 +276,18 @@ public final class ModRegistry {
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")
.setRegistryName("light_projectile"),
EntityType.Builder.create(EntityStructureFinder::new, EntityClassification.MISC)
.size(0.5F, 0.5F).setShouldReceiveVelocityUpdates(true)
.setTrackingRange(64).setUpdateInterval(2).immuneToFire().build(NaturesAura.MOD_ID + ":structure_finder")
.setRegistryName("structure_finder")
);
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);
NaturesAura.proxy.registerEntityRenderer(ModEntities.STRUCTURE_FINDER, () -> m -> new SpriteRenderer<>(m, Minecraft.getInstance().getItemRenderer()));
}
@SubscribeEvent

View file

@ -127,6 +127,8 @@
"item.naturesaura.tainted_gold": "Tainted Gold",
"item.naturesaura.loot_finder": "Staff of Riches",
"item.naturesaura.light_staff": "Staff of Baldur",
"item.naturesaura.fortress_finder": "Eye of the Blaze",
"item.naturesaura.end_city_finder": "Eye of the Shulker",
"container.naturesaura:tree_ritual.name": "Ritual of the Forest",
"container.naturesaura:altar.name": "Natural Altar Infusion",
"container.naturesaura:offering.name": "Offering to the Gods",

Binary file not shown.

After

Width:  |  Height:  |  Size: 458 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 484 B

View file

@ -0,0 +1,17 @@
{
"name": "Eye of the Shulker",
"icon": "naturesaura:end_city_finder",
"category": "items",
"advancement": "naturesaura:aura_bottle_end",
"pages": [
{
"type": "text",
"text": "Being aware of the abilities of the $(item)Eye of Ender$() and the $(l:items/fortress_finder)Eye of the Blaze$(), magical botanists can construct a third one of these structure-finding eyes, completing the dimension sequence. The $(item)Eye of the Shulker$() will, in a very similar manner to its overworld and nether counterparts, locate the closest $(thing)End City$() upon being thrown."
},
{
"type": "crafting",
"text": "Creating the $(item)Eye of the Shulker$()",
"recipe": "naturesaura:end_city_finder"
}
]
}

View file

@ -0,0 +1,17 @@
{
"name": "Eye of the Blaze",
"icon": "naturesaura:fortress_finder",
"category": "items",
"advancement": "naturesaura:aura_bottle_nether",
"pages": [
{
"type": "text",
"text": "To find $(thing)Strongholds$(), one can use the abilities of the $(item)Eye of Ender$(), which will, upon being thrown, slowly move towards the nearest one of these structures, and in doing so, point the way to it. Similar behavior can be observed for the $(item)Eye of the Blaze$(), but, instead of finding strongholds, it will locate the closest $(thing)Nether Fortress$()."
},
{
"type": "crafting",
"text": "Creating the $(item)Eye of the Blaze$()",
"recipe": "naturesaura:fortress_finder"
}
]
}

View file

@ -0,0 +1,26 @@
{
"type": "minecraft:crafting_shaped",
"pattern": [
" B ",
"CEC",
" B "
],
"key": {
"E": {
"item": "minecraft:ender_eye"
},
"C": {
"item": "minecraft:chorus_fruit"
},
"B": {
"type": "forge:nbt",
"item": "naturesaura:aura_bottle",
"nbt": {
"stored_type": "naturesaura:end"
}
}
},
"result": {
"item": "naturesaura:end_city_finder"
}
}

View file

@ -0,0 +1,26 @@
{
"type": "minecraft:crafting_shaped",
"pattern": [
" B ",
"CEC",
" B "
],
"key": {
"E": {
"item": "minecraft:ender_eye"
},
"C": {
"type": "forge:nbt",
"item": "naturesaura:aura_bottle",
"nbt": {
"stored_type": "naturesaura:nether"
}
},
"B": {
"item": "minecraft:nether_brick"
}
},
"result": {
"item": "naturesaura:fortress_finder"
}
}