use of hellfirepvp.astralsorcery.common.crafting.recipe.WellLiquefaction in project AstralSorcery by HellFirePvP.
the class WellManager method addRecipe.
@ZenCodeType.Method
public void addRecipe(String name, Fluid output, IIngredient input, float productionMultiplier, float shatterMultiplier, @ZenCodeType.OptionalInt(0x00FF55FF) int color) {
name = fixRecipeName(name);
ResourceLocation recipeId = new ResourceLocation(name);
WellLiquefaction recipe = new WellLiquefaction(recipeId, input.asVanillaIngredient(), output, new Color(color, true), productionMultiplier, shatterMultiplier);
CraftTweakerAPI.apply(new ActionAddRecipe(this, recipe));
}
use of hellfirepvp.astralsorcery.common.crafting.recipe.WellLiquefaction in project AstralSorcery by HellFirePvP.
the class WellRecipeSerializer method read.
@Override
public WellLiquefaction read(ResourceLocation recipeId, PacketBuffer buffer) {
Ingredient input = Ingredient.read(buffer);
Fluid fluid = ByteBufUtils.readRegistryEntry(buffer);
float shatter = buffer.readFloat();
float production = buffer.readFloat();
Color color = ByteBufUtils.readOptional(buffer, buf -> new Color(buf.readInt(), true));
return new WellLiquefaction(recipeId, input, fluid, color, production, shatter);
}
use of hellfirepvp.astralsorcery.common.crafting.recipe.WellLiquefaction in project AstralSorcery by HellFirePvP.
the class WellRecipeSerializer method read.
@Override
public WellLiquefaction read(ResourceLocation recipeId, JsonObject json) {
Ingredient input = Ingredient.deserialize(JSONUtils.getJsonObject(json, "input"));
String fluidKey = JSONUtils.getString(json, "output");
Fluid fluid = ForgeRegistries.FLUIDS.getValue(new ResourceLocation(fluidKey));
if (fluid == null) {
throw new JsonSyntaxException("Unknown fluid: " + fluidKey);
}
float productionMultiplier = JSONUtils.getFloat(json, "productionMultiplier");
float shatterMultiplier = JSONUtils.getFloat(json, "shatterMultiplier");
Color color = null;
if (json.has("color")) {
color = JsonHelper.getColor(json, "color");
}
return new WellLiquefaction(recipeId, input, fluid, color, productionMultiplier, shatterMultiplier);
}
use of hellfirepvp.astralsorcery.common.crafting.recipe.WellLiquefaction 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