use of hellfirepvp.astralsorcery.common.crafting.recipe.WellLiquefactionContext in project AstralSorcery by HellFirePvP.
the class TileWell method doClientEffects.
@OnlyIn(Dist.CLIENT)
private void doClientEffects() {
ItemStack stack = this.inventory.getStackInSlot(0);
if (!stack.isEmpty()) {
runningRecipe = RecipeTypesAS.TYPE_WELL.findRecipe(new WellLiquefactionContext(this));
if (runningRecipe != null) {
Color color = Color.WHITE;
if (runningRecipe.getCatalystColor() != null) {
color = runningRecipe.getCatalystColor();
}
doCatalystEffect(color);
}
}
if (tank.getFluidAmount() > 0 && tank.getFluid().getFluid() instanceof FluidLiquidStarlight) {
BlockLiquidStarlight.playLiquidStarlightBlockEffect(rand, new Vector3(this).add(0, 0.4 + tank.getPercentageFilled() * 0.5, 0), 0.7F);
}
}
use of hellfirepvp.astralsorcery.common.crafting.recipe.WellLiquefactionContext in project AstralSorcery by HellFirePvP.
the class TileWell method tick.
@Override
public void tick() {
super.tick();
if (!getWorld().isRemote()) {
if (this.doesSeeSky()) {
this.collectStarlight();
}
ItemStack stack = this.getInventory().getStackInSlot(0);
if (!stack.isEmpty()) {
if (!getWorld().isAirBlock(getPos().up())) {
breakCatalyst();
} else {
if (runningRecipe == null) {
runningRecipe = RecipeTypesAS.TYPE_WELL.findRecipe(new WellLiquefactionContext(this));
}
if (runningRecipe != null) {
int statMultiplier = 1;
if (stack.getItem() instanceof CrystalAttributeItem) {
CrystalAttributes attributes = ((CrystalAttributeItem) stack.getItem()).getAttributes(stack);
if (attributes != null) {
statMultiplier = attributes.getTotalTierLevel();
}
}
double gain = Math.sqrt(starlightBuffer) * (statMultiplier * runningRecipe.getProductionMultiplier());
if (gain > 0 && tank.getFluidAmount() <= TANK_SIZE) {
fillAndDiscardRest(runningRecipe, gain);
if (rand.nextInt(750) == 0) {
EntityFlare.spawnAmbientFlare(getWorld(), getPos().add(-3 + rand.nextInt(7), 1, -3 + rand.nextInt(7)));
}
}
starlightBuffer = 0;
if (rand.nextInt(1 + (int) (1000 * (statMultiplier * runningRecipe.getShatterMultiplier()))) == 0) {
breakCatalyst();
EntityFlare.spawnAmbientFlare(getWorld(), getPos().add(-3 + rand.nextInt(7), 1, -3 + rand.nextInt(7)));
}
} else {
breakCatalyst();
}
}
}
this.starlightBuffer = 0;
} else {
doClientEffects();
}
}
use of hellfirepvp.astralsorcery.common.crafting.recipe.WellLiquefactionContext in project AstralSorcery by HellFirePvP.
the class BlockWell method onBlockActivated.
@Override
public ActionResultType onBlockActivated(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult hit) {
if (!world.isRemote()) {
ItemStack heldItem = player.getHeldItem(hand);
if (!heldItem.isEmpty()) {
TileWell tw = MiscUtils.getTileAt(world, pos, TileWell.class, false);
if (tw == null) {
return ActionResultType.PASS;
}
WellLiquefaction entry = RecipeTypesAS.TYPE_WELL.findRecipe(new WellLiquefactionContext(heldItem));
if (entry != null) {
ItemStackHandler handle = tw.getInventory();
if (!handle.getStackInSlot(0).isEmpty()) {
return ActionResultType.PASS;
}
if (!world.isAirBlock(pos.up())) {
return ActionResultType.PASS;
}
handle.setStackInSlot(0, ItemUtils.copyStackWithSize(heldItem, 1));
world.playSound(null, pos.getX(), pos.getY(), pos.getZ(), SoundEvents.ENTITY_ITEM_PICKUP, SoundCategory.PLAYERS, 0.2F, ((world.rand.nextFloat() - world.rand.nextFloat()) * 0.7F + 1.0F) * 2.0F);
if (!player.isCreative()) {
heldItem.shrink(1);
}
if (heldItem.getCount() <= 0) {
player.setHeldItem(hand, ItemStack.EMPTY);
}
}
tw.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, null).ifPresent((handler) -> {
FluidActionResult far = FluidUtil.tryFillContainerAndStow(heldItem, handler, new InvWrapper(player.inventory), FluidAttributes.BUCKET_VOLUME, player, true);
if (far.isSuccess()) {
player.setHeldItem(hand, far.getResult());
SoundHelper.playSoundAround(SoundEvents.ITEM_BUCKET_FILL, world, pos, 1F, 1F);
tw.markForUpdate();
}
});
}
}
return ActionResultType.SUCCESS;
}
Aggregations