use of WayofTime.alchemicalWizardry.api.summoningRegistry.SummoningRegistryComponent in project BloodMagic by WayofTime.
the class TEPlinth method updateEntity.
// Logic for the actual block is under here
@Override
public void updateEntity() {
super.updateEntity();
if (worldObj.isRemote) {
return;
}
if (!isActive()) {
if (getStackInSlot(0) != null && getStackInSlot(0).getItem() instanceof EnergyBattery) {
int bloodOrbLevel = ((EnergyBattery) getStackInSlot(0).getItem()).getOrbLevel();
if (SummoningRegistry.isRecipeValid(bloodOrbLevel, composeItemsForRingAndParadigm(1, true), composeItemsForRingAndParadigm(2, true), composeItemsForRingAndParadigm(3, true))) {
SummoningRegistryComponent src = SummoningRegistry.getRegistryComponent(bloodOrbLevel, composeItemsForRingAndParadigm(1, true), composeItemsForRingAndParadigm(2, true), composeItemsForRingAndParadigm(3, true));
isActive = true;
paradigm = true;
progress = 0;
ring1Inv = src.getRingRecipeForRing(1);
ring2Inv = src.getRingRecipeForRing(2);
ring3Inv = src.getRingRecipeForRing(3);
} else if (SummoningRegistry.isRecipeValid(bloodOrbLevel, composeItemsForRingAndParadigm(1, false), composeItemsForRingAndParadigm(2, false), composeItemsForRingAndParadigm(3, false))) {
SummoningRegistryComponent src = SummoningRegistry.getRegistryComponent(bloodOrbLevel, composeItemsForRingAndParadigm(1, false), composeItemsForRingAndParadigm(2, false), composeItemsForRingAndParadigm(3, false));
isActive = true;
paradigm = false;
progress = 0;
ring1Inv = src.getRingRecipeForRing(1);
ring2Inv = src.getRingRecipeForRing(2);
ring3Inv = src.getRingRecipeForRing(3);
} else {
isActive = false;
progress = 0;
}
}
} else {
if (getStackInSlot(0) != null && getStackInSlot(0).getItem() instanceof EnergyBattery) {
if (progress % progressInterval == 0) {
int ring = (progress / progressInterval) / 6 + 1;
int slot = (progress / progressInterval) % 6;
ItemStack itemStack;
switch(ring) {
case 1:
itemStack = this.ring1Inv[slot];
break;
case 2:
itemStack = this.ring2Inv[slot];
break;
case 3:
itemStack = this.ring3Inv[slot];
break;
default:
itemStack = null;
}
if (itemStack == null) {
progress += progressInterval;
} else {
if (this.deleteItemStackInRing(ring, itemStack)) {
progress++;
}
}
} else {
progress++;
}
if (progress >= progressInterval * 18) {
int bloodOrbLevel = ((EnergyBattery) getStackInSlot(0).getItem()).getOrbLevel();
EntityLivingBase entity = SummoningRegistry.getEntity(worldObj, bloodOrbLevel, ring1Inv, ring2Inv, ring3Inv);
if (entity != null) {
entity.setPosition(xCoord + 0.5, yCoord + 1, zCoord + 0.5);
worldObj.spawnEntityInWorld(entity);
if (entity instanceof IDemon) {
((IDemon) entity).setSummonedConditions();
}
worldObj.createExplosion(entity, entity.posX, entity.posY, entity.posZ, 3, false);
// deleteItemsInRing(1);
isActive = false;
progress = 0;
if (worldObj != null) {
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
}
}
}
}
}
}
Aggregations