Finished the Binding array, including lightning. Need to add special EntityItem to prevent items burning.
This commit is contained in:
parent
dd8832e18f
commit
440e629e11
|
@ -1,11 +1,56 @@
|
|||
package WayofTime.bloodmagic.alchemyArray;
|
||||
|
||||
import net.minecraft.entity.effect.EntityLightningBolt;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import WayofTime.bloodmagic.api.alchemyCrafting.AlchemyArrayEffectCrafting;
|
||||
import WayofTime.bloodmagic.client.render.alchemyArray.BindingAlchemyCircleRenderer;
|
||||
|
||||
public class CraftingArrayEffectBinding extends AlchemyArrayEffectCrafting{
|
||||
|
||||
public CraftingArrayEffectBinding(ItemStack outputStack) {
|
||||
super(outputStack, 300);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean update(TileEntity tile, int ticksActive) {
|
||||
if(ticksActive >= 50 && ticksActive <= 250) {
|
||||
//TODO: Find a way to spawn lightning from only the server side - does not render when just spawned on server, not client.
|
||||
this.spawnLightningOnCircle(tile.getWorld(), tile.getPos(), ticksActive);
|
||||
}
|
||||
|
||||
if(tile.getWorld().isRemote) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if(ticksActive >= tickLimit){
|
||||
BlockPos pos = tile.getPos();
|
||||
|
||||
ItemStack output = outputStack.copy();
|
||||
EntityItem outputEntity = new EntityItem(tile.getWorld(), pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, output);
|
||||
|
||||
tile.getWorld().spawnEntityInWorld(outputEntity);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public void spawnLightningOnCircle(World world, BlockPos pos, int ticksActive) {
|
||||
if(ticksActive % 50 == 0) {
|
||||
int circle = ticksActive / 50 - 1;
|
||||
float distance = BindingAlchemyCircleRenderer.getDistanceOfCircle(circle, ticksActive);
|
||||
float angle = BindingAlchemyCircleRenderer.getAngleOfCircle(circle, ticksActive);
|
||||
|
||||
double dispX = distance * Math.sin(angle);
|
||||
double dispZ = -distance * Math.cos(angle);
|
||||
|
||||
EntityLightningBolt lightning = new EntityLightningBolt(world, pos.getX() + dispX, pos.getY(), pos.getZ() + dispZ);
|
||||
world.spawnEntityInWorld(lightning);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,28 +16,28 @@ public class BindingAlchemyCircleRenderer extends AlchemyCircleRenderer {
|
|||
public final ResourceLocation arrayResource;
|
||||
public final ResourceLocation[] arraysResources;
|
||||
|
||||
public final int numberOfSweeps = 5;
|
||||
public final int startTime = 50;
|
||||
public final int sweepTime = 40;
|
||||
public static final int numberOfSweeps = 5;
|
||||
public static final int startTime = 50;
|
||||
public static final int sweepTime = 40;
|
||||
|
||||
public final int inwardRotationTime = 50;
|
||||
public static final int inwardRotationTime = 50;
|
||||
|
||||
public final float arcLength = (float) Math.sqrt(2*(2*2) - 2*2*2*Math.cos(2*Math.PI*2/5));
|
||||
public final float theta2 = (float) (18f * Math.PI / 180f);
|
||||
public static final float arcLength = (float) Math.sqrt(2*(2*2) - 2*2*2*Math.cos(2*Math.PI*2/5));
|
||||
public static final float theta2 = (float) (18f * Math.PI / 180f);
|
||||
|
||||
public final int endTime = 300;
|
||||
public static final int endTime = 300;
|
||||
|
||||
public BindingAlchemyCircleRenderer() {
|
||||
this.arrayResource = new ResourceLocation("bloodmagic", "textures/models/AlchemyArrays/BindingArray.png");
|
||||
arraysResources = new ResourceLocation[5];
|
||||
arraysResources[0] = new ResourceLocation("bloodmagic", "textures/models/AlchemyArrays/AirSigil.png");
|
||||
arraysResources[1] = new ResourceLocation("bloodmagic", "textures/models/AlchemyArrays/LavaSigil.png");
|
||||
arraysResources[2] = new ResourceLocation("bloodmagic", "textures/models/AlchemyArrays/WaterSigil.png");
|
||||
arraysResources[3] = new ResourceLocation("bloodmagic", "textures/models/AlchemyArrays/VoidSigil.png");
|
||||
arraysResources[4] = new ResourceLocation("bloodmagic", "textures/models/AlchemyArrays/GrowthSigil.png");
|
||||
arraysResources[0] = new ResourceLocation("bloodmagic", "textures/models/AlchemyArrays/BindingLightningArray.png");
|
||||
arraysResources[1] = new ResourceLocation("bloodmagic", "textures/models/AlchemyArrays/BindingLightningArray.png");
|
||||
arraysResources[2] = new ResourceLocation("bloodmagic", "textures/models/AlchemyArrays/BindingLightningArray.png");
|
||||
arraysResources[3] = new ResourceLocation("bloodmagic", "textures/models/AlchemyArrays/BindingLightningArray.png");
|
||||
arraysResources[4] = new ResourceLocation("bloodmagic", "textures/models/AlchemyArrays/BindingLightningArray.png");
|
||||
}
|
||||
|
||||
public float getAngleOfCircle(int circle, float craftTime) {
|
||||
public static float getAngleOfCircle(int circle, float craftTime) {
|
||||
if (circle >= 0 && circle <= 4) {
|
||||
float originalAngle = (float) (circle * 2 * Math.PI / 5d);
|
||||
|
||||
|
@ -56,7 +56,7 @@ public class BindingAlchemyCircleRenderer extends AlchemyCircleRenderer {
|
|||
return 0;
|
||||
}
|
||||
|
||||
public float getAngle(float craftTime, int sweep) {
|
||||
public static float getAngle(float craftTime, int sweep) {
|
||||
float rDP = craftTime/sweepTime*arcLength;
|
||||
float rEnd = (float) Math.sqrt(rDP*rDP + 2*2 - 2*rDP*2*Math.cos(theta2));
|
||||
return (float) (Math.acos((2*2 + rEnd*rEnd - rDP*rDP)/(2*rEnd*2)));
|
||||
|
@ -65,7 +65,7 @@ public class BindingAlchemyCircleRenderer extends AlchemyCircleRenderer {
|
|||
/**
|
||||
* Returns the center-to-center distance of this circle.
|
||||
*/
|
||||
public float getDistanceOfCircle(int circle, float craftTime) { //TODO Change this so it doesn't use angle, since it is a constant speed.
|
||||
public static float getDistanceOfCircle(int circle, float craftTime) { //TODO Change this so it doesn't use angle, since it is a constant speed.
|
||||
double sweep = (craftTime - startTime)/sweepTime;
|
||||
if(sweep >= 0 && sweep < numberOfSweeps) {
|
||||
float offset = ((int)sweep)*sweepTime + startTime;
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 42 KiB |
Loading…
Reference in a new issue