use of com.infinityraider.agricraft.api.v1.crop.IAgriGrowthStage in project AgriCraft by AgriCraft.
the class TileEntityCropBase method revertGrowthStage.
protected void revertGrowthStage() {
IAgriGrowthStage current = this.getGrowthStage();
IAgriGrowthStage previous = current.getPreviousStage(this, this.getRandom());
if (current.equals(previous)) {
this.removeGenome();
} else {
this.setGrowthStage(previous);
}
}
use of com.infinityraider.agricraft.api.v1.crop.IAgriGrowthStage in project AgriCraft by AgriCraft.
the class AgriRecipeCategoryGrowthRequirements method draw.
@Override
public void draw(@Nonnull IAgriPlant plant, @Nonnull MatrixStack transforms, double mouseX, double mouseY) {
// Fetch strength and stage
PlantRenderState state = this.getState(plant);
int strength = state.getStrength();
IAgriGrowthStage stage = state.getStage();
IAgriGrowthRequirement req = plant.getGrowthRequirement(stage);
// Tell the renderer to render with a custom growth stage
AgriIngredientPlant.RENDERER.useGrowthStageForNextRenderCall(plant, stage);
// Draw increments
IncrementRenderer.getInstance().renderStrengthIncrements(transforms, strength);
IncrementRenderer.getInstance().renderGrowthStageIncrements(transforms, stage);
// Draw light levels
LightLevelRenderer.getInstance().renderLightLevels(transforms, 32, 26, mouseX, mouseY, light -> req.getLightLevelResponse(light, strength).isFertile());
// Draw Property icons
Arrays.stream(IAgriSoil.Humidity.values()).filter(IAgriSoil.Humidity::isValid).filter(humidity -> req.getSoilHumidityResponse(humidity, strength).isFertile()).forEach(humidity -> SoilPropertyIconRenderer.getInstance().drawHumidityIcon(humidity, transforms, 37, 83, mouseX, mouseY));
Arrays.stream(IAgriSoil.Acidity.values()).filter(IAgriSoil.Acidity::isValid).filter(acidity -> req.getSoilAcidityResponse(acidity, strength).isFertile()).forEach(acidity -> SoilPropertyIconRenderer.getInstance().drawAcidityIcon(acidity, transforms, 37, 96, mouseX, mouseY));
Arrays.stream(IAgriSoil.Nutrients.values()).filter(IAgriSoil.Nutrients::isValid).filter(nutrients -> req.getSoilNutrientsResponse(nutrients, strength).isFertile()).forEach(nutrients -> SoilPropertyIconRenderer.getInstance().drawNutrientsIcon(nutrients, transforms, 37, 109, mouseX, mouseY));
// Draw seasons
SeasonRenderer.getInstance().renderSeasons(transforms, 17, 24, season -> req.getSeasonResponse(season, strength).isFertile());
// Draw buttons
state.updateStageButtons(102, 10);
state.updateStrengthButtons(114, 10);
state.drawGrowthStageButtons(transforms, mouseX, mouseY);
state.drawStrengthButtons(transforms, mouseX, mouseY);
// Draw tooltips
this.tooltips.forEach(tooltip -> tooltip.drawTooltip(transforms, mouseX, mouseY, state));
}
use of com.infinityraider.agricraft.api.v1.crop.IAgriGrowthStage in project AgriCraft by AgriCraft.
the class AgriRecipeCategoryGrowthRequirements method setIngredients.
@Override
public void setIngredients(@Nonnull IAgriPlant plant, IIngredients ingredients) {
// Get current strength and stage
PlantRenderState state = this.getState(plant);
int strength = state.getStrength();
IAgriGrowthStage stage = state.getStage();
// Determine inputs
List<ItemStack> seeds = new ImmutableList.Builder<ItemStack>().add(plant.toItemStack()).addAll(plant.getSeedItems()).build();
List<ItemStack> soils = AgriApi.getSoilRegistry().stream().filter(soil -> {
IAgriGrowthRequirement req = plant.getGrowthRequirement(stage);
boolean humidity = req.getSoilHumidityResponse(soil.getHumidity(), strength).isFertile();
boolean acidity = req.getSoilAcidityResponse(soil.getAcidity(), strength).isFertile();
boolean nutrients = req.getSoilNutrientsResponse(soil.getNutrients(), strength).isFertile();
return humidity && acidity && nutrients;
}).map(IAgriSoil::getVariants).flatMap(Collection::stream).map(AbstractBlock.AbstractBlockState::getBlock).distinct().map(ItemStack::new).collect(Collectors.toList());
ingredients.setInputLists(VanillaTypes.ITEM, ImmutableList.of(seeds, soils));
// Determine output
ingredients.setOutputLists(AgriIngredientPlant.TYPE, ImmutableList.of(ImmutableList.of(plant)));
}
use of com.infinityraider.agricraft.api.v1.crop.IAgriGrowthStage in project AgriCraft by AgriCraft.
the class MysticalAgricultureCompatClient method bakeQuadsForMystical.
@Nonnull
private static List<BakedQuad> bakeQuadsForMystical(IAgriGrowable growable, IAgriGrowthStage stage, @Nullable Direction face, IntFunction<TextureAtlasSprite> spriteFunc) {
if (face != null) {
return ImmutableList.of();
}
ITessellator tessellator = AgriPlantQuadGenerator.getInstance().getTessellator();
TextureAtlasSprite sprite = spriteFunc.apply(0);
tessellator.startDrawingQuads();
tessellator.setFace((Direction) null);
tessellator.pushMatrix();
tessellator.drawScaledFaceDouble(-2, 0, 10, 12, Direction.NORTH, sprite, 4.001F, 0, 0, 16, 16);
tessellator.drawScaledFaceDouble(6, 0, 18, 12, Direction.NORTH, sprite, 3.999F, 0, 0, 16, 16);
tessellator.drawScaledFaceDouble(-2, 0, 10, 12, Direction.EAST, sprite, 4.001F, 0, 0, 16, 16);
tessellator.drawScaledFaceDouble(6, 0, 18, 12, Direction.EAST, sprite, 3.999F, 0, 0, 16, 16);
tessellator.drawScaledFaceDouble(-2, 0, 10, 12, Direction.NORTH, sprite, 12.001F, 0, 0, 16, 16);
tessellator.drawScaledFaceDouble(6, 0, 18, 12, Direction.NORTH, sprite, 11.999F, 0, 0, 16, 16);
tessellator.drawScaledFaceDouble(-2, 0, 10, 12, Direction.EAST, sprite, 12.001F, 0, 0, 16, 16);
tessellator.drawScaledFaceDouble(6, 0, 18, 12, Direction.EAST, sprite, 11.999F, 0, 0, 16, 16);
if (stage.isFinal()) {
IAgriPlant plant = ((IAgriPlant) growable);
int flowerColor = MysticalAgricultureCompatClient.colorForFlower(plant.getId());
TextureAtlasSprite flowerSprite = spriteFunc.apply(1);
if (flowerColor != -1) {
tessellator.setColorRGB(((flowerColor >> 16) & 0xFF) / 255.0F, ((flowerColor >> 8) & 0xFF) / 255.0F, ((flowerColor) & 0xFF) / 255.0F);
}
tessellator.drawScaledFaceDouble(-2, 0, 10, 12, Direction.NORTH, flowerSprite, 4.001F, 0, 0, 16, 16);
tessellator.drawScaledFaceDouble(6, 0, 18, 12, Direction.NORTH, flowerSprite, 3.999F, 0, 0, 16, 16);
tessellator.drawScaledFaceDouble(-2, 0, 10, 12, Direction.EAST, flowerSprite, 4.001F, 0, 0, 16, 16);
tessellator.drawScaledFaceDouble(6, 0, 18, 12, Direction.EAST, flowerSprite, 3.999F, 0, 0, 16, 16);
tessellator.drawScaledFaceDouble(-2, 0, 10, 12, Direction.NORTH, flowerSprite, 12.001F, 0, 0, 16, 16);
tessellator.drawScaledFaceDouble(6, 0, 18, 12, Direction.NORTH, flowerSprite, 11.999F, 0, 0, 16, 16);
tessellator.drawScaledFaceDouble(-2, 0, 10, 12, Direction.EAST, flowerSprite, 12.001F, 0, 0, 16, 16);
tessellator.drawScaledFaceDouble(6, 0, 18, 12, Direction.EAST, flowerSprite, 11.999F, 0, 0, 16, 16);
}
tessellator.translate(0, 12.0F / 16.0F, 0);
tessellator.popMatrix();
List<BakedQuad> quads = tessellator.getQuads();
tessellator.draw();
return quads;
}
use of com.infinityraider.agricraft.api.v1.crop.IAgriGrowthStage in project AgriCraft by AgriCraft.
the class JsonFertilizer method applyFertilizer.
@Override
public ActionResultType applyFertilizer(World world, BlockPos pos, IAgriFertilizable target, ItemStack stack, Random random, @Nullable LivingEntity entity) {
if (target instanceof IAgriPlantProvider) {
IAgriCrop crop = ((IAgriCrop) target);
String type = "neutral";
for (int i = 0; i < this.potency; i++) {
if (fertilizerEffect.isNegativelyAffected(crop.getPlant().getId())) {
if (fertilizerEffect.canReduceGrowth() && random.nextBoolean()) {
type = "negative";
IAgriGrowthStage current = crop.getGrowthStage();
IAgriGrowthStage previous = current.getPreviousStage(crop, random);
if (current.equals(previous)) {
if (fertilizerEffect.canKillPlant()) {
crop.removeGenome();
}
} else {
crop.setGrowthStage(previous);
}
}
} else {
if (crop.hasPlant() && this.fertilizerEffect.canFertilize(crop.getPlant().getId())) {
target.applyGrowthTick();
type = "positive";
} else if (crop.isCrossCrop() && this.canTriggerMutation()) {
target.applyGrowthTick();
type = "positive";
} else if (this.canTriggerWeeds()) {
target.applyGrowthTick();
type = "positive";
}
}
}
this.spawnParticles(world, pos, type, random);
if ((entity instanceof PlayerEntity) && !(((PlayerEntity) entity).isCreative())) {
stack.shrink(1);
}
return ActionResultType.SUCCESS;
}
return ActionResultType.FAIL;
}
Aggregations