use of WayofTime.bloodmagic.alchemyArray.AlchemyArrayEffect in project BloodMagic by WayofTime.
the class BindingRecipeMaker method getRecipes.
@Nonnull
public static List<BindingRecipeJEI> getRecipes() {
Map<List<ItemStack>, AlchemyArrayRecipeRegistry.AlchemyArrayRecipe> alchemyArrayRecipeMap = AlchemyArrayRecipeRegistry.getRecipes();
ArrayList<BindingRecipeJEI> recipes = new ArrayList<>();
for (Map.Entry<List<ItemStack>, AlchemyArrayRecipeRegistry.AlchemyArrayRecipe> itemStackAlchemyArrayRecipeEntry : alchemyArrayRecipeMap.entrySet()) {
List<ItemStack> input = itemStackAlchemyArrayRecipeEntry.getValue().getInput();
BiMap<ItemStackWrapper, AlchemyArrayEffect> catalystMap = itemStackAlchemyArrayRecipeEntry.getValue().catalystMap;
for (Map.Entry<ItemStackWrapper, AlchemyArrayEffect> entry : catalystMap.entrySet()) {
ItemStack catalyst = entry.getKey().toStack();
if (AlchemyArrayRecipeRegistry.getAlchemyArrayEffect(input, catalyst) instanceof AlchemyArrayEffectBinding) {
ItemStack output = ((AlchemyArrayEffectBinding) itemStackAlchemyArrayRecipeEntry.getValue().getAlchemyArrayEffectForCatalyst(catalyst)).outputStack;
BindingRecipeJEI recipe = new BindingRecipeJEI(input, catalyst, output);
recipes.add(recipe);
}
}
}
return recipes;
}
use of WayofTime.bloodmagic.alchemyArray.AlchemyArrayEffect in project BloodMagic by WayofTime.
the class TileAlchemyArray method attemptCraft.
public boolean attemptCraft() {
AlchemyArrayEffect effect = AlchemyArrayRecipeRegistry.getAlchemyArrayEffect(this.getStackInSlot(0), this.getStackInSlot(1));
if (effect != null) {
if (arrayEffect == null) {
arrayEffect = effect;
key = effect.getKey();
} else {
String effectKey = effect.getKey();
if (effectKey.equals(key)) {
// Good! Moving on.
} else {
// Something has changed, therefore we have to move our stuffs.
// TODO: Add an AlchemyArrayEffect.onBreak(); ?
arrayEffect = effect;
key = effect.getKey();
}
}
} else {
RecipeAlchemyArray recipe = BloodMagicAPI.INSTANCE.getRecipeRegistrar().getAlchemyArray(getStackInSlot(0), getStackInSlot(1));
if (recipe == null)
return false;
AlchemyArrayEffect newEffect = new AlchemyArrayEffectCraftingNew(recipe);
if (arrayEffect == null) {
arrayEffect = newEffect;
key = newEffect.key;
} else if (!newEffect.key.equals(key)) {
arrayEffect = newEffect;
key = newEffect.key;
}
}
if (arrayEffect != null) {
isActive = true;
if (arrayEffect.update(this, this.activeCounter)) {
this.decrStackSize(0, 1);
this.decrStackSize(1, 1);
this.getWorld().setBlockToAir(getPos());
}
return true;
}
return false;
}
use of WayofTime.bloodmagic.alchemyArray.AlchemyArrayEffect in project BloodMagic by WayofTime.
the class AlchemyArrayRecipeRegistry method registerRecipe.
/**
* General case for creating an AlchemyArrayEffect for a given input.
*
* @param input - Input item(s) that is used to change the Alchemy Circle into the
* circle that you are making
* @param catalystStack - Catalyst item that, when right-clicked onto the array, will
* cause an effect
* @param arrayEffect - The effect that will be activated once the array is activated
* @param circleRenderer - Circle rendered when the array is passive - can be substituted
* for a special renderer
*/
public static void registerRecipe(List<ItemStack> input, @Nullable ItemStack catalystStack, AlchemyArrayEffect arrayEffect, AlchemyCircleRenderer circleRenderer) {
effectMap.put(arrayEffect.getKey(), arrayEffect);
for (Entry<List<ItemStack>, AlchemyArrayRecipe> entry : recipes.entrySet()) {
AlchemyArrayRecipe arrayRecipe = entry.getValue();
if (arrayRecipe.doesInputMatchRecipe(input)) {
AlchemyArrayEffect eff = arrayRecipe.getAlchemyArrayEffectForCatalyst(catalystStack);
if (eff != null) {
// Recipe already exists!
return;
} else {
arrayRecipe.catalystMap.put(ItemStackWrapper.getHolder(catalystStack), arrayEffect);
if (circleRenderer != null) {
if (arrayRecipe.defaultCircleRenderer == null) {
arrayRecipe.defaultCircleRenderer = circleRenderer;
} else {
arrayRecipe.circleMap.put(ItemStackWrapper.getHolder(catalystStack), circleRenderer);
}
}
return;
}
}
}
recipes.put(input, new AlchemyArrayRecipe(input, catalystStack, arrayEffect, circleRenderer == null ? DEFAULT_RENDERER : circleRenderer));
}
use of WayofTime.bloodmagic.alchemyArray.AlchemyArrayEffect in project BloodMagic by WayofTime.
the class TurretAlchemyCircleRenderer method renderAt.
@Override
public void renderAt(TileEntity tile, double x, double y, double z, float craftTime) {
if (!(tile instanceof TileAlchemyArray)) {
return;
}
// Not working
float f = 0;
TileAlchemyArray tileArray = (TileAlchemyArray) tile;
AlchemyArrayEffect effect = tileArray.arrayEffect;
double pitch = 0;
double yaw = 0;
int arrowTimer = -1;
if (effect instanceof AlchemyArrayEffectArrowTurret) {
AlchemyArrayEffectArrowTurret turretEffect = (AlchemyArrayEffectArrowTurret) effect;
pitch = (turretEffect.getPitch() - turretEffect.getLastPitch()) * f + turretEffect.getLastPitch();
yaw = (turretEffect.getYaw() - turretEffect.getLastYaw()) * f + turretEffect.getLastYaw();
arrowTimer = turretEffect.arrowTimer;
}
double arrowAnimation = arrowTimer + f;
Tessellator tessellator = Tessellator.getInstance();
BufferBuilder wr = tessellator.getBuffer();
GlStateManager.pushMatrix();
float rot = getRotation(craftTime);
float size = 1.0F * getSizeModifier(craftTime);
// Bind the texture to the circle
Minecraft.getMinecraft().renderEngine.bindTexture(arrayResource);
GlStateManager.disableCull();
GlStateManager.enableBlend();
GlStateManager.blendFunc(770, 1);
GlStateManager.translate(x, y, z);
// Specify which face this "circle" is located on
EnumFacing sideHit = EnumFacing.UP;
EnumFacing rotation = tileArray.getRotation();
GlStateManager.translate(sideHit.getFrontOffsetX() * offsetFromFace, sideHit.getFrontOffsetY() * offsetFromFace, sideHit.getFrontOffsetZ() * offsetFromFace);
switch(sideHit) {
case DOWN:
GlStateManager.translate(0, 0, 1);
GlStateManager.rotate(-90.0f, 1, 0, 0);
break;
case EAST:
GlStateManager.rotate(-90.0f, 0, 1, 0);
GlStateManager.translate(0, 0, -1);
break;
case NORTH:
break;
case SOUTH:
GlStateManager.rotate(180.0f, 0, 1, 0);
GlStateManager.translate(-1, 0, -1);
break;
case UP:
GlStateManager.translate(0, 1, 0);
GlStateManager.rotate(90.0f, 1, 0, 0);
break;
case WEST:
GlStateManager.translate(0, 0, 1);
GlStateManager.rotate(90.0f, 0, 1, 0);
break;
}
GlStateManager.pushMatrix();
GlStateManager.translate(0.5f, 0.5f, getVerticalOffset(craftTime));
// GlStateManager.rotate(rotation.getHorizontalAngle() + 180, 0, 0, 1);
GlStateManager.pushMatrix();
double topHeightOffset = getTopHeightOffset(craftTime, arrowAnimation);
double middleHeightOffset = getMiddleHeightOffset(craftTime, arrowAnimation);
double bottomHeightOffset = getBottomHeightOffset(craftTime, arrowAnimation);
BlockPos pos = tileArray.getPos();
World world = tileArray.getWorld();
GlStateManager.rotate((float) (yaw + 360 * getStartupPitchYawRatio(craftTime)), 0, 0, 1);
GlStateManager.rotate((float) ((pitch + 90) * getStartupPitchYawRatio(craftTime)), 1, 0, 0);
GlStateManager.pushMatrix();
Minecraft.getMinecraft().renderEngine.bindTexture(bottomArrayResource);
GlStateManager.rotate(-rot, 0, 0, 1);
GlStateManager.translate(0, 0, -bottomHeightOffset);
renderStandardCircle(tessellator, wr, size / 2);
GlStateManager.popMatrix();
GlStateManager.pushMatrix();
Minecraft.getMinecraft().renderEngine.bindTexture(middleArrayResource);
GlStateManager.rotate(0, 0, 0, 1);
GlStateManager.translate(0, 0, -middleHeightOffset);
renderStandardCircle(tessellator, wr, size);
GlStateManager.popMatrix();
GlStateManager.pushMatrix();
Minecraft.getMinecraft().renderEngine.bindTexture(arrayResource);
GlStateManager.rotate(rot, 0, 0, 1);
GlStateManager.translate(0, 0, -topHeightOffset);
renderStandardCircle(tessellator, wr, size);
GlStateManager.popMatrix();
GlStateManager.popMatrix();
// GlStateManager.depthMask(true);
GlStateManager.disableBlend();
GlStateManager.enableCull();
// GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
GlStateManager.popMatrix();
GlStateManager.popMatrix();
}
use of WayofTime.bloodmagic.alchemyArray.AlchemyArrayEffect in project BloodMagic by WayofTime.
the class AlchemyArrayRecipeRegistry method getRecipeForOutputStack.
/**
* @param stack of the recipe
* @return an array of two ItemStacks - first index is the input stack,
* second is the catalyst stack. Returns {null, null} if no recipe
* is valid.
*/
public static ItemStack[] getRecipeForOutputStack(ItemStack stack) {
for (Entry<List<ItemStack>, AlchemyArrayRecipe> entry : recipes.entrySet()) {
AlchemyArrayRecipe recipe = entry.getValue();
if (recipe != null && entry.getKey().size() > 0) {
for (Entry<ItemStackWrapper, AlchemyArrayEffect> effectEntry : recipe.catalystMap.entrySet()) {
if (effectEntry.getValue() instanceof AlchemyArrayEffectCrafting) {
AlchemyArrayEffectCrafting craftingEffect = (AlchemyArrayEffectCrafting) effectEntry.getValue();
ItemStack resultStack = craftingEffect.outputStack;
if (!resultStack.isEmpty()) {
if (resultStack.getItem() == stack.getItem() && resultStack.getItemDamage() == stack.getItemDamage()) {
return new ItemStack[] { entry.getKey().get(0), effectEntry.getKey().toStack() };
}
}
}
}
}
}
return new ItemStack[] { null, null };
}
Aggregations